documentation.d.ts 3.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532
  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. private static _Counter;
  1457. /**
  1458. * Gets or sets the number of objects referencing this buffer
  1459. */
  1460. references: number;
  1461. /** Gets or sets the size of the underlying buffer */
  1462. capacity: number;
  1463. /**
  1464. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1465. */
  1466. is32Bits: boolean;
  1467. /**
  1468. * Gets the underlying buffer
  1469. */
  1470. get underlyingResource(): any;
  1471. /**
  1472. * Gets the unique id of this buffer
  1473. */
  1474. readonly uniqueId: number;
  1475. /**
  1476. * Constructs the buffer
  1477. */
  1478. constructor();
  1479. }
  1480. }
  1481. declare module BABYLON {
  1482. /** @hidden */
  1483. export interface IShaderProcessor {
  1484. attributeProcessor?: (attribute: string, preProcessors: {
  1485. [key: string]: string;
  1486. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1488. [key: string]: string;
  1489. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1490. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1491. [key: string]: string;
  1492. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1493. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1494. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1496. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1497. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1498. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1499. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1500. vertexCode: string;
  1501. fragmentCode: string;
  1502. };
  1503. }
  1504. }
  1505. declare module BABYLON {
  1506. /** @hidden */
  1507. export interface ShaderProcessingContext {
  1508. }
  1509. /** @hidden */
  1510. export interface ProcessingOptions {
  1511. defines: string[];
  1512. indexParameters: any;
  1513. isFragment: boolean;
  1514. shouldUseHighPrecisionShader: boolean;
  1515. supportsUniformBuffers: boolean;
  1516. shadersRepository: string;
  1517. includesShadersStore: {
  1518. [key: string]: string;
  1519. };
  1520. processor: Nullable<IShaderProcessor>;
  1521. version: string;
  1522. platformName: string;
  1523. lookForClosingBracketForUniformBuffer?: boolean;
  1524. processingContext: Nullable<ShaderProcessingContext>;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /** @hidden */
  1529. export class ShaderCodeNode {
  1530. line: string;
  1531. children: ShaderCodeNode[];
  1532. additionalDefineKey?: string;
  1533. additionalDefineValue?: string;
  1534. isValid(preprocessors: {
  1535. [key: string]: string;
  1536. }): boolean;
  1537. process(preprocessors: {
  1538. [key: string]: string;
  1539. }, options: ProcessingOptions): string;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /** @hidden */
  1544. export class ShaderCodeCursor {
  1545. private _lines;
  1546. lineIndex: number;
  1547. get currentLine(): string;
  1548. get canRead(): boolean;
  1549. set lines(value: string[]);
  1550. }
  1551. }
  1552. declare module BABYLON {
  1553. /** @hidden */
  1554. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1555. process(preprocessors: {
  1556. [key: string]: string;
  1557. }, options: ProcessingOptions): string;
  1558. }
  1559. }
  1560. declare module BABYLON {
  1561. /** @hidden */
  1562. export class ShaderDefineExpression {
  1563. isTrue(preprocessors: {
  1564. [key: string]: string;
  1565. }): boolean;
  1566. private static _OperatorPriority;
  1567. private static _Stack;
  1568. static postfixToInfix(postfix: string[]): string;
  1569. static infixToPostfix(infix: string): string[];
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderCodeTestNode extends ShaderCodeNode {
  1575. testExpression: ShaderDefineExpression;
  1576. isValid(preprocessors: {
  1577. [key: string]: string;
  1578. }): boolean;
  1579. }
  1580. }
  1581. declare module BABYLON {
  1582. /** @hidden */
  1583. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1584. define: string;
  1585. not: boolean;
  1586. constructor(define: string, not?: boolean);
  1587. isTrue(preprocessors: {
  1588. [key: string]: string;
  1589. }): boolean;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /** @hidden */
  1594. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1595. leftOperand: ShaderDefineExpression;
  1596. rightOperand: ShaderDefineExpression;
  1597. isTrue(preprocessors: {
  1598. [key: string]: string;
  1599. }): boolean;
  1600. }
  1601. }
  1602. declare module BABYLON {
  1603. /** @hidden */
  1604. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1605. leftOperand: ShaderDefineExpression;
  1606. rightOperand: ShaderDefineExpression;
  1607. isTrue(preprocessors: {
  1608. [key: string]: string;
  1609. }): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /** @hidden */
  1614. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1615. define: string;
  1616. operand: string;
  1617. testValue: string;
  1618. constructor(define: string, operand: string, testValue: string);
  1619. isTrue(preprocessors: {
  1620. [key: string]: string;
  1621. }): boolean;
  1622. }
  1623. }
  1624. declare module BABYLON {
  1625. /**
  1626. * Class used to enable access to offline support
  1627. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1628. */
  1629. export interface IOfflineProvider {
  1630. /**
  1631. * Gets a boolean indicating if scene must be saved in the database
  1632. */
  1633. enableSceneOffline: boolean;
  1634. /**
  1635. * Gets a boolean indicating if textures must be saved in the database
  1636. */
  1637. enableTexturesOffline: boolean;
  1638. /**
  1639. * Open the offline support and make it available
  1640. * @param successCallback defines the callback to call on success
  1641. * @param errorCallback defines the callback to call on error
  1642. */
  1643. open(successCallback: () => void, errorCallback: () => void): void;
  1644. /**
  1645. * Loads an image from the offline support
  1646. * @param url defines the url to load from
  1647. * @param image defines the target DOM image
  1648. */
  1649. loadImage(url: string, image: HTMLImageElement): void;
  1650. /**
  1651. * Loads a file from offline support
  1652. * @param url defines the URL to load from
  1653. * @param sceneLoaded defines a callback to call on success
  1654. * @param progressCallBack defines a callback to call when progress changed
  1655. * @param errorCallback defines a callback to call on error
  1656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1657. */
  1658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1659. }
  1660. }
  1661. declare module BABYLON {
  1662. /**
  1663. * Class used to help managing file picking and drag'n'drop
  1664. * File Storage
  1665. */
  1666. export class FilesInputStore {
  1667. /**
  1668. * List of files ready to be loaded
  1669. */
  1670. static FilesToLoad: {
  1671. [key: string]: File;
  1672. };
  1673. }
  1674. }
  1675. declare module BABYLON {
  1676. /**
  1677. * Class used to define a retry strategy when error happens while loading assets
  1678. */
  1679. export class RetryStrategy {
  1680. /**
  1681. * Function used to defines an exponential back off strategy
  1682. * @param maxRetries defines the maximum number of retries (3 by default)
  1683. * @param baseInterval defines the interval between retries
  1684. * @returns the strategy function to use
  1685. */
  1686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /**
  1691. * @ignore
  1692. * Application error to support additional information when loading a file
  1693. */
  1694. export abstract class BaseError extends Error {
  1695. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1696. }
  1697. }
  1698. declare module BABYLON {
  1699. /** @ignore */
  1700. export class LoadFileError extends BaseError {
  1701. request?: WebRequest;
  1702. file?: File;
  1703. /**
  1704. * Creates a new LoadFileError
  1705. * @param message defines the message of the error
  1706. * @param request defines the optional web request
  1707. * @param file defines the optional file
  1708. */
  1709. constructor(message: string, object?: WebRequest | File);
  1710. }
  1711. /** @ignore */
  1712. export class RequestFileError extends BaseError {
  1713. request: WebRequest;
  1714. /**
  1715. * Creates a new LoadFileError
  1716. * @param message defines the message of the error
  1717. * @param request defines the optional web request
  1718. */
  1719. constructor(message: string, request: WebRequest);
  1720. }
  1721. /** @ignore */
  1722. export class ReadFileError extends BaseError {
  1723. file: File;
  1724. /**
  1725. * Creates a new ReadFileError
  1726. * @param message defines the message of the error
  1727. * @param file defines the optional file
  1728. */
  1729. constructor(message: string, file: File);
  1730. }
  1731. /**
  1732. * @hidden
  1733. */
  1734. export class FileTools {
  1735. /**
  1736. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1737. */
  1738. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1739. /**
  1740. * Gets or sets the base URL to use to load assets
  1741. */
  1742. static BaseUrl: string;
  1743. /**
  1744. * Default behaviour for cors in the application.
  1745. * It can be a string if the expected behavior is identical in the entire app.
  1746. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1747. */
  1748. static CorsBehavior: string | ((url: string | string[]) => string);
  1749. /**
  1750. * Gets or sets a function used to pre-process url before using them to load assets
  1751. */
  1752. static PreprocessUrl: (url: string) => string;
  1753. /**
  1754. * Removes unwanted characters from an url
  1755. * @param url defines the url to clean
  1756. * @returns the cleaned url
  1757. */
  1758. private static _CleanUrl;
  1759. /**
  1760. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1761. * @param url define the url we are trying
  1762. * @param element define the dom element where to configure the cors policy
  1763. */
  1764. static SetCorsBehavior(url: string | string[], element: {
  1765. crossOrigin: string | null;
  1766. }): void;
  1767. /**
  1768. * Loads an image as an HTMLImageElement.
  1769. * @param input url string, ArrayBuffer, or Blob to load
  1770. * @param onLoad callback called when the image successfully loads
  1771. * @param onError callback called when the image fails to load
  1772. * @param offlineProvider offline provider for caching
  1773. * @param mimeType optional mime type
  1774. * @returns the HTMLImageElement of the loaded image
  1775. */
  1776. 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>;
  1777. /**
  1778. * Reads a file from a File object
  1779. * @param file defines the file to load
  1780. * @param onSuccess defines the callback to call when data is loaded
  1781. * @param onProgress defines the callback to call during loading process
  1782. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1783. * @param onError defines the callback to call when an error occurs
  1784. * @returns a file request object
  1785. */
  1786. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1787. /**
  1788. * Loads a file from a url
  1789. * @param url url to load
  1790. * @param onSuccess callback called when the file successfully loads
  1791. * @param onProgress callback called while file is loading (if the server supports this mode)
  1792. * @param offlineProvider defines the offline provider for caching
  1793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1794. * @param onError callback called when the file fails to load
  1795. * @returns a file request object
  1796. */
  1797. 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;
  1798. /**
  1799. * Loads a file
  1800. * @param url url to load
  1801. * @param onSuccess callback called when the file successfully loads
  1802. * @param onProgress callback called while file is loading (if the server supports this mode)
  1803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1804. * @param onError callback called when the file fails to load
  1805. * @param onOpened callback called when the web request is opened
  1806. * @returns a file request object
  1807. */
  1808. 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;
  1809. /**
  1810. * Checks if the loaded document was accessed via `file:`-Protocol.
  1811. * @returns boolean
  1812. */
  1813. static IsFileURL(): boolean;
  1814. }
  1815. }
  1816. declare module BABYLON {
  1817. /** @hidden */
  1818. export class ShaderProcessor {
  1819. static Initialize(options: ProcessingOptions): void;
  1820. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1821. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1822. vertexCode: string;
  1823. fragmentCode: string;
  1824. };
  1825. private static _ProcessPrecision;
  1826. private static _ExtractOperation;
  1827. private static _BuildSubExpression;
  1828. private static _BuildExpression;
  1829. private static _MoveCursorWithinIf;
  1830. private static _MoveCursor;
  1831. private static _EvaluatePreProcessors;
  1832. private static _PreparePreProcessors;
  1833. private static _ProcessShaderConversion;
  1834. private static _ProcessIncludes;
  1835. /**
  1836. * Loads a file from a url
  1837. * @param url url to load
  1838. * @param onSuccess callback called when the file successfully loads
  1839. * @param onProgress callback called while file is loading (if the server supports this mode)
  1840. * @param offlineProvider defines the offline provider for caching
  1841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1842. * @param onError callback called when the file fails to load
  1843. * @returns a file request object
  1844. * @hidden
  1845. */
  1846. 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;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Interface used to define common properties for effect fallbacks
  1852. */
  1853. export interface IEffectFallbacks {
  1854. /**
  1855. * Removes the defines that should be removed when falling back.
  1856. * @param currentDefines defines the current define statements for the shader.
  1857. * @param effect defines the current effect we try to compile
  1858. * @returns The resulting defines with defines of the current rank removed.
  1859. */
  1860. reduce(currentDefines: string, effect: Effect): string;
  1861. /**
  1862. * Removes the fallback from the bound mesh.
  1863. */
  1864. unBindMesh(): void;
  1865. /**
  1866. * Checks to see if more fallbacks are still availible.
  1867. */
  1868. hasMoreFallbacks: boolean;
  1869. }
  1870. }
  1871. declare module BABYLON {
  1872. /**
  1873. * Interface for the size containing width and height
  1874. */
  1875. export interface ISize {
  1876. /**
  1877. * Width
  1878. */
  1879. width: number;
  1880. /**
  1881. * Heighht
  1882. */
  1883. height: number;
  1884. }
  1885. /**
  1886. * Size containing widht and height
  1887. */
  1888. export class Size implements ISize {
  1889. /**
  1890. * Width
  1891. */
  1892. width: number;
  1893. /**
  1894. * Height
  1895. */
  1896. height: number;
  1897. /**
  1898. * Creates a Size object from the given width and height (floats).
  1899. * @param width width of the new size
  1900. * @param height height of the new size
  1901. */
  1902. constructor(width: number, height: number);
  1903. /**
  1904. * Returns a string with the Size width and height
  1905. * @returns a string with the Size width and height
  1906. */
  1907. toString(): string;
  1908. /**
  1909. * "Size"
  1910. * @returns the string "Size"
  1911. */
  1912. getClassName(): string;
  1913. /**
  1914. * Returns the Size hash code.
  1915. * @returns a hash code for a unique width and height
  1916. */
  1917. getHashCode(): number;
  1918. /**
  1919. * Updates the current size from the given one.
  1920. * @param src the given size
  1921. */
  1922. copyFrom(src: Size): void;
  1923. /**
  1924. * Updates in place the current Size from the given floats.
  1925. * @param width width of the new size
  1926. * @param height height of the new size
  1927. * @returns the updated Size.
  1928. */
  1929. copyFromFloats(width: number, height: number): Size;
  1930. /**
  1931. * Updates in place the current Size from the given floats.
  1932. * @param width width to set
  1933. * @param height height to set
  1934. * @returns the updated Size.
  1935. */
  1936. set(width: number, height: number): Size;
  1937. /**
  1938. * Multiplies the width and height by numbers
  1939. * @param w factor to multiple the width by
  1940. * @param h factor to multiple the height by
  1941. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1942. */
  1943. multiplyByFloats(w: number, h: number): Size;
  1944. /**
  1945. * Clones the size
  1946. * @returns a new Size copied from the given one.
  1947. */
  1948. clone(): Size;
  1949. /**
  1950. * True if the current Size and the given one width and height are strictly equal.
  1951. * @param other the other size to compare against
  1952. * @returns True if the current Size and the given one width and height are strictly equal.
  1953. */
  1954. equals(other: Size): boolean;
  1955. /**
  1956. * The surface of the Size : width * height (float).
  1957. */
  1958. get surface(): number;
  1959. /**
  1960. * Create a new size of zero
  1961. * @returns a new Size set to (0.0, 0.0)
  1962. */
  1963. static Zero(): Size;
  1964. /**
  1965. * Sums the width and height of two sizes
  1966. * @param otherSize size to add to this size
  1967. * @returns a new Size set as the addition result of the current Size and the given one.
  1968. */
  1969. add(otherSize: Size): Size;
  1970. /**
  1971. * Subtracts the width and height of two
  1972. * @param otherSize size to subtract to this size
  1973. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1974. */
  1975. subtract(otherSize: Size): Size;
  1976. /**
  1977. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1978. * @param start starting size to lerp between
  1979. * @param end end size to lerp between
  1980. * @param amount amount to lerp between the start and end values
  1981. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1982. */
  1983. static Lerp(start: Size, end: Size, amount: number): Size;
  1984. }
  1985. }
  1986. declare module BABYLON {
  1987. /**
  1988. * Base class of all the textures in babylon.
  1989. * It groups all the common properties required to work with Thin Engine.
  1990. */
  1991. export class ThinTexture {
  1992. protected _wrapU: number;
  1993. /**
  1994. * | Value | Type | Description |
  1995. * | ----- | ------------------ | ----------- |
  1996. * | 0 | CLAMP_ADDRESSMODE | |
  1997. * | 1 | WRAP_ADDRESSMODE | |
  1998. * | 2 | MIRROR_ADDRESSMODE | |
  1999. */
  2000. get wrapU(): number;
  2001. set wrapU(value: number);
  2002. protected _wrapV: number;
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. get wrapV(): number;
  2011. set wrapV(value: number);
  2012. /**
  2013. * | Value | Type | Description |
  2014. * | ----- | ------------------ | ----------- |
  2015. * | 0 | CLAMP_ADDRESSMODE | |
  2016. * | 1 | WRAP_ADDRESSMODE | |
  2017. * | 2 | MIRROR_ADDRESSMODE | |
  2018. */
  2019. wrapR: number;
  2020. /**
  2021. * With compliant hardware and browser (supporting anisotropic filtering)
  2022. * this defines the level of anisotropic filtering in the texture.
  2023. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2024. */
  2025. anisotropicFilteringLevel: number;
  2026. /**
  2027. * Define the current state of the loading sequence when in delayed load mode.
  2028. */
  2029. delayLoadState: number;
  2030. /**
  2031. * How a texture is mapped.
  2032. * Unused in thin texture mode.
  2033. */
  2034. get coordinatesMode(): number;
  2035. /**
  2036. * Define if the texture is a cube texture or if false a 2d texture.
  2037. */
  2038. get isCube(): boolean;
  2039. set isCube(value: boolean);
  2040. /**
  2041. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2042. */
  2043. get is3D(): boolean;
  2044. set is3D(value: boolean);
  2045. /**
  2046. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is2DArray(): boolean;
  2049. set is2DArray(value: boolean);
  2050. /**
  2051. * Get the class name of the texture.
  2052. * @returns "ThinTexture"
  2053. */
  2054. getClassName(): string;
  2055. /** @hidden */
  2056. _texture: Nullable<InternalTexture>;
  2057. protected _engine: Nullable<ThinEngine>;
  2058. private _cachedSize;
  2059. private _cachedBaseSize;
  2060. /**
  2061. * Instantiates a new ThinTexture.
  2062. * Base class of all the textures in babylon.
  2063. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2064. * @param internalTexture Define the internalTexture to wrap
  2065. */
  2066. constructor(internalTexture: Nullable<InternalTexture>);
  2067. /**
  2068. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2069. * @returns true if fully ready
  2070. */
  2071. isReady(): boolean;
  2072. /**
  2073. * Triggers the load sequence in delayed load mode.
  2074. */
  2075. delayLoad(): void;
  2076. /**
  2077. * Get the underlying lower level texture from Babylon.
  2078. * @returns the insternal texture
  2079. */
  2080. getInternalTexture(): Nullable<InternalTexture>;
  2081. /**
  2082. * Get the size of the texture.
  2083. * @returns the texture size.
  2084. */
  2085. getSize(): ISize;
  2086. /**
  2087. * Get the base size of the texture.
  2088. * It can be different from the size if the texture has been resized for POT for instance
  2089. * @returns the base size
  2090. */
  2091. getBaseSize(): ISize;
  2092. /**
  2093. * Update the sampling mode of the texture.
  2094. * Default is Trilinear mode.
  2095. *
  2096. * | Value | Type | Description |
  2097. * | ----- | ------------------ | ----------- |
  2098. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2099. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2100. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2101. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2102. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2103. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2104. * | 7 | NEAREST_LINEAR | |
  2105. * | 8 | NEAREST_NEAREST | |
  2106. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2107. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2108. * | 11 | LINEAR_LINEAR | |
  2109. * | 12 | LINEAR_NEAREST | |
  2110. *
  2111. * > _mag_: magnification filter (close to the viewer)
  2112. * > _min_: minification filter (far from the viewer)
  2113. * > _mip_: filter used between mip map levels
  2114. *@param samplingMode Define the new sampling mode of the texture
  2115. */
  2116. updateSamplingMode(samplingMode: number): void;
  2117. /**
  2118. * Release and destroy the underlying lower level texture aka internalTexture.
  2119. */
  2120. releaseInternalTexture(): void;
  2121. /**
  2122. * Dispose the texture and release its associated resources.
  2123. */
  2124. dispose(): void;
  2125. }
  2126. }
  2127. declare module BABYLON {
  2128. /**
  2129. * Defines an array and its length.
  2130. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2131. */
  2132. export interface ISmartArrayLike<T> {
  2133. /**
  2134. * The data of the array.
  2135. */
  2136. data: Array<T>;
  2137. /**
  2138. * The active length of the array.
  2139. */
  2140. length: number;
  2141. }
  2142. /**
  2143. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2144. */
  2145. export class SmartArray<T> implements ISmartArrayLike<T> {
  2146. /**
  2147. * The full set of data from the array.
  2148. */
  2149. data: Array<T>;
  2150. /**
  2151. * The active length of the array.
  2152. */
  2153. length: number;
  2154. protected _id: number;
  2155. /**
  2156. * Instantiates a Smart Array.
  2157. * @param capacity defines the default capacity of the array.
  2158. */
  2159. constructor(capacity: number);
  2160. /**
  2161. * Pushes a value at the end of the active data.
  2162. * @param value defines the object to push in the array.
  2163. */
  2164. push(value: T): void;
  2165. /**
  2166. * Iterates over the active data and apply the lambda to them.
  2167. * @param func defines the action to apply on each value.
  2168. */
  2169. forEach(func: (content: T) => void): void;
  2170. /**
  2171. * Sorts the full sets of data.
  2172. * @param compareFn defines the comparison function to apply.
  2173. */
  2174. sort(compareFn: (a: T, b: T) => number): void;
  2175. /**
  2176. * Resets the active data to an empty array.
  2177. */
  2178. reset(): void;
  2179. /**
  2180. * Releases all the data from the array as well as the array.
  2181. */
  2182. dispose(): void;
  2183. /**
  2184. * Concats the active data with a given array.
  2185. * @param array defines the data to concatenate with.
  2186. */
  2187. concat(array: any): void;
  2188. /**
  2189. * Returns the position of a value in the active data.
  2190. * @param value defines the value to find the index for
  2191. * @returns the index if found in the active data otherwise -1
  2192. */
  2193. indexOf(value: T): number;
  2194. /**
  2195. * Returns whether an element is part of the active data.
  2196. * @param value defines the value to look for
  2197. * @returns true if found in the active data otherwise false
  2198. */
  2199. contains(value: T): boolean;
  2200. private static _GlobalId;
  2201. }
  2202. /**
  2203. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2204. * The data in this array can only be present once
  2205. */
  2206. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2207. private _duplicateId;
  2208. /**
  2209. * Pushes a value at the end of the active data.
  2210. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2211. * @param value defines the object to push in the array.
  2212. */
  2213. push(value: T): void;
  2214. /**
  2215. * Pushes a value at the end of the active data.
  2216. * If the data is already present, it won t be added again
  2217. * @param value defines the object to push in the array.
  2218. * @returns true if added false if it was already present
  2219. */
  2220. pushNoDuplicate(value: T): boolean;
  2221. /**
  2222. * Resets the active data to an empty array.
  2223. */
  2224. reset(): void;
  2225. /**
  2226. * Concats the active data with a given array.
  2227. * This ensures no dupplicate will be present in the result.
  2228. * @param array defines the data to concatenate with.
  2229. */
  2230. concatWithNoDuplicate(array: any): void;
  2231. }
  2232. }
  2233. declare module BABYLON {
  2234. /**
  2235. * Class used to evalaute queries containing `and` and `or` operators
  2236. */
  2237. export class AndOrNotEvaluator {
  2238. /**
  2239. * Evaluate a query
  2240. * @param query defines the query to evaluate
  2241. * @param evaluateCallback defines the callback used to filter result
  2242. * @returns true if the query matches
  2243. */
  2244. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2245. private static _HandleParenthesisContent;
  2246. private static _SimplifyNegation;
  2247. }
  2248. }
  2249. declare module BABYLON {
  2250. /**
  2251. * Class used to store custom tags
  2252. */
  2253. export class Tags {
  2254. /**
  2255. * Adds support for tags on the given object
  2256. * @param obj defines the object to use
  2257. */
  2258. static EnableFor(obj: any): void;
  2259. /**
  2260. * Removes tags support
  2261. * @param obj defines the object to use
  2262. */
  2263. static DisableFor(obj: any): void;
  2264. /**
  2265. * Gets a boolean indicating if the given object has tags
  2266. * @param obj defines the object to use
  2267. * @returns a boolean
  2268. */
  2269. static HasTags(obj: any): boolean;
  2270. /**
  2271. * Gets the tags available on a given object
  2272. * @param obj defines the object to use
  2273. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2274. * @returns the tags
  2275. */
  2276. static GetTags(obj: any, asString?: boolean): any;
  2277. /**
  2278. * Adds tags to an object
  2279. * @param obj defines the object to use
  2280. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2281. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2282. */
  2283. static AddTagsTo(obj: any, tagsString: string): void;
  2284. /**
  2285. * @hidden
  2286. */
  2287. static _AddTagTo(obj: any, tag: string): void;
  2288. /**
  2289. * Removes specific tags from a specific object
  2290. * @param obj defines the object to use
  2291. * @param tagsString defines the tags to remove
  2292. */
  2293. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2294. /**
  2295. * @hidden
  2296. */
  2297. static _RemoveTagFrom(obj: any, tag: string): void;
  2298. /**
  2299. * Defines if tags hosted on an object match a given query
  2300. * @param obj defines the object to use
  2301. * @param tagsQuery defines the tag query
  2302. * @returns a boolean
  2303. */
  2304. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2305. }
  2306. }
  2307. declare module BABYLON {
  2308. /**
  2309. * Scalar computation library
  2310. */
  2311. export class Scalar {
  2312. /**
  2313. * Two pi constants convenient for computation.
  2314. */
  2315. static TwoPi: number;
  2316. /**
  2317. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2318. * @param a number
  2319. * @param b number
  2320. * @param epsilon (default = 1.401298E-45)
  2321. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2322. */
  2323. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2324. /**
  2325. * Returns a string : the upper case translation of the number i to hexadecimal.
  2326. * @param i number
  2327. * @returns the upper case translation of the number i to hexadecimal.
  2328. */
  2329. static ToHex(i: number): string;
  2330. /**
  2331. * Returns -1 if value is negative and +1 is value is positive.
  2332. * @param value the value
  2333. * @returns the value itself if it's equal to zero.
  2334. */
  2335. static Sign(value: number): number;
  2336. /**
  2337. * Returns the value itself if it's between min and max.
  2338. * Returns min if the value is lower than min.
  2339. * Returns max if the value is greater than max.
  2340. * @param value the value to clmap
  2341. * @param min the min value to clamp to (default: 0)
  2342. * @param max the max value to clamp to (default: 1)
  2343. * @returns the clamped value
  2344. */
  2345. static Clamp(value: number, min?: number, max?: number): number;
  2346. /**
  2347. * the log2 of value.
  2348. * @param value the value to compute log2 of
  2349. * @returns the log2 of value.
  2350. */
  2351. static Log2(value: number): number;
  2352. /**
  2353. * the floor part of a log2 value.
  2354. * @param value the value to compute log2 of
  2355. * @returns the log2 of value.
  2356. */
  2357. static ILog2(value: number): number;
  2358. /**
  2359. * Loops the value, so that it is never larger than length and never smaller than 0.
  2360. *
  2361. * This is similar to the modulo operator but it works with floating point numbers.
  2362. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2363. * With t = 5 and length = 2.5, the result would be 0.0.
  2364. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2365. * @param value the value
  2366. * @param length the length
  2367. * @returns the looped value
  2368. */
  2369. static Repeat(value: number, length: number): number;
  2370. /**
  2371. * Normalize the value between 0.0 and 1.0 using min and max values
  2372. * @param value value to normalize
  2373. * @param min max to normalize between
  2374. * @param max min to normalize between
  2375. * @returns the normalized value
  2376. */
  2377. static Normalize(value: number, min: number, max: number): number;
  2378. /**
  2379. * Denormalize the value from 0.0 and 1.0 using min and max values
  2380. * @param normalized value to denormalize
  2381. * @param min max to denormalize between
  2382. * @param max min to denormalize between
  2383. * @returns the denormalized value
  2384. */
  2385. static Denormalize(normalized: number, min: number, max: number): number;
  2386. /**
  2387. * Calculates the shortest difference between two given angles given in degrees.
  2388. * @param current current angle in degrees
  2389. * @param target target angle in degrees
  2390. * @returns the delta
  2391. */
  2392. static DeltaAngle(current: number, target: number): number;
  2393. /**
  2394. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2395. * @param tx value
  2396. * @param length length
  2397. * @returns The returned value will move back and forth between 0 and length
  2398. */
  2399. static PingPong(tx: number, length: number): number;
  2400. /**
  2401. * Interpolates between min and max with smoothing at the limits.
  2402. *
  2403. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2404. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2405. * @param from from
  2406. * @param to to
  2407. * @param tx value
  2408. * @returns the smooth stepped value
  2409. */
  2410. static SmoothStep(from: number, to: number, tx: number): number;
  2411. /**
  2412. * Moves a value current towards target.
  2413. *
  2414. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2415. * Negative values of maxDelta pushes the value away from target.
  2416. * @param current current value
  2417. * @param target target value
  2418. * @param maxDelta max distance to move
  2419. * @returns resulting value
  2420. */
  2421. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2422. /**
  2423. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2424. *
  2425. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2426. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2427. * @param current current value
  2428. * @param target target value
  2429. * @param maxDelta max distance to move
  2430. * @returns resulting angle
  2431. */
  2432. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2433. /**
  2434. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  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 Lerp(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2443. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2444. * @param start start value
  2445. * @param end target value
  2446. * @param amount amount to lerp between
  2447. * @returns the lerped value
  2448. */
  2449. static LerpAngle(start: number, end: number, amount: number): number;
  2450. /**
  2451. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2452. * @param a start value
  2453. * @param b target value
  2454. * @param value value between a and b
  2455. * @returns the inverseLerp value
  2456. */
  2457. static InverseLerp(a: number, b: number, value: number): number;
  2458. /**
  2459. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2460. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2461. * @param value1 spline value
  2462. * @param tangent1 spline value
  2463. * @param value2 spline value
  2464. * @param tangent2 spline value
  2465. * @param amount input value
  2466. * @returns hermite result
  2467. */
  2468. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2469. /**
  2470. * Returns a random float number between and min and max values
  2471. * @param min min value of random
  2472. * @param max max value of random
  2473. * @returns random value
  2474. */
  2475. static RandomRange(min: number, max: number): number;
  2476. /**
  2477. * This function returns percentage of a number in a given range.
  2478. *
  2479. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2480. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2481. * @param number to convert to percentage
  2482. * @param min min range
  2483. * @param max max range
  2484. * @returns the percentage
  2485. */
  2486. static RangeToPercent(number: number, min: number, max: number): number;
  2487. /**
  2488. * This function returns number that corresponds to the percentage in a given range.
  2489. *
  2490. * PercentToRange(0.34,0,100) will return 34.
  2491. * @param percent to convert to number
  2492. * @param min min range
  2493. * @param max max range
  2494. * @returns the number
  2495. */
  2496. static PercentToRange(percent: number, min: number, max: number): number;
  2497. /**
  2498. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2499. * @param angle The angle to normalize in radian.
  2500. * @return The converted angle.
  2501. */
  2502. static NormalizeRadians(angle: number): number;
  2503. }
  2504. }
  2505. declare module BABYLON {
  2506. /**
  2507. * Constant used to convert a value to gamma space
  2508. * @ignorenaming
  2509. */
  2510. export const ToGammaSpace: number;
  2511. /**
  2512. * Constant used to convert a value to linear space
  2513. * @ignorenaming
  2514. */
  2515. export const ToLinearSpace = 2.2;
  2516. /**
  2517. * Constant used to define the minimal number value in Babylon.js
  2518. * @ignorenaming
  2519. */
  2520. let Epsilon: number;
  2521. }
  2522. declare module BABYLON {
  2523. /**
  2524. * Class used to represent a viewport on screen
  2525. */
  2526. export class Viewport {
  2527. /** viewport left coordinate */
  2528. x: number;
  2529. /** viewport top coordinate */
  2530. y: number;
  2531. /**viewport width */
  2532. width: number;
  2533. /** viewport height */
  2534. height: number;
  2535. /**
  2536. * Creates a Viewport object located at (x, y) and sized (width, height)
  2537. * @param x defines viewport left coordinate
  2538. * @param y defines viewport top coordinate
  2539. * @param width defines the viewport width
  2540. * @param height defines the viewport height
  2541. */
  2542. constructor(
  2543. /** viewport left coordinate */
  2544. x: number,
  2545. /** viewport top coordinate */
  2546. y: number,
  2547. /**viewport width */
  2548. width: number,
  2549. /** viewport height */
  2550. height: number);
  2551. /**
  2552. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2553. * @param renderWidth defines the rendering width
  2554. * @param renderHeight defines the rendering height
  2555. * @returns a new Viewport
  2556. */
  2557. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2558. /**
  2559. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2560. * @param renderWidth defines the rendering width
  2561. * @param renderHeight defines the rendering height
  2562. * @param ref defines the target viewport
  2563. * @returns the current viewport
  2564. */
  2565. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2566. /**
  2567. * Returns a new Viewport copied from the current one
  2568. * @returns a new Viewport
  2569. */
  2570. clone(): Viewport;
  2571. }
  2572. }
  2573. declare module BABYLON {
  2574. /**
  2575. * Class containing a set of static utilities functions for arrays.
  2576. */
  2577. export class ArrayTools {
  2578. /**
  2579. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2580. * @param size the number of element to construct and put in the array
  2581. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2582. * @returns a new array filled with new objects
  2583. */
  2584. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2585. }
  2586. }
  2587. declare module BABYLON {
  2588. /**
  2589. * Represents a plane by the equation ax + by + cz + d = 0
  2590. */
  2591. export class Plane {
  2592. private static _TmpMatrix;
  2593. /**
  2594. * Normal of the plane (a,b,c)
  2595. */
  2596. normal: Vector3;
  2597. /**
  2598. * d component of the plane
  2599. */
  2600. d: number;
  2601. /**
  2602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2603. * @param a a component of the plane
  2604. * @param b b component of the plane
  2605. * @param c c component of the plane
  2606. * @param d d component of the plane
  2607. */
  2608. constructor(a: number, b: number, c: number, d: number);
  2609. /**
  2610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2611. */
  2612. asArray(): number[];
  2613. /**
  2614. * @returns a new plane copied from the current Plane.
  2615. */
  2616. clone(): Plane;
  2617. /**
  2618. * @returns the string "Plane".
  2619. */
  2620. getClassName(): string;
  2621. /**
  2622. * @returns the Plane hash code.
  2623. */
  2624. getHashCode(): number;
  2625. /**
  2626. * Normalize the current Plane in place.
  2627. * @returns the updated Plane.
  2628. */
  2629. normalize(): Plane;
  2630. /**
  2631. * Applies a transformation the plane and returns the result
  2632. * @param transformation the transformation matrix to be applied to the plane
  2633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2634. */
  2635. transform(transformation: DeepImmutable<Matrix>): Plane;
  2636. /**
  2637. * Compute the dot product between the point and the plane normal
  2638. * @param point point to calculate the dot product with
  2639. * @returns the dot product (float) of the point coordinates and the plane normal.
  2640. */
  2641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2642. /**
  2643. * Updates the current Plane from the plane defined by the three given points.
  2644. * @param point1 one of the points used to contruct the plane
  2645. * @param point2 one of the points used to contruct the plane
  2646. * @param point3 one of the points used to contruct the plane
  2647. * @returns the updated Plane.
  2648. */
  2649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2650. /**
  2651. * 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).
  2652. * Note that for this function to work as expected you should make sure that:
  2653. * - direction and the plane normal are normalized
  2654. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2655. * @param direction the direction to check if the plane is facing
  2656. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2657. * @returns True if the plane is facing the given direction
  2658. */
  2659. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2660. /**
  2661. * Calculates the distance to a point
  2662. * @param point point to calculate distance to
  2663. * @returns the signed distance (float) from the given point to the Plane.
  2664. */
  2665. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Creates a plane from an array
  2668. * @param array the array to create a plane from
  2669. * @returns a new Plane from the given array.
  2670. */
  2671. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2672. /**
  2673. * Creates a plane from three points
  2674. * @param point1 point used to create the plane
  2675. * @param point2 point used to create the plane
  2676. * @param point3 point used to create the plane
  2677. * @returns a new Plane defined by the three given points.
  2678. */
  2679. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2680. /**
  2681. * Creates a plane from an origin point and a normal
  2682. * @param origin origin of the plane to be constructed
  2683. * @param normal normal of the plane to be constructed
  2684. * @returns a new Plane the normal vector to this plane at the given origin point.
  2685. * Note : the vector "normal" is updated because normalized.
  2686. */
  2687. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2688. /**
  2689. * Calculates the distance from a plane and a point
  2690. * @param origin origin of the plane to be constructed
  2691. * @param normal normal of the plane to be constructed
  2692. * @param point point to calculate distance to
  2693. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2694. */
  2695. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2696. }
  2697. }
  2698. declare module BABYLON {
  2699. /** @hidden */
  2700. export class PerformanceConfigurator {
  2701. /** @hidden */
  2702. static MatrixUse64Bits: boolean;
  2703. /** @hidden */
  2704. static MatrixTrackPrecisionChange: boolean;
  2705. /** @hidden */
  2706. static MatrixCurrentType: any;
  2707. /** @hidden */
  2708. static MatrixTrackedMatrices: Array<any> | null;
  2709. /** @hidden */
  2710. static SetMatrixPrecision(use64bits: boolean): void;
  2711. }
  2712. }
  2713. declare module BABYLON {
  2714. /**
  2715. * Class representing a vector containing 2 coordinates
  2716. */
  2717. export class Vector2 {
  2718. /** defines the first coordinate */
  2719. x: number;
  2720. /** defines the second coordinate */
  2721. y: number;
  2722. /**
  2723. * Creates a new Vector2 from the given x and y coordinates
  2724. * @param x defines the first coordinate
  2725. * @param y defines the second coordinate
  2726. */
  2727. constructor(
  2728. /** defines the first coordinate */
  2729. x?: number,
  2730. /** defines the second coordinate */
  2731. y?: number);
  2732. /**
  2733. * Gets a string with the Vector2 coordinates
  2734. * @returns a string with the Vector2 coordinates
  2735. */
  2736. toString(): string;
  2737. /**
  2738. * Gets class name
  2739. * @returns the string "Vector2"
  2740. */
  2741. getClassName(): string;
  2742. /**
  2743. * Gets current vector hash code
  2744. * @returns the Vector2 hash code as a number
  2745. */
  2746. getHashCode(): number;
  2747. /**
  2748. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2749. * @param array defines the source array
  2750. * @param index defines the offset in source array
  2751. * @returns the current Vector2
  2752. */
  2753. toArray(array: FloatArray, index?: number): Vector2;
  2754. /**
  2755. * Update the current vector from an array
  2756. * @param array defines the destination array
  2757. * @param index defines the offset in the destination array
  2758. * @returns the current Vector3
  2759. */
  2760. fromArray(array: FloatArray, index?: number): Vector2;
  2761. /**
  2762. * Copy the current vector to an array
  2763. * @returns a new array with 2 elements: the Vector2 coordinates.
  2764. */
  2765. asArray(): number[];
  2766. /**
  2767. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2768. * @param source defines the source Vector2
  2769. * @returns the current updated Vector2
  2770. */
  2771. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Sets the Vector2 coordinates with the given floats
  2774. * @param x defines the first coordinate
  2775. * @param y defines the second coordinate
  2776. * @returns the current updated Vector2
  2777. */
  2778. copyFromFloats(x: number, y: number): Vector2;
  2779. /**
  2780. * Sets the Vector2 coordinates with the given floats
  2781. * @param x defines the first coordinate
  2782. * @param y defines the second coordinate
  2783. * @returns the current updated Vector2
  2784. */
  2785. set(x: number, y: number): Vector2;
  2786. /**
  2787. * Add another vector with the current one
  2788. * @param otherVector defines the other vector
  2789. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2790. */
  2791. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2792. /**
  2793. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2794. * @param otherVector defines the other vector
  2795. * @param result defines the target vector
  2796. * @returns the unmodified current Vector2
  2797. */
  2798. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2799. /**
  2800. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2801. * @param otherVector defines the other vector
  2802. * @returns the current updated Vector2
  2803. */
  2804. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2805. /**
  2806. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2807. * @param otherVector defines the other vector
  2808. * @returns a new Vector2
  2809. */
  2810. addVector3(otherVector: Vector3): Vector2;
  2811. /**
  2812. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2813. * @param otherVector defines the other vector
  2814. * @returns a new Vector2
  2815. */
  2816. subtract(otherVector: Vector2): Vector2;
  2817. /**
  2818. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2819. * @param otherVector defines the other vector
  2820. * @param result defines the target vector
  2821. * @returns the unmodified current Vector2
  2822. */
  2823. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2824. /**
  2825. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2826. * @param otherVector defines the other vector
  2827. * @returns the current updated Vector2
  2828. */
  2829. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Multiplies in place the current Vector2 coordinates by the given ones
  2832. * @param otherVector defines the other vector
  2833. * @returns the current updated Vector2
  2834. */
  2835. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2836. /**
  2837. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2838. * @param otherVector defines the other vector
  2839. * @returns a new Vector2
  2840. */
  2841. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2842. /**
  2843. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2844. * @param otherVector defines the other vector
  2845. * @param result defines the target vector
  2846. * @returns the unmodified current Vector2
  2847. */
  2848. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2849. /**
  2850. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2851. * @param x defines the first coordinate
  2852. * @param y defines the second coordinate
  2853. * @returns a new Vector2
  2854. */
  2855. multiplyByFloats(x: number, y: number): Vector2;
  2856. /**
  2857. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2858. * @param otherVector defines the other vector
  2859. * @returns a new Vector2
  2860. */
  2861. divide(otherVector: Vector2): Vector2;
  2862. /**
  2863. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2864. * @param otherVector defines the other vector
  2865. * @param result defines the target vector
  2866. * @returns the unmodified current Vector2
  2867. */
  2868. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2869. /**
  2870. * Divides the current Vector2 coordinates by the given ones
  2871. * @param otherVector defines the other vector
  2872. * @returns the current updated Vector2
  2873. */
  2874. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2875. /**
  2876. * Gets a new Vector2 with current Vector2 negated coordinates
  2877. * @returns a new Vector2
  2878. */
  2879. negate(): Vector2;
  2880. /**
  2881. * Negate this vector in place
  2882. * @returns this
  2883. */
  2884. negateInPlace(): Vector2;
  2885. /**
  2886. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2887. * @param result defines the Vector3 object where to store the result
  2888. * @returns the current Vector2
  2889. */
  2890. negateToRef(result: Vector2): Vector2;
  2891. /**
  2892. * Multiply the Vector2 coordinates by scale
  2893. * @param scale defines the scaling factor
  2894. * @returns the current updated Vector2
  2895. */
  2896. scaleInPlace(scale: number): Vector2;
  2897. /**
  2898. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2899. * @param scale defines the scaling factor
  2900. * @returns a new Vector2
  2901. */
  2902. scale(scale: number): Vector2;
  2903. /**
  2904. * Scale the current Vector2 values by a factor to a given Vector2
  2905. * @param scale defines the scale factor
  2906. * @param result defines the Vector2 object where to store the result
  2907. * @returns the unmodified current Vector2
  2908. */
  2909. scaleToRef(scale: number, result: Vector2): Vector2;
  2910. /**
  2911. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2912. * @param scale defines the scale factor
  2913. * @param result defines the Vector2 object where to store the result
  2914. * @returns the unmodified current Vector2
  2915. */
  2916. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2917. /**
  2918. * Gets a boolean if two vectors are equals
  2919. * @param otherVector defines the other vector
  2920. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2921. */
  2922. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2923. /**
  2924. * Gets a boolean if two vectors are equals (using an epsilon value)
  2925. * @param otherVector defines the other vector
  2926. * @param epsilon defines the minimal distance to consider equality
  2927. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2928. */
  2929. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2930. /**
  2931. * Gets a new Vector2 from current Vector2 floored values
  2932. * @returns a new Vector2
  2933. */
  2934. floor(): Vector2;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. fract(): Vector2;
  2940. /**
  2941. * Gets the length of the vector
  2942. * @returns the vector length (float)
  2943. */
  2944. length(): number;
  2945. /**
  2946. * Gets the vector squared length
  2947. * @returns the vector squared length (float)
  2948. */
  2949. lengthSquared(): number;
  2950. /**
  2951. * Normalize the vector
  2952. * @returns the current updated Vector2
  2953. */
  2954. normalize(): Vector2;
  2955. /**
  2956. * Gets a new Vector2 copied from the Vector2
  2957. * @returns a new Vector2
  2958. */
  2959. clone(): Vector2;
  2960. /**
  2961. * Gets a new Vector2(0, 0)
  2962. * @returns a new Vector2
  2963. */
  2964. static Zero(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(1, 1)
  2967. * @returns a new Vector2
  2968. */
  2969. static One(): Vector2;
  2970. /**
  2971. * Gets a new Vector2 set from the given index element of the given array
  2972. * @param array defines the data source
  2973. * @param offset defines the offset in the data source
  2974. * @returns a new Vector2
  2975. */
  2976. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2977. /**
  2978. * Sets "result" from the given index element of the given array
  2979. * @param array defines the data source
  2980. * @param offset defines the offset in the data source
  2981. * @param result defines the target vector
  2982. */
  2983. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2984. /**
  2985. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2986. * @param value1 defines 1st point of control
  2987. * @param value2 defines 2nd point of control
  2988. * @param value3 defines 3rd point of control
  2989. * @param value4 defines 4th point of control
  2990. * @param amount defines the interpolation factor
  2991. * @returns a new Vector2
  2992. */
  2993. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2994. /**
  2995. * 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".
  2996. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2997. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2998. * @param value defines the value to clamp
  2999. * @param min defines the lower limit
  3000. * @param max defines the upper limit
  3001. * @returns a new Vector2
  3002. */
  3003. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3004. /**
  3005. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3006. * @param value1 defines the 1st control point
  3007. * @param tangent1 defines the outgoing tangent
  3008. * @param value2 defines the 2nd control point
  3009. * @param tangent2 defines the incoming tangent
  3010. * @param amount defines the interpolation factor
  3011. * @returns a new Vector2
  3012. */
  3013. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3014. /**
  3015. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3016. * @param start defines the start vector
  3017. * @param end defines the end vector
  3018. * @param amount defines the interpolation factor
  3019. * @returns a new Vector2
  3020. */
  3021. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3022. /**
  3023. * Gets the dot product of the vector "left" and the vector "right"
  3024. * @param left defines first vector
  3025. * @param right defines second vector
  3026. * @returns the dot product (float)
  3027. */
  3028. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3029. /**
  3030. * Returns a new Vector2 equal to the normalized given vector
  3031. * @param vector defines the vector to normalize
  3032. * @returns a new Vector2
  3033. */
  3034. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3035. /**
  3036. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3037. * @param left defines 1st vector
  3038. * @param right defines 2nd vector
  3039. * @returns a new Vector2
  3040. */
  3041. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3042. /**
  3043. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3044. * @param left defines 1st vector
  3045. * @param right defines 2nd vector
  3046. * @returns a new Vector2
  3047. */
  3048. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3049. /**
  3050. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3051. * @param vector defines the vector to transform
  3052. * @param transformation defines the matrix to apply
  3053. * @returns a new Vector2
  3054. */
  3055. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3056. /**
  3057. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3058. * @param vector defines the vector to transform
  3059. * @param transformation defines the matrix to apply
  3060. * @param result defines the target vector
  3061. */
  3062. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3063. /**
  3064. * Determines if a given vector is included in a triangle
  3065. * @param p defines the vector to test
  3066. * @param p0 defines 1st triangle point
  3067. * @param p1 defines 2nd triangle point
  3068. * @param p2 defines 3rd triangle point
  3069. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3070. */
  3071. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3072. /**
  3073. * Gets the distance between the vectors "value1" and "value2"
  3074. * @param value1 defines first vector
  3075. * @param value2 defines second vector
  3076. * @returns the distance between vectors
  3077. */
  3078. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3079. /**
  3080. * Returns the squared distance between the vectors "value1" and "value2"
  3081. * @param value1 defines first vector
  3082. * @param value2 defines second vector
  3083. * @returns the squared distance between vectors
  3084. */
  3085. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3086. /**
  3087. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3088. * @param value1 defines first vector
  3089. * @param value2 defines second vector
  3090. * @returns a new Vector2
  3091. */
  3092. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3093. /**
  3094. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3095. * @param value1 defines first vector
  3096. * @param value2 defines second vector
  3097. * @param ref defines third vector
  3098. * @returns ref
  3099. */
  3100. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3101. /**
  3102. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3103. * @param p defines the middle point
  3104. * @param segA defines one point of the segment
  3105. * @param segB defines the other point of the segment
  3106. * @returns the shortest distance
  3107. */
  3108. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3109. }
  3110. /**
  3111. * Class used to store (x,y,z) vector representation
  3112. * A Vector3 is the main object used in 3D geometry
  3113. * It can represent etiher the coordinates of a point the space, either a direction
  3114. * Reminder: js uses a left handed forward facing system
  3115. */
  3116. export class Vector3 {
  3117. private static _UpReadOnly;
  3118. private static _ZeroReadOnly;
  3119. /** @hidden */
  3120. _x: number;
  3121. /** @hidden */
  3122. _y: number;
  3123. /** @hidden */
  3124. _z: number;
  3125. /** @hidden */
  3126. _isDirty: boolean;
  3127. /** Gets or sets the x coordinate */
  3128. get x(): number;
  3129. set x(value: number);
  3130. /** Gets or sets the y coordinate */
  3131. get y(): number;
  3132. set y(value: number);
  3133. /** Gets or sets the z coordinate */
  3134. get z(): number;
  3135. set z(value: number);
  3136. /**
  3137. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3138. * @param x defines the first coordinates (on X axis)
  3139. * @param y defines the second coordinates (on Y axis)
  3140. * @param z defines the third coordinates (on Z axis)
  3141. */
  3142. constructor(x?: number, y?: number, z?: number);
  3143. /**
  3144. * Creates a string representation of the Vector3
  3145. * @returns a string with the Vector3 coordinates.
  3146. */
  3147. toString(): string;
  3148. /**
  3149. * Gets the class name
  3150. * @returns the string "Vector3"
  3151. */
  3152. getClassName(): string;
  3153. /**
  3154. * Creates the Vector3 hash code
  3155. * @returns a number which tends to be unique between Vector3 instances
  3156. */
  3157. getHashCode(): number;
  3158. /**
  3159. * Creates an array containing three elements : the coordinates of the Vector3
  3160. * @returns a new array of numbers
  3161. */
  3162. asArray(): number[];
  3163. /**
  3164. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3165. * @param array defines the destination array
  3166. * @param index defines the offset in the destination array
  3167. * @returns the current Vector3
  3168. */
  3169. toArray(array: FloatArray, index?: number): Vector3;
  3170. /**
  3171. * Update the current vector from an array
  3172. * @param array defines the destination array
  3173. * @param index defines the offset in the destination array
  3174. * @returns the current Vector3
  3175. */
  3176. fromArray(array: FloatArray, index?: number): Vector3;
  3177. /**
  3178. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3179. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3180. */
  3181. toQuaternion(): Quaternion;
  3182. /**
  3183. * Adds the given vector to the current Vector3
  3184. * @param otherVector defines the second operand
  3185. * @returns the current updated Vector3
  3186. */
  3187. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Adds the given coordinates to the current Vector3
  3190. * @param x defines the x coordinate of the operand
  3191. * @param y defines the y coordinate of the operand
  3192. * @param z defines the z coordinate of the operand
  3193. * @returns the current updated Vector3
  3194. */
  3195. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3196. /**
  3197. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3198. * @param otherVector defines the second operand
  3199. * @returns the resulting Vector3
  3200. */
  3201. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3204. * @param otherVector defines the second operand
  3205. * @param result defines the Vector3 object where to store the result
  3206. * @returns the current Vector3
  3207. */
  3208. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3209. /**
  3210. * Subtract the given vector from the current Vector3
  3211. * @param otherVector defines the second operand
  3212. * @returns the current updated Vector3
  3213. */
  3214. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3215. /**
  3216. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3217. * @param otherVector defines the second operand
  3218. * @returns the resulting Vector3
  3219. */
  3220. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3221. /**
  3222. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3223. * @param otherVector defines the second operand
  3224. * @param result defines the Vector3 object where to store the result
  3225. * @returns the current Vector3
  3226. */
  3227. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3228. /**
  3229. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3230. * @param x defines the x coordinate of the operand
  3231. * @param y defines the y coordinate of the operand
  3232. * @param z defines the z coordinate of the operand
  3233. * @returns the resulting Vector3
  3234. */
  3235. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3236. /**
  3237. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3238. * @param x defines the x coordinate of the operand
  3239. * @param y defines the y coordinate of the operand
  3240. * @param z defines the z coordinate of the operand
  3241. * @param result defines the Vector3 object where to store the result
  3242. * @returns the current Vector3
  3243. */
  3244. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3245. /**
  3246. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3247. * @returns a new Vector3
  3248. */
  3249. negate(): Vector3;
  3250. /**
  3251. * Negate this vector in place
  3252. * @returns this
  3253. */
  3254. negateInPlace(): Vector3;
  3255. /**
  3256. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3257. * @param result defines the Vector3 object where to store the result
  3258. * @returns the current Vector3
  3259. */
  3260. negateToRef(result: Vector3): Vector3;
  3261. /**
  3262. * Multiplies the Vector3 coordinates by the float "scale"
  3263. * @param scale defines the multiplier factor
  3264. * @returns the current updated Vector3
  3265. */
  3266. scaleInPlace(scale: number): Vector3;
  3267. /**
  3268. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3269. * @param scale defines the multiplier factor
  3270. * @returns a new Vector3
  3271. */
  3272. scale(scale: number): Vector3;
  3273. /**
  3274. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3275. * @param scale defines the multiplier factor
  3276. * @param result defines the Vector3 object where to store the result
  3277. * @returns the current Vector3
  3278. */
  3279. scaleToRef(scale: number, result: Vector3): Vector3;
  3280. /**
  3281. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3282. * @param scale defines the scale factor
  3283. * @param result defines the Vector3 object where to store the result
  3284. * @returns the unmodified current Vector3
  3285. */
  3286. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3287. /**
  3288. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3289. * @param origin defines the origin of the projection ray
  3290. * @param plane defines the plane to project to
  3291. * @returns the projected vector3
  3292. */
  3293. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3294. /**
  3295. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3296. * @param origin defines the origin of the projection ray
  3297. * @param plane defines the plane to project to
  3298. * @param result defines the Vector3 where to store the result
  3299. */
  3300. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3301. /**
  3302. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3303. * @param otherVector defines the second operand
  3304. * @returns true if both vectors are equals
  3305. */
  3306. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3307. /**
  3308. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3309. * @param otherVector defines the second operand
  3310. * @param epsilon defines the minimal distance to define values as equals
  3311. * @returns true if both vectors are distant less than epsilon
  3312. */
  3313. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3314. /**
  3315. * Returns true if the current Vector3 coordinates equals the given floats
  3316. * @param x defines the x coordinate of the operand
  3317. * @param y defines the y coordinate of the operand
  3318. * @param z defines the z coordinate of the operand
  3319. * @returns true if both vectors are equals
  3320. */
  3321. equalsToFloats(x: number, y: number, z: number): boolean;
  3322. /**
  3323. * Multiplies the current Vector3 coordinates by the given ones
  3324. * @param otherVector defines the second operand
  3325. * @returns the current updated Vector3
  3326. */
  3327. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3328. /**
  3329. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3330. * @param otherVector defines the second operand
  3331. * @returns the new Vector3
  3332. */
  3333. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3334. /**
  3335. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3336. * @param otherVector defines the second operand
  3337. * @param result defines the Vector3 object where to store the result
  3338. * @returns the current Vector3
  3339. */
  3340. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3343. * @param x defines the x coordinate of the operand
  3344. * @param y defines the y coordinate of the operand
  3345. * @param z defines the z coordinate of the operand
  3346. * @returns the new Vector3
  3347. */
  3348. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3349. /**
  3350. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3351. * @param otherVector defines the second operand
  3352. * @returns the new Vector3
  3353. */
  3354. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3355. /**
  3356. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3357. * @param otherVector defines the second operand
  3358. * @param result defines the Vector3 object where to store the result
  3359. * @returns the current Vector3
  3360. */
  3361. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3362. /**
  3363. * Divides the current Vector3 coordinates by the given ones.
  3364. * @param otherVector defines the second operand
  3365. * @returns the current updated Vector3
  3366. */
  3367. divideInPlace(otherVector: Vector3): Vector3;
  3368. /**
  3369. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3370. * @param other defines the second operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3374. /**
  3375. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3376. * @param other defines the second operand
  3377. * @returns the current updated Vector3
  3378. */
  3379. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3380. /**
  3381. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3382. * @param x defines the x coordinate of the operand
  3383. * @param y defines the y coordinate of the operand
  3384. * @param z defines the z coordinate of the operand
  3385. * @returns the current updated Vector3
  3386. */
  3387. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3388. /**
  3389. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3390. * @param x defines the x coordinate of the operand
  3391. * @param y defines the y coordinate of the operand
  3392. * @param z defines the z coordinate of the operand
  3393. * @returns the current updated Vector3
  3394. */
  3395. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3396. /**
  3397. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3398. * Check if is non uniform within a certain amount of decimal places to account for this
  3399. * @param epsilon the amount the values can differ
  3400. * @returns if the the vector is non uniform to a certain number of decimal places
  3401. */
  3402. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3403. /**
  3404. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3405. */
  3406. get isNonUniform(): boolean;
  3407. /**
  3408. * Gets a new Vector3 from current Vector3 floored values
  3409. * @returns a new Vector3
  3410. */
  3411. floor(): Vector3;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. fract(): Vector3;
  3417. /**
  3418. * Gets the length of the Vector3
  3419. * @returns the length of the Vector3
  3420. */
  3421. length(): number;
  3422. /**
  3423. * Gets the squared length of the Vector3
  3424. * @returns squared length of the Vector3
  3425. */
  3426. lengthSquared(): number;
  3427. /**
  3428. * Normalize the current Vector3.
  3429. * Please note that this is an in place operation.
  3430. * @returns the current updated Vector3
  3431. */
  3432. normalize(): Vector3;
  3433. /**
  3434. * Reorders the x y z properties of the vector in place
  3435. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3436. * @returns the current updated vector
  3437. */
  3438. reorderInPlace(order: string): this;
  3439. /**
  3440. * Rotates the vector around 0,0,0 by a quaternion
  3441. * @param quaternion the rotation quaternion
  3442. * @param result vector to store the result
  3443. * @returns the resulting vector
  3444. */
  3445. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3446. /**
  3447. * Rotates a vector around a given point
  3448. * @param quaternion the rotation quaternion
  3449. * @param point the point to rotate around
  3450. * @param result vector to store the result
  3451. * @returns the resulting vector
  3452. */
  3453. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3454. /**
  3455. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3456. * The cross product is then orthogonal to both current and "other"
  3457. * @param other defines the right operand
  3458. * @returns the cross product
  3459. */
  3460. cross(other: Vector3): Vector3;
  3461. /**
  3462. * Normalize the current Vector3 with the given input length.
  3463. * Please note that this is an in place operation.
  3464. * @param len the length of the vector
  3465. * @returns the current updated Vector3
  3466. */
  3467. normalizeFromLength(len: number): Vector3;
  3468. /**
  3469. * Normalize the current Vector3 to a new vector
  3470. * @returns the new Vector3
  3471. */
  3472. normalizeToNew(): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to the reference
  3475. * @param reference define the Vector3 to update
  3476. * @returns the updated Vector3
  3477. */
  3478. normalizeToRef(reference: Vector3): Vector3;
  3479. /**
  3480. * Creates a new Vector3 copied from the current Vector3
  3481. * @returns the new Vector3
  3482. */
  3483. clone(): Vector3;
  3484. /**
  3485. * Copies the given vector coordinates to the current Vector3 ones
  3486. * @param source defines the source Vector3
  3487. * @returns the current updated Vector3
  3488. */
  3489. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Copies the given floats to the current Vector3 coordinates
  3492. * @param x defines the x coordinate of the operand
  3493. * @param y defines the y coordinate of the operand
  3494. * @param z defines the z coordinate of the operand
  3495. * @returns the current updated Vector3
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number): Vector3;
  3498. /**
  3499. * Copies the given floats to the current Vector3 coordinates
  3500. * @param x defines the x coordinate of the operand
  3501. * @param y defines the y coordinate of the operand
  3502. * @param z defines the z coordinate of the operand
  3503. * @returns the current updated Vector3
  3504. */
  3505. set(x: number, y: number, z: number): Vector3;
  3506. /**
  3507. * Copies the given float to the current Vector3 coordinates
  3508. * @param v defines the x, y and z coordinates of the operand
  3509. * @returns the current updated Vector3
  3510. */
  3511. setAll(v: number): Vector3;
  3512. /**
  3513. * Get the clip factor between two vectors
  3514. * @param vector0 defines the first operand
  3515. * @param vector1 defines the second operand
  3516. * @param axis defines the axis to use
  3517. * @param size defines the size along the axis
  3518. * @returns the clip factor
  3519. */
  3520. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3521. /**
  3522. * Get angle between two vectors
  3523. * @param vector0 angle between vector0 and vector1
  3524. * @param vector1 angle between vector0 and vector1
  3525. * @param normal direction of the normal
  3526. * @return the angle between vector0 and vector1
  3527. */
  3528. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3529. /**
  3530. * Returns a new Vector3 set from the index "offset" of the given array
  3531. * @param array defines the source array
  3532. * @param offset defines the offset in the source array
  3533. * @returns the new Vector3
  3534. */
  3535. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3536. /**
  3537. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3538. * @param array defines the source array
  3539. * @param offset defines the offset in the source array
  3540. * @returns the new Vector3
  3541. * @deprecated Please use FromArray instead.
  3542. */
  3543. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3544. /**
  3545. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3546. * @param array defines the source array
  3547. * @param offset defines the offset in the source array
  3548. * @param result defines the Vector3 where to store the result
  3549. */
  3550. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3551. /**
  3552. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3553. * @param array defines the source array
  3554. * @param offset defines the offset in the source array
  3555. * @param result defines the Vector3 where to store the result
  3556. * @deprecated Please use FromArrayToRef instead.
  3557. */
  3558. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3559. /**
  3560. * Sets the given vector "result" with the given floats.
  3561. * @param x defines the x coordinate of the source
  3562. * @param y defines the y coordinate of the source
  3563. * @param z defines the z coordinate of the source
  3564. * @param result defines the Vector3 where to store the result
  3565. */
  3566. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3567. /**
  3568. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3569. * @returns a new empty Vector3
  3570. */
  3571. static Zero(): Vector3;
  3572. /**
  3573. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3574. * @returns a new unit Vector3
  3575. */
  3576. static One(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3579. * @returns a new up Vector3
  3580. */
  3581. static Up(): Vector3;
  3582. /**
  3583. * Gets a up Vector3 that must not be updated
  3584. */
  3585. static get UpReadOnly(): DeepImmutable<Vector3>;
  3586. /**
  3587. * Gets a zero Vector3 that must not be updated
  3588. */
  3589. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3590. /**
  3591. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3592. * @returns a new down Vector3
  3593. */
  3594. static Down(): Vector3;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3597. * @param rightHandedSystem is the scene right-handed (negative z)
  3598. * @returns a new forward Vector3
  3599. */
  3600. static Forward(rightHandedSystem?: boolean): Vector3;
  3601. /**
  3602. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3603. * @param rightHandedSystem is the scene right-handed (negative-z)
  3604. * @returns a new forward Vector3
  3605. */
  3606. static Backward(rightHandedSystem?: boolean): Vector3;
  3607. /**
  3608. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3609. * @returns a new right Vector3
  3610. */
  3611. static Right(): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3614. * @returns a new left Vector3
  3615. */
  3616. static Left(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3619. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3620. * @param vector defines the Vector3 to transform
  3621. * @param transformation defines the transformation matrix
  3622. * @returns the transformed Vector3
  3623. */
  3624. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3625. /**
  3626. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3627. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3628. * @param vector defines the Vector3 to transform
  3629. * @param transformation defines the transformation matrix
  3630. * @param result defines the Vector3 where to store the result
  3631. */
  3632. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3633. /**
  3634. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3635. * This method computes tranformed coordinates only, not transformed direction vectors
  3636. * @param x define the x coordinate of the source vector
  3637. * @param y define the y coordinate of the source vector
  3638. * @param z define the z coordinate of the source vector
  3639. * @param transformation defines the transformation matrix
  3640. * @param result defines the Vector3 where to store the result
  3641. */
  3642. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3643. /**
  3644. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3645. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3646. * @param vector defines the Vector3 to transform
  3647. * @param transformation defines the transformation matrix
  3648. * @returns the new Vector3
  3649. */
  3650. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3651. /**
  3652. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3654. * @param vector defines the Vector3 to transform
  3655. * @param transformation defines the transformation matrix
  3656. * @param result defines the Vector3 where to store the result
  3657. */
  3658. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3659. /**
  3660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3661. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3662. * @param x define the x coordinate of the source vector
  3663. * @param y define the y coordinate of the source vector
  3664. * @param z define the z coordinate of the source vector
  3665. * @param transformation defines the transformation matrix
  3666. * @param result defines the Vector3 where to store the result
  3667. */
  3668. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3669. /**
  3670. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3671. * @param value1 defines the first control point
  3672. * @param value2 defines the second control point
  3673. * @param value3 defines the third control point
  3674. * @param value4 defines the fourth control point
  3675. * @param amount defines the amount on the spline to use
  3676. * @returns the new Vector3
  3677. */
  3678. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3679. /**
  3680. * 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"
  3681. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3682. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3683. * @param value defines the current value
  3684. * @param min defines the lower range value
  3685. * @param max defines the upper range value
  3686. * @returns the new Vector3
  3687. */
  3688. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3689. /**
  3690. * 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"
  3691. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3692. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3693. * @param value defines the current value
  3694. * @param min defines the lower range value
  3695. * @param max defines the upper range value
  3696. * @param result defines the Vector3 where to store the result
  3697. */
  3698. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3699. /**
  3700. * Checks if a given vector is inside a specific range
  3701. * @param v defines the vector to test
  3702. * @param min defines the minimum range
  3703. * @param max defines the maximum range
  3704. */
  3705. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3706. /**
  3707. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3708. * @param value1 defines the first control point
  3709. * @param tangent1 defines the first tangent vector
  3710. * @param value2 defines the second control point
  3711. * @param tangent2 defines the second tangent vector
  3712. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3713. * @returns the new Vector3
  3714. */
  3715. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3716. /**
  3717. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3718. * @param start defines the start value
  3719. * @param end defines the end value
  3720. * @param amount max defines amount between both (between 0 and 1)
  3721. * @returns the new Vector3
  3722. */
  3723. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3724. /**
  3725. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3726. * @param start defines the start value
  3727. * @param end defines the end value
  3728. * @param amount max defines amount between both (between 0 and 1)
  3729. * @param result defines the Vector3 where to store the result
  3730. */
  3731. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3732. /**
  3733. * Returns the dot product (float) between the vectors "left" and "right"
  3734. * @param left defines the left operand
  3735. * @param right defines the right operand
  3736. * @returns the dot product
  3737. */
  3738. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3739. /**
  3740. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3741. * The cross product is then orthogonal to both "left" and "right"
  3742. * @param left defines the left operand
  3743. * @param right defines the right operand
  3744. * @returns the cross product
  3745. */
  3746. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3747. /**
  3748. * Sets the given vector "result" with the cross product of "left" and "right"
  3749. * The cross product is then orthogonal to both "left" and "right"
  3750. * @param left defines the left operand
  3751. * @param right defines the right operand
  3752. * @param result defines the Vector3 where to store the result
  3753. */
  3754. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3755. /**
  3756. * Returns a new Vector3 as the normalization of the given vector
  3757. * @param vector defines the Vector3 to normalize
  3758. * @returns the new Vector3
  3759. */
  3760. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3761. /**
  3762. * Sets the given vector "result" with the normalization of the given first vector
  3763. * @param vector defines the Vector3 to normalize
  3764. * @param result defines the Vector3 where to store the result
  3765. */
  3766. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3767. /**
  3768. * Project a Vector3 onto screen space
  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. * @returns the new Vector3
  3774. */
  3775. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3776. /**
  3777. * Project a Vector3 onto screen space to reference
  3778. * @param vector defines the Vector3 to project
  3779. * @param world defines the world matrix to use
  3780. * @param transform defines the transform (view x projection) matrix to use
  3781. * @param viewport defines the screen viewport to use
  3782. * @param result the vector in which the screen space will be stored
  3783. * @returns the new Vector3
  3784. */
  3785. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3786. /** @hidden */
  3787. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3788. /**
  3789. * Unproject from screen space to object space
  3790. * @param source defines the screen space Vector3 to use
  3791. * @param viewportWidth defines the current width of the viewport
  3792. * @param viewportHeight defines the current height of the viewport
  3793. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3794. * @param transform defines the transform (view x projection) matrix to use
  3795. * @returns the new Vector3
  3796. */
  3797. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3798. /**
  3799. * Unproject from screen space to object space
  3800. * @param source defines the screen space Vector3 to use
  3801. * @param viewportWidth defines the current width of the viewport
  3802. * @param viewportHeight defines the current height of the viewport
  3803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3804. * @param view defines the view matrix to use
  3805. * @param projection defines the projection matrix to use
  3806. * @returns the new Vector3
  3807. */
  3808. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3809. /**
  3810. * Unproject from screen space to object space
  3811. * @param source defines the screen space Vector3 to use
  3812. * @param viewportWidth defines the current width of the viewport
  3813. * @param viewportHeight defines the current height of the viewport
  3814. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3815. * @param view defines the view matrix to use
  3816. * @param projection defines the projection matrix to use
  3817. * @param result defines the Vector3 where to store the result
  3818. */
  3819. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3820. /**
  3821. * Unproject from screen space to object space
  3822. * @param sourceX defines the screen space x coordinate to use
  3823. * @param sourceY defines the screen space y coordinate to use
  3824. * @param sourceZ defines the screen space z coordinate to use
  3825. * @param viewportWidth defines the current width of the viewport
  3826. * @param viewportHeight defines the current height of the viewport
  3827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3828. * @param view defines the view matrix to use
  3829. * @param projection defines the projection matrix to use
  3830. * @param result defines the Vector3 where to store the result
  3831. */
  3832. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3833. /**
  3834. * Gets the minimal coordinate values between two Vector3
  3835. * @param left defines the first operand
  3836. * @param right defines the second operand
  3837. * @returns the new Vector3
  3838. */
  3839. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3840. /**
  3841. * Gets the maximal coordinate values between two Vector3
  3842. * @param left defines the first operand
  3843. * @param right defines the second operand
  3844. * @returns the new Vector3
  3845. */
  3846. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3847. /**
  3848. * Returns the distance between the vectors "value1" and "value2"
  3849. * @param value1 defines the first operand
  3850. * @param value2 defines the second operand
  3851. * @returns the distance
  3852. */
  3853. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3854. /**
  3855. * Returns the squared distance between the vectors "value1" and "value2"
  3856. * @param value1 defines the first operand
  3857. * @param value2 defines the second operand
  3858. * @returns the squared distance
  3859. */
  3860. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3861. /**
  3862. * Returns a new Vector3 located at the center between "value1" and "value2"
  3863. * @param value1 defines the first operand
  3864. * @param value2 defines the second operand
  3865. * @returns the new Vector3
  3866. */
  3867. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3868. /**
  3869. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3870. * @param value1 defines first vector
  3871. * @param value2 defines second vector
  3872. * @param ref defines third vector
  3873. * @returns ref
  3874. */
  3875. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3876. /**
  3877. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3878. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3879. * to something in order to rotate it from its local system to the given target system
  3880. * Note: axis1, axis2 and axis3 are normalized during this operation
  3881. * @param axis1 defines the first axis
  3882. * @param axis2 defines the second axis
  3883. * @param axis3 defines the third axis
  3884. * @returns a new Vector3
  3885. */
  3886. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3887. /**
  3888. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3889. * @param axis1 defines the first axis
  3890. * @param axis2 defines the second axis
  3891. * @param axis3 defines the third axis
  3892. * @param ref defines the Vector3 where to store the result
  3893. */
  3894. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3895. }
  3896. /**
  3897. * Vector4 class created for EulerAngle class conversion to Quaternion
  3898. */
  3899. export class Vector4 {
  3900. /** x value of the vector */
  3901. x: number;
  3902. /** y value of the vector */
  3903. y: number;
  3904. /** z value of the vector */
  3905. z: number;
  3906. /** w value of the vector */
  3907. w: number;
  3908. /**
  3909. * Creates a Vector4 object from the given floats.
  3910. * @param x x value of the vector
  3911. * @param y y value of the vector
  3912. * @param z z value of the vector
  3913. * @param w w value of the vector
  3914. */
  3915. constructor(
  3916. /** x value of the vector */
  3917. x: number,
  3918. /** y value of the vector */
  3919. y: number,
  3920. /** z value of the vector */
  3921. z: number,
  3922. /** w value of the vector */
  3923. w: number);
  3924. /**
  3925. * Returns the string with the Vector4 coordinates.
  3926. * @returns a string containing all the vector values
  3927. */
  3928. toString(): string;
  3929. /**
  3930. * Returns the string "Vector4".
  3931. * @returns "Vector4"
  3932. */
  3933. getClassName(): string;
  3934. /**
  3935. * Returns the Vector4 hash code.
  3936. * @returns a unique hash code
  3937. */
  3938. getHashCode(): number;
  3939. /**
  3940. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3941. * @returns the resulting array
  3942. */
  3943. asArray(): number[];
  3944. /**
  3945. * Populates the given array from the given index with the Vector4 coordinates.
  3946. * @param array array to populate
  3947. * @param index index of the array to start at (default: 0)
  3948. * @returns the Vector4.
  3949. */
  3950. toArray(array: FloatArray, index?: number): Vector4;
  3951. /**
  3952. * Update the current vector from an array
  3953. * @param array defines the destination array
  3954. * @param index defines the offset in the destination array
  3955. * @returns the current Vector3
  3956. */
  3957. fromArray(array: FloatArray, index?: number): Vector4;
  3958. /**
  3959. * Adds the given vector to the current Vector4.
  3960. * @param otherVector the vector to add
  3961. * @returns the updated Vector4.
  3962. */
  3963. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3964. /**
  3965. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3966. * @param otherVector the vector to add
  3967. * @returns the resulting vector
  3968. */
  3969. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3970. /**
  3971. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3972. * @param otherVector the vector to add
  3973. * @param result the vector to store the result
  3974. * @returns the current Vector4.
  3975. */
  3976. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3977. /**
  3978. * Subtract in place the given vector from the current Vector4.
  3979. * @param otherVector the vector to subtract
  3980. * @returns the updated Vector4.
  3981. */
  3982. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3983. /**
  3984. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3985. * @param otherVector the vector to add
  3986. * @returns the new vector with the result
  3987. */
  3988. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3989. /**
  3990. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3991. * @param otherVector the vector to subtract
  3992. * @param result the vector to store the result
  3993. * @returns the current Vector4.
  3994. */
  3995. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3996. /**
  3997. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3998. */
  3999. /**
  4000. * Returns a new Vector4 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. * @returns new vector containing the result
  4006. */
  4007. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4008. /**
  4009. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4010. * @param x value to subtract
  4011. * @param y value to subtract
  4012. * @param z value to subtract
  4013. * @param w value to subtract
  4014. * @param result the vector to store the result in
  4015. * @returns the current Vector4.
  4016. */
  4017. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4018. /**
  4019. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4020. * @returns a new vector with the negated values
  4021. */
  4022. negate(): Vector4;
  4023. /**
  4024. * Negate this vector in place
  4025. * @returns this
  4026. */
  4027. negateInPlace(): Vector4;
  4028. /**
  4029. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4030. * @param result defines the Vector3 object where to store the result
  4031. * @returns the current Vector4
  4032. */
  4033. negateToRef(result: Vector4): Vector4;
  4034. /**
  4035. * Multiplies the current Vector4 coordinates by scale (float).
  4036. * @param scale the number to scale with
  4037. * @returns the updated Vector4.
  4038. */
  4039. scaleInPlace(scale: number): Vector4;
  4040. /**
  4041. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4042. * @param scale the number to scale with
  4043. * @returns a new vector with the result
  4044. */
  4045. scale(scale: number): Vector4;
  4046. /**
  4047. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4048. * @param scale the number to scale with
  4049. * @param result a vector to store the result in
  4050. * @returns the current Vector4.
  4051. */
  4052. scaleToRef(scale: number, result: Vector4): Vector4;
  4053. /**
  4054. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4055. * @param scale defines the scale factor
  4056. * @param result defines the Vector4 object where to store the result
  4057. * @returns the unmodified current Vector4
  4058. */
  4059. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4060. /**
  4061. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4062. * @param otherVector the vector to compare against
  4063. * @returns true if they are equal
  4064. */
  4065. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4066. /**
  4067. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4068. * @param otherVector vector to compare against
  4069. * @param epsilon (Default: very small number)
  4070. * @returns true if they are equal
  4071. */
  4072. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4073. /**
  4074. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4075. * @param x x value to compare against
  4076. * @param y y value to compare against
  4077. * @param z z value to compare against
  4078. * @param w w value to compare against
  4079. * @returns true if equal
  4080. */
  4081. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4082. /**
  4083. * Multiplies in place the current Vector4 by the given one.
  4084. * @param otherVector vector to multiple with
  4085. * @returns the updated Vector4.
  4086. */
  4087. multiplyInPlace(otherVector: Vector4): Vector4;
  4088. /**
  4089. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4090. * @param otherVector vector to multiple with
  4091. * @returns resulting new vector
  4092. */
  4093. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4094. /**
  4095. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4096. * @param otherVector vector to multiple with
  4097. * @param result vector to store the result
  4098. * @returns the current Vector4.
  4099. */
  4100. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4103. * @param x x value multiply with
  4104. * @param y y value multiply with
  4105. * @param z z value multiply with
  4106. * @param w w value multiply with
  4107. * @returns resulting new vector
  4108. */
  4109. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4110. /**
  4111. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4112. * @param otherVector vector to devide with
  4113. * @returns resulting new vector
  4114. */
  4115. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4116. /**
  4117. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4118. * @param otherVector vector to devide with
  4119. * @param result vector to store the result
  4120. * @returns the current Vector4.
  4121. */
  4122. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4123. /**
  4124. * Divides the current Vector3 coordinates by the given ones.
  4125. * @param otherVector vector to devide with
  4126. * @returns the updated Vector3.
  4127. */
  4128. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4129. /**
  4130. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4131. * @param other defines the second operand
  4132. * @returns the current updated Vector4
  4133. */
  4134. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4135. /**
  4136. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4137. * @param other defines the second operand
  4138. * @returns the current updated Vector4
  4139. */
  4140. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4141. /**
  4142. * Gets a new Vector4 from current Vector4 floored values
  4143. * @returns a new Vector4
  4144. */
  4145. floor(): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector3 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. fract(): Vector4;
  4151. /**
  4152. * Returns the Vector4 length (float).
  4153. * @returns the length
  4154. */
  4155. length(): number;
  4156. /**
  4157. * Returns the Vector4 squared length (float).
  4158. * @returns the length squared
  4159. */
  4160. lengthSquared(): number;
  4161. /**
  4162. * Normalizes in place the Vector4.
  4163. * @returns the updated Vector4.
  4164. */
  4165. normalize(): Vector4;
  4166. /**
  4167. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4168. * @returns this converted to a new vector3
  4169. */
  4170. toVector3(): Vector3;
  4171. /**
  4172. * Returns a new Vector4 copied from the current one.
  4173. * @returns the new cloned vector
  4174. */
  4175. clone(): Vector4;
  4176. /**
  4177. * Updates the current Vector4 with the given one coordinates.
  4178. * @param source the source vector to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to copy from
  4185. * @param y float to copy from
  4186. * @param z float to copy from
  4187. * @param w float to copy from
  4188. * @returns the updated Vector4.
  4189. */
  4190. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Updates the current Vector4 coordinates with the given floats.
  4193. * @param x float to set from
  4194. * @param y float to set from
  4195. * @param z float to set from
  4196. * @param w float to set from
  4197. * @returns the updated Vector4.
  4198. */
  4199. set(x: number, y: number, z: number, w: number): Vector4;
  4200. /**
  4201. * Copies the given float to the current Vector3 coordinates
  4202. * @param v defines the x, y, z and w coordinates of the operand
  4203. * @returns the current updated Vector3
  4204. */
  4205. setAll(v: number): Vector4;
  4206. /**
  4207. * Returns a new Vector4 set from the starting index of the given array.
  4208. * @param array the array to pull values from
  4209. * @param offset the offset into the array to start at
  4210. * @returns the new vector
  4211. */
  4212. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4213. /**
  4214. * Updates the given vector "result" from the starting index of the given array.
  4215. * @param array the array to pull values from
  4216. * @param offset the offset into the array to start at
  4217. * @param result the vector to store the result in
  4218. */
  4219. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4220. /**
  4221. * Updates the given vector "result" from the starting index of the given Float32Array.
  4222. * @param array the array to pull values from
  4223. * @param offset the offset into the array to start at
  4224. * @param result the vector to store the result in
  4225. */
  4226. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4227. /**
  4228. * Updates the given vector "result" coordinates from the given floats.
  4229. * @param x float to set from
  4230. * @param y float to set from
  4231. * @param z float to set from
  4232. * @param w float to set from
  4233. * @param result the vector to the floats in
  4234. */
  4235. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4236. /**
  4237. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4238. * @returns the new vector
  4239. */
  4240. static Zero(): Vector4;
  4241. /**
  4242. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4243. * @returns the new vector
  4244. */
  4245. static One(): Vector4;
  4246. /**
  4247. * Returns a new normalized Vector4 from the given one.
  4248. * @param vector the vector to normalize
  4249. * @returns the vector
  4250. */
  4251. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4252. /**
  4253. * Updates the given vector "result" from the normalization of the given one.
  4254. * @param vector the vector to normalize
  4255. * @param result the vector to store the result in
  4256. */
  4257. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4258. /**
  4259. * Returns a vector with the minimum values from the left and right vectors
  4260. * @param left left vector to minimize
  4261. * @param right right vector to minimize
  4262. * @returns a new vector with the minimum of the left and right vector values
  4263. */
  4264. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4265. /**
  4266. * Returns a vector with the maximum values from the left and right vectors
  4267. * @param left left vector to maximize
  4268. * @param right right vector to maximize
  4269. * @returns a new vector with the maximum of the left and right vector values
  4270. */
  4271. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4272. /**
  4273. * Returns the distance (float) between the vectors "value1" and "value2".
  4274. * @param value1 value to calulate the distance between
  4275. * @param value2 value to calulate the distance between
  4276. * @return the distance between the two vectors
  4277. */
  4278. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4279. /**
  4280. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4281. * @param value1 value to calulate the distance between
  4282. * @param value2 value to calulate the distance between
  4283. * @return the distance between the two vectors squared
  4284. */
  4285. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4286. /**
  4287. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4288. * @param value1 value to calulate the center between
  4289. * @param value2 value to calulate the center between
  4290. * @return the center between the two vectors
  4291. */
  4292. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4293. /**
  4294. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4295. * @param value1 defines first vector
  4296. * @param value2 defines second vector
  4297. * @param ref defines third vector
  4298. * @returns ref
  4299. */
  4300. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4301. /**
  4302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4303. * This methods computes transformed normalized direction vectors only.
  4304. * @param vector the vector to transform
  4305. * @param transformation the transformation matrix to apply
  4306. * @returns the new vector
  4307. */
  4308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4309. /**
  4310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4311. * This methods computes transformed normalized direction vectors only.
  4312. * @param vector the vector to transform
  4313. * @param transformation the transformation matrix to apply
  4314. * @param result the vector to store the result in
  4315. */
  4316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4317. /**
  4318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4319. * This methods computes transformed normalized direction vectors only.
  4320. * @param x value to transform
  4321. * @param y value to transform
  4322. * @param z value to transform
  4323. * @param w value to transform
  4324. * @param transformation the transformation matrix to apply
  4325. * @param result the vector to store the results in
  4326. */
  4327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4328. /**
  4329. * Creates a new Vector4 from a Vector3
  4330. * @param source defines the source data
  4331. * @param w defines the 4th component (default is 0)
  4332. * @returns a new Vector4
  4333. */
  4334. static FromVector3(source: Vector3, w?: number): Vector4;
  4335. }
  4336. /**
  4337. * Class used to store quaternion data
  4338. * @see https://en.wikipedia.org/wiki/Quaternion
  4339. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4340. */
  4341. export class Quaternion {
  4342. /** @hidden */
  4343. _x: number;
  4344. /** @hidden */
  4345. _y: number;
  4346. /** @hidden */
  4347. _z: number;
  4348. /** @hidden */
  4349. _w: number;
  4350. /** @hidden */
  4351. _isDirty: boolean;
  4352. /** Gets or sets the x coordinate */
  4353. get x(): number;
  4354. set x(value: number);
  4355. /** Gets or sets the y coordinate */
  4356. get y(): number;
  4357. set y(value: number);
  4358. /** Gets or sets the z coordinate */
  4359. get z(): number;
  4360. set z(value: number);
  4361. /** Gets or sets the w coordinate */
  4362. get w(): number;
  4363. set w(value: number);
  4364. /**
  4365. * Creates a new Quaternion from the given floats
  4366. * @param x defines the first component (0 by default)
  4367. * @param y defines the second component (0 by default)
  4368. * @param z defines the third component (0 by default)
  4369. * @param w defines the fourth component (1.0 by default)
  4370. */
  4371. constructor(x?: number, y?: number, z?: number, w?: number);
  4372. /**
  4373. * Gets a string representation for the current quaternion
  4374. * @returns a string with the Quaternion coordinates
  4375. */
  4376. toString(): string;
  4377. /**
  4378. * Gets the class name of the quaternion
  4379. * @returns the string "Quaternion"
  4380. */
  4381. getClassName(): string;
  4382. /**
  4383. * Gets a hash code for this quaternion
  4384. * @returns the quaternion hash code
  4385. */
  4386. getHashCode(): number;
  4387. /**
  4388. * Copy the quaternion to an array
  4389. * @returns a new array populated with 4 elements from the quaternion coordinates
  4390. */
  4391. asArray(): number[];
  4392. /**
  4393. * Check if two quaternions are equals
  4394. * @param otherQuaternion defines the second operand
  4395. * @return true if the current quaternion and the given one coordinates are strictly equals
  4396. */
  4397. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4398. /**
  4399. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4400. * @param otherQuaternion defines the other quaternion
  4401. * @param epsilon defines the minimal distance to consider equality
  4402. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4403. */
  4404. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4405. /**
  4406. * Clone the current quaternion
  4407. * @returns a new quaternion copied from the current one
  4408. */
  4409. clone(): Quaternion;
  4410. /**
  4411. * Copy a quaternion to the current one
  4412. * @param other defines the other quaternion
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4416. /**
  4417. * Updates the current quaternion with 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. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Updates the current quaternion from the given float coordinates
  4427. * @param x defines the x coordinate
  4428. * @param y defines the y coordinate
  4429. * @param z defines the z coordinate
  4430. * @param w defines the w coordinate
  4431. * @returns the updated current quaternion
  4432. */
  4433. set(x: number, y: number, z: number, w: number): Quaternion;
  4434. /**
  4435. * Adds two quaternions
  4436. * @param other defines the second operand
  4437. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4438. */
  4439. add(other: DeepImmutable<Quaternion>): Quaternion;
  4440. /**
  4441. * Add a quaternion to the current one
  4442. * @param other defines the quaternion to add
  4443. * @returns the current quaternion
  4444. */
  4445. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4446. /**
  4447. * Subtract two quaternions
  4448. * @param other defines the second operand
  4449. * @returns a new quaternion as the subtraction result of the given one from the current one
  4450. */
  4451. subtract(other: Quaternion): Quaternion;
  4452. /**
  4453. * Multiplies the current quaternion by a scale factor
  4454. * @param value defines the scale factor
  4455. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4456. */
  4457. scale(value: number): Quaternion;
  4458. /**
  4459. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4460. * @param scale defines the scale factor
  4461. * @param result defines the Quaternion object where to store the result
  4462. * @returns the unmodified current quaternion
  4463. */
  4464. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4465. /**
  4466. * Multiplies in place the current quaternion by a scale factor
  4467. * @param value defines the scale factor
  4468. * @returns the current modified quaternion
  4469. */
  4470. scaleInPlace(value: number): Quaternion;
  4471. /**
  4472. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4473. * @param scale defines the scale factor
  4474. * @param result defines the Quaternion object where to store the result
  4475. * @returns the unmodified current quaternion
  4476. */
  4477. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4478. /**
  4479. * Multiplies two quaternions
  4480. * @param q1 defines the second operand
  4481. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4482. */
  4483. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4484. /**
  4485. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4486. * @param q1 defines the second operand
  4487. * @param result defines the target quaternion
  4488. * @returns the current quaternion
  4489. */
  4490. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4491. /**
  4492. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4493. * @param q1 defines the second operand
  4494. * @returns the currentupdated quaternion
  4495. */
  4496. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4497. /**
  4498. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4499. * @param ref defines the target quaternion
  4500. * @returns the current quaternion
  4501. */
  4502. conjugateToRef(ref: Quaternion): Quaternion;
  4503. /**
  4504. * Conjugates in place (1-q) the current quaternion
  4505. * @returns the current updated quaternion
  4506. */
  4507. conjugateInPlace(): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns a new quaternion
  4511. */
  4512. conjugate(): Quaternion;
  4513. /**
  4514. * Gets length of current quaternion
  4515. * @returns the quaternion length (float)
  4516. */
  4517. length(): number;
  4518. /**
  4519. * Normalize in place the current quaternion
  4520. * @returns the current updated quaternion
  4521. */
  4522. normalize(): Quaternion;
  4523. /**
  4524. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4525. * @param order is a reserved parameter and is ignored for now
  4526. * @returns a new Vector3 containing the Euler angles
  4527. */
  4528. toEulerAngles(order?: string): Vector3;
  4529. /**
  4530. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4531. * @param result defines the vector which will be filled with the Euler angles
  4532. * @returns the current unchanged quaternion
  4533. */
  4534. toEulerAnglesToRef(result: Vector3): Quaternion;
  4535. /**
  4536. * Updates the given rotation matrix with the current quaternion values
  4537. * @param result defines the target matrix
  4538. * @returns the current unchanged quaternion
  4539. */
  4540. toRotationMatrix(result: Matrix): Quaternion;
  4541. /**
  4542. * Updates the current quaternion from the given rotation matrix values
  4543. * @param matrix defines the source matrix
  4544. * @returns the current updated quaternion
  4545. */
  4546. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4547. /**
  4548. * Creates a new quaternion from a rotation matrix
  4549. * @param matrix defines the source matrix
  4550. * @returns a new quaternion created from the given rotation matrix values
  4551. */
  4552. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4553. /**
  4554. * Updates the given quaternion with the given rotation matrix values
  4555. * @param matrix defines the source matrix
  4556. * @param result defines the target quaternion
  4557. */
  4558. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4559. /**
  4560. * Returns the dot product (float) between the quaternions "left" and "right"
  4561. * @param left defines the left operand
  4562. * @param right defines the right operand
  4563. * @returns the dot product
  4564. */
  4565. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4566. /**
  4567. * Checks if the two quaternions are close to each other
  4568. * @param quat0 defines the first quaternion to check
  4569. * @param quat1 defines the second quaternion to check
  4570. * @returns true if the two quaternions are close to each other
  4571. */
  4572. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4573. /**
  4574. * Creates an empty quaternion
  4575. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4576. */
  4577. static Zero(): Quaternion;
  4578. /**
  4579. * Inverse a given quaternion
  4580. * @param q defines the source quaternion
  4581. * @returns a new quaternion as the inverted current quaternion
  4582. */
  4583. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4584. /**
  4585. * Inverse a given quaternion
  4586. * @param q defines the source quaternion
  4587. * @param result the quaternion the result will be stored in
  4588. * @returns the result quaternion
  4589. */
  4590. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4591. /**
  4592. * Creates an identity quaternion
  4593. * @returns the identity quaternion
  4594. */
  4595. static Identity(): Quaternion;
  4596. /**
  4597. * Gets a boolean indicating if the given quaternion is identity
  4598. * @param quaternion defines the quaternion to check
  4599. * @returns true if the quaternion is identity
  4600. */
  4601. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4602. /**
  4603. * Creates a quaternion from a rotation around an axis
  4604. * @param axis defines the axis to use
  4605. * @param angle defines the angle to use
  4606. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4607. */
  4608. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4609. /**
  4610. * Creates a rotation around an axis and stores it into the given quaternion
  4611. * @param axis defines the axis to use
  4612. * @param angle defines the angle to use
  4613. * @param result defines the target quaternion
  4614. * @returns the target quaternion
  4615. */
  4616. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4617. /**
  4618. * Creates a new quaternion from data stored into an array
  4619. * @param array defines the data source
  4620. * @param offset defines the offset in the source array where the data starts
  4621. * @returns a new quaternion
  4622. */
  4623. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4624. /**
  4625. * Updates the given quaternion "result" from the starting index of the given array.
  4626. * @param array the array to pull values from
  4627. * @param offset the offset into the array to start at
  4628. * @param result the quaternion to store the result in
  4629. */
  4630. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4631. /**
  4632. * Create a quaternion from Euler rotation angles
  4633. * @param x Pitch
  4634. * @param y Yaw
  4635. * @param z Roll
  4636. * @returns the new Quaternion
  4637. */
  4638. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4639. /**
  4640. * Updates a quaternion from Euler rotation angles
  4641. * @param x Pitch
  4642. * @param y Yaw
  4643. * @param z Roll
  4644. * @param result the quaternion to store the result
  4645. * @returns the updated quaternion
  4646. */
  4647. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4648. /**
  4649. * Create a quaternion from Euler rotation vector
  4650. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4651. * @returns the new Quaternion
  4652. */
  4653. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4654. /**
  4655. * Updates a quaternion from Euler rotation vector
  4656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4657. * @param result the quaternion to store the result
  4658. * @returns the updated quaternion
  4659. */
  4660. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4661. /**
  4662. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4663. * @param vecFrom defines the direction vector from which to rotate
  4664. * @param vecTo defines the direction vector to which to rotate
  4665. * @param result the quaternion to store the result
  4666. * @returns the updated quaternion
  4667. */
  4668. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4669. /**
  4670. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4671. * @param yaw defines the rotation around Y axis
  4672. * @param pitch defines the rotation around X axis
  4673. * @param roll defines the rotation around Z axis
  4674. * @returns the new quaternion
  4675. */
  4676. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4677. /**
  4678. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4679. * @param yaw defines the rotation around Y axis
  4680. * @param pitch defines the rotation around X axis
  4681. * @param roll defines the rotation around Z axis
  4682. * @param result defines the target quaternion
  4683. */
  4684. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4685. /**
  4686. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4687. * @param alpha defines the rotation around first axis
  4688. * @param beta defines the rotation around second axis
  4689. * @param gamma defines the rotation around third axis
  4690. * @returns the new quaternion
  4691. */
  4692. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4693. /**
  4694. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4695. * @param alpha defines the rotation around first axis
  4696. * @param beta defines the rotation around second axis
  4697. * @param gamma defines the rotation around third axis
  4698. * @param result defines the target quaternion
  4699. */
  4700. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4701. /**
  4702. * 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)
  4703. * @param axis1 defines the first axis
  4704. * @param axis2 defines the second axis
  4705. * @param axis3 defines the third axis
  4706. * @returns the new quaternion
  4707. */
  4708. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4709. /**
  4710. * 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
  4711. * @param axis1 defines the first axis
  4712. * @param axis2 defines the second axis
  4713. * @param axis3 defines the third axis
  4714. * @param ref defines the target quaternion
  4715. */
  4716. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4717. /**
  4718. * Interpolates between two quaternions
  4719. * @param left defines first quaternion
  4720. * @param right defines second quaternion
  4721. * @param amount defines the gradient to use
  4722. * @returns the new interpolated quaternion
  4723. */
  4724. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4725. /**
  4726. * Interpolates between two quaternions and stores it into a target quaternion
  4727. * @param left defines first quaternion
  4728. * @param right defines second quaternion
  4729. * @param amount defines the gradient to use
  4730. * @param result defines the target quaternion
  4731. */
  4732. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4733. /**
  4734. * Interpolate between two quaternions using Hermite interpolation
  4735. * @param value1 defines first quaternion
  4736. * @param tangent1 defines the incoming tangent
  4737. * @param value2 defines second quaternion
  4738. * @param tangent2 defines the outgoing tangent
  4739. * @param amount defines the target quaternion
  4740. * @returns the new interpolated quaternion
  4741. */
  4742. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4743. }
  4744. /**
  4745. * Class used to store matrix data (4x4)
  4746. */
  4747. export class Matrix {
  4748. /**
  4749. * Gets the precision of matrix computations
  4750. */
  4751. static get Use64Bits(): boolean;
  4752. private static _updateFlagSeed;
  4753. private static _identityReadOnly;
  4754. private _isIdentity;
  4755. private _isIdentityDirty;
  4756. private _isIdentity3x2;
  4757. private _isIdentity3x2Dirty;
  4758. /**
  4759. * Gets the update flag of the matrix which is an unique number for the matrix.
  4760. * It will be incremented every time the matrix data change.
  4761. * You can use it to speed the comparison between two versions of the same matrix.
  4762. */
  4763. updateFlag: number;
  4764. private readonly _m;
  4765. /**
  4766. * Gets the internal data of the matrix
  4767. */
  4768. get m(): DeepImmutable<Float32Array | Array<number>>;
  4769. /** @hidden */
  4770. _markAsUpdated(): void;
  4771. /** @hidden */
  4772. private _updateIdentityStatus;
  4773. /**
  4774. * Creates an empty matrix (filled with zeros)
  4775. */
  4776. constructor();
  4777. /**
  4778. * Check if the current matrix is identity
  4779. * @returns true is the matrix is the identity matrix
  4780. */
  4781. isIdentity(): boolean;
  4782. /**
  4783. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentityAs3x2(): boolean;
  4787. /**
  4788. * Gets the determinant of the matrix
  4789. * @returns the matrix determinant
  4790. */
  4791. determinant(): number;
  4792. /**
  4793. * Returns the matrix as a Float32Array or Array<number>
  4794. * @returns the matrix underlying array
  4795. */
  4796. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array.
  4800. */
  4801. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Inverts the current matrix in place
  4804. * @returns the current inverted matrix
  4805. */
  4806. invert(): Matrix;
  4807. /**
  4808. * Sets all the matrix elements to zero
  4809. * @returns the current matrix
  4810. */
  4811. reset(): Matrix;
  4812. /**
  4813. * Adds the current matrix with a second one
  4814. * @param other defines the matrix to add
  4815. * @returns a new matrix as the addition of the current matrix and the given one
  4816. */
  4817. add(other: DeepImmutable<Matrix>): Matrix;
  4818. /**
  4819. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4820. * @param other defines the matrix to add
  4821. * @param result defines the target matrix
  4822. * @returns the current matrix
  4823. */
  4824. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4825. /**
  4826. * Adds in place the given matrix to the current matrix
  4827. * @param other defines the second operand
  4828. * @returns the current updated matrix
  4829. */
  4830. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4831. /**
  4832. * Sets the given matrix to the current inverted Matrix
  4833. * @param other defines the target matrix
  4834. * @returns the unmodified current matrix
  4835. */
  4836. invertToRef(other: Matrix): Matrix;
  4837. /**
  4838. * add a value at the specified position in the current Matrix
  4839. * @param index the index of the value within the matrix. between 0 and 15.
  4840. * @param value the value to be added
  4841. * @returns the current updated matrix
  4842. */
  4843. addAtIndex(index: number, value: number): Matrix;
  4844. /**
  4845. * mutiply the specified position in the current Matrix by a value
  4846. * @param index the index of the value within the matrix. between 0 and 15.
  4847. * @param value the value to be added
  4848. * @returns the current updated matrix
  4849. */
  4850. multiplyAtIndex(index: number, value: number): Matrix;
  4851. /**
  4852. * Inserts the translation vector (using 3 floats) in the current matrix
  4853. * @param x defines the 1st component of the translation
  4854. * @param y defines the 2nd component of the translation
  4855. * @param z defines the 3rd component of the translation
  4856. * @returns the current updated matrix
  4857. */
  4858. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4859. /**
  4860. * Adds the translation vector (using 3 floats) in the current matrix
  4861. * @param x defines the 1st component of the translation
  4862. * @param y defines the 2nd component of the translation
  4863. * @param z defines the 3rd component of the translation
  4864. * @returns the current updated matrix
  4865. */
  4866. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4867. /**
  4868. * Inserts the translation vector in the current matrix
  4869. * @param vector3 defines the translation to insert
  4870. * @returns the current updated matrix
  4871. */
  4872. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4873. /**
  4874. * Gets the translation value of the current matrix
  4875. * @returns a new Vector3 as the extracted translation from the matrix
  4876. */
  4877. getTranslation(): Vector3;
  4878. /**
  4879. * Fill a Vector3 with the extracted translation from the matrix
  4880. * @param result defines the Vector3 where to store the translation
  4881. * @returns the current matrix
  4882. */
  4883. getTranslationToRef(result: Vector3): Matrix;
  4884. /**
  4885. * Remove rotation and scaling part from the matrix
  4886. * @returns the updated matrix
  4887. */
  4888. removeRotationAndScaling(): Matrix;
  4889. /**
  4890. * Multiply two matrices
  4891. * @param other defines the second operand
  4892. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4893. */
  4894. multiply(other: DeepImmutable<Matrix>): Matrix;
  4895. /**
  4896. * Copy the current matrix from the given one
  4897. * @param other defines the source matrix
  4898. * @returns the current updated matrix
  4899. */
  4900. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4901. /**
  4902. * Populates the given array from the starting index with the current matrix values
  4903. * @param array defines the target array
  4904. * @param offset defines the offset in the target array where to start storing values
  4905. * @returns the current matrix
  4906. */
  4907. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4908. /**
  4909. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4910. * @param other defines the second operand
  4911. * @param result defines the matrix where to store the multiplication
  4912. * @returns the current matrix
  4913. */
  4914. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4915. /**
  4916. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4917. * @param other defines the second operand
  4918. * @param result defines the array where to store the multiplication
  4919. * @param offset defines the offset in the target array where to start storing values
  4920. * @returns the current matrix
  4921. */
  4922. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4923. /**
  4924. * Check equality between this matrix and a second one
  4925. * @param value defines the second matrix to compare
  4926. * @returns true is the current matrix and the given one values are strictly equal
  4927. */
  4928. equals(value: DeepImmutable<Matrix>): boolean;
  4929. /**
  4930. * Clone the current matrix
  4931. * @returns a new matrix from the current matrix
  4932. */
  4933. clone(): Matrix;
  4934. /**
  4935. * Returns the name of the current matrix class
  4936. * @returns the string "Matrix"
  4937. */
  4938. getClassName(): string;
  4939. /**
  4940. * Gets the hash code of the current matrix
  4941. * @returns the hash code
  4942. */
  4943. getHashCode(): number;
  4944. /**
  4945. * Decomposes the current Matrix into a translation, rotation and scaling components
  4946. * @param scale defines the scale vector3 given as a reference to update
  4947. * @param rotation defines the rotation quaternion given as a reference to update
  4948. * @param translation defines the translation vector3 given as a reference to update
  4949. * @returns true if operation was successful
  4950. */
  4951. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4952. /**
  4953. * Gets specific row of the matrix
  4954. * @param index defines the number of the row to get
  4955. * @returns the index-th row of the current matrix as a new Vector4
  4956. */
  4957. getRow(index: number): Nullable<Vector4>;
  4958. /**
  4959. * Sets the index-th row of the current matrix to the vector4 values
  4960. * @param index defines the number of the row to set
  4961. * @param row defines the target vector4
  4962. * @returns the updated current matrix
  4963. */
  4964. setRow(index: number, row: Vector4): Matrix;
  4965. /**
  4966. * Compute the transpose of the matrix
  4967. * @returns the new transposed matrix
  4968. */
  4969. transpose(): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix and store it in a given matrix
  4972. * @param result defines the target matrix
  4973. * @returns the current matrix
  4974. */
  4975. transposeToRef(result: Matrix): Matrix;
  4976. /**
  4977. * Sets the index-th row of the current matrix with the given 4 x float values
  4978. * @param index defines the row index
  4979. * @param x defines the x component to set
  4980. * @param y defines the y component to set
  4981. * @param z defines the z component to set
  4982. * @param w defines the w component to set
  4983. * @returns the updated current matrix
  4984. */
  4985. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4986. /**
  4987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4988. * @param scale defines the scale factor
  4989. * @returns a new matrix
  4990. */
  4991. scale(scale: number): Matrix;
  4992. /**
  4993. * Scale the current matrix values by a factor to a given result matrix
  4994. * @param scale defines the scale factor
  4995. * @param result defines the matrix to store the result
  4996. * @returns the current matrix
  4997. */
  4998. scaleToRef(scale: number, result: Matrix): Matrix;
  4999. /**
  5000. * Scale the current matrix values by a factor and add the result to a given matrix
  5001. * @param scale defines the scale factor
  5002. * @param result defines the Matrix to store the result
  5003. * @returns the current matrix
  5004. */
  5005. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5006. /**
  5007. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5008. * @param ref matrix to store the result
  5009. */
  5010. toNormalMatrix(ref: Matrix): void;
  5011. /**
  5012. * Gets only rotation part of the current matrix
  5013. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5014. */
  5015. getRotationMatrix(): Matrix;
  5016. /**
  5017. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5018. * @param result defines the target matrix to store data to
  5019. * @returns the current matrix
  5020. */
  5021. getRotationMatrixToRef(result: Matrix): Matrix;
  5022. /**
  5023. * Toggles model matrix from being right handed to left handed in place and vice versa
  5024. */
  5025. toggleModelMatrixHandInPlace(): void;
  5026. /**
  5027. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5028. */
  5029. toggleProjectionMatrixHandInPlace(): void;
  5030. /**
  5031. * Creates a matrix from an array
  5032. * @param array defines the source array
  5033. * @param offset defines an offset in the source array
  5034. * @returns a new Matrix set from the starting index of the given array
  5035. */
  5036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5037. /**
  5038. * Copy the content of an array into a given matrix
  5039. * @param array defines the source array
  5040. * @param offset defines an offset in the source array
  5041. * @param result defines the target matrix
  5042. */
  5043. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5044. /**
  5045. * Stores an array into a matrix after having multiplied each component by a given factor
  5046. * @param array defines the source array
  5047. * @param offset defines the offset in the source array
  5048. * @param scale defines the scaling factor
  5049. * @param result defines the target matrix
  5050. */
  5051. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5052. /**
  5053. * Gets an identity matrix that must not be updated
  5054. */
  5055. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5056. /**
  5057. * Stores a list of values (16) inside a given matrix
  5058. * @param initialM11 defines 1st value of 1st row
  5059. * @param initialM12 defines 2nd value of 1st row
  5060. * @param initialM13 defines 3rd value of 1st row
  5061. * @param initialM14 defines 4th value of 1st row
  5062. * @param initialM21 defines 1st value of 2nd row
  5063. * @param initialM22 defines 2nd value of 2nd row
  5064. * @param initialM23 defines 3rd value of 2nd row
  5065. * @param initialM24 defines 4th value of 2nd row
  5066. * @param initialM31 defines 1st value of 3rd row
  5067. * @param initialM32 defines 2nd value of 3rd row
  5068. * @param initialM33 defines 3rd value of 3rd row
  5069. * @param initialM34 defines 4th value of 3rd row
  5070. * @param initialM41 defines 1st value of 4th row
  5071. * @param initialM42 defines 2nd value of 4th row
  5072. * @param initialM43 defines 3rd value of 4th row
  5073. * @param initialM44 defines 4th value of 4th row
  5074. * @param result defines the target matrix
  5075. */
  5076. 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;
  5077. /**
  5078. * Creates new matrix from a list of values (16)
  5079. * @param initialM11 defines 1st value of 1st row
  5080. * @param initialM12 defines 2nd value of 1st row
  5081. * @param initialM13 defines 3rd value of 1st row
  5082. * @param initialM14 defines 4th value of 1st row
  5083. * @param initialM21 defines 1st value of 2nd row
  5084. * @param initialM22 defines 2nd value of 2nd row
  5085. * @param initialM23 defines 3rd value of 2nd row
  5086. * @param initialM24 defines 4th value of 2nd row
  5087. * @param initialM31 defines 1st value of 3rd row
  5088. * @param initialM32 defines 2nd value of 3rd row
  5089. * @param initialM33 defines 3rd value of 3rd row
  5090. * @param initialM34 defines 4th value of 3rd row
  5091. * @param initialM41 defines 1st value of 4th row
  5092. * @param initialM42 defines 2nd value of 4th row
  5093. * @param initialM43 defines 3rd value of 4th row
  5094. * @param initialM44 defines 4th value of 4th row
  5095. * @returns the new matrix
  5096. */
  5097. 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;
  5098. /**
  5099. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5100. * @param scale defines the scale vector3
  5101. * @param rotation defines the rotation quaternion
  5102. * @param translation defines the translation vector3
  5103. * @returns a new matrix
  5104. */
  5105. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5106. /**
  5107. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5108. * @param scale defines the scale vector3
  5109. * @param rotation defines the rotation quaternion
  5110. * @param translation defines the translation vector3
  5111. * @param result defines the target matrix
  5112. */
  5113. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5114. /**
  5115. * Creates a new identity matrix
  5116. * @returns a new identity matrix
  5117. */
  5118. static Identity(): Matrix;
  5119. /**
  5120. * Creates a new identity matrix and stores the result in a given matrix
  5121. * @param result defines the target matrix
  5122. */
  5123. static IdentityToRef(result: Matrix): void;
  5124. /**
  5125. * Creates a new zero matrix
  5126. * @returns a new zero matrix
  5127. */
  5128. static Zero(): Matrix;
  5129. /**
  5130. * Creates a new rotation matrix for "angle" radians around the X axis
  5131. * @param angle defines the angle (in radians) to use
  5132. * @return the new matrix
  5133. */
  5134. static RotationX(angle: number): Matrix;
  5135. /**
  5136. * Creates a new matrix as the invert of a given matrix
  5137. * @param source defines the source matrix
  5138. * @returns the new matrix
  5139. */
  5140. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5141. /**
  5142. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5143. * @param angle defines the angle (in radians) to use
  5144. * @param result defines the target matrix
  5145. */
  5146. static RotationXToRef(angle: number, result: Matrix): void;
  5147. /**
  5148. * Creates a new rotation matrix for "angle" radians around the Y axis
  5149. * @param angle defines the angle (in radians) to use
  5150. * @return the new matrix
  5151. */
  5152. static RotationY(angle: number): Matrix;
  5153. /**
  5154. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5155. * @param angle defines the angle (in radians) to use
  5156. * @param result defines the target matrix
  5157. */
  5158. static RotationYToRef(angle: number, result: Matrix): void;
  5159. /**
  5160. * Creates a new rotation matrix for "angle" radians around the Z axis
  5161. * @param angle defines the angle (in radians) to use
  5162. * @return the new matrix
  5163. */
  5164. static RotationZ(angle: number): Matrix;
  5165. /**
  5166. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5167. * @param angle defines the angle (in radians) to use
  5168. * @param result defines the target matrix
  5169. */
  5170. static RotationZToRef(angle: number, result: Matrix): void;
  5171. /**
  5172. * Creates a new rotation matrix for "angle" radians around the given axis
  5173. * @param axis defines the axis to use
  5174. * @param angle defines the angle (in radians) to use
  5175. * @return the new matrix
  5176. */
  5177. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5178. /**
  5179. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5180. * @param axis defines the axis to use
  5181. * @param angle defines the angle (in radians) to use
  5182. * @param result defines the target matrix
  5183. */
  5184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5185. /**
  5186. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5187. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5188. * @param from defines the vector to align
  5189. * @param to defines the vector to align to
  5190. * @param result defines the target matrix
  5191. */
  5192. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5193. /**
  5194. * Creates a rotation matrix
  5195. * @param yaw defines the yaw angle in radians (Y axis)
  5196. * @param pitch defines the pitch angle in radians (X axis)
  5197. * @param roll defines the roll angle in radians (Z axis)
  5198. * @returns the new rotation matrix
  5199. */
  5200. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5201. /**
  5202. * Creates a rotation matrix and stores it in a given matrix
  5203. * @param yaw defines the yaw angle in radians (Y axis)
  5204. * @param pitch defines the pitch angle in radians (X axis)
  5205. * @param roll defines the roll angle in radians (Z axis)
  5206. * @param result defines the target matrix
  5207. */
  5208. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5209. /**
  5210. * Creates a scaling matrix
  5211. * @param x defines the scale factor on X axis
  5212. * @param y defines the scale factor on Y axis
  5213. * @param z defines the scale factor on Z axis
  5214. * @returns the new matrix
  5215. */
  5216. static Scaling(x: number, y: number, z: number): Matrix;
  5217. /**
  5218. * Creates a scaling matrix and stores it in a given matrix
  5219. * @param x defines the scale factor on X axis
  5220. * @param y defines the scale factor on Y axis
  5221. * @param z defines the scale factor on Z axis
  5222. * @param result defines the target matrix
  5223. */
  5224. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5225. /**
  5226. * Creates a translation matrix
  5227. * @param x defines the translation on X axis
  5228. * @param y defines the translation on Y axis
  5229. * @param z defines the translationon Z axis
  5230. * @returns the new matrix
  5231. */
  5232. static Translation(x: number, y: number, z: number): Matrix;
  5233. /**
  5234. * Creates a translation matrix and stores it in a given matrix
  5235. * @param x defines the translation on X axis
  5236. * @param y defines the translation on Y axis
  5237. * @param z defines the translationon Z axis
  5238. * @param result defines the target matrix
  5239. */
  5240. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5241. /**
  5242. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5243. * @param startValue defines the start value
  5244. * @param endValue defines the end value
  5245. * @param gradient defines the gradient factor
  5246. * @returns the new matrix
  5247. */
  5248. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5249. /**
  5250. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5251. * @param startValue defines the start value
  5252. * @param endValue defines the end value
  5253. * @param gradient defines the gradient factor
  5254. * @param result defines the Matrix object where to store data
  5255. */
  5256. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5257. /**
  5258. * Builds a new matrix whose values are computed by:
  5259. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5260. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5261. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5262. * @param startValue defines the first matrix
  5263. * @param endValue defines the second matrix
  5264. * @param gradient defines the gradient between the two matrices
  5265. * @returns the new matrix
  5266. */
  5267. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5268. /**
  5269. * Update a matrix to values which are computed by:
  5270. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5271. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5272. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5273. * @param startValue defines the first matrix
  5274. * @param endValue defines the second matrix
  5275. * @param gradient defines the gradient between the two matrices
  5276. * @param result defines the target matrix
  5277. */
  5278. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5279. /**
  5280. * 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"
  5281. * This function works in left handed mode
  5282. * @param eye defines the final position of the entity
  5283. * @param target defines where the entity should look at
  5284. * @param up defines the up vector for the entity
  5285. * @returns the new matrix
  5286. */
  5287. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5288. /**
  5289. * 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".
  5290. * This function works in left handed mode
  5291. * @param eye defines the final position of the entity
  5292. * @param target defines where the entity should look at
  5293. * @param up defines the up vector for the entity
  5294. * @param result defines the target matrix
  5295. */
  5296. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5297. /**
  5298. * 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"
  5299. * This function works in right handed mode
  5300. * @param eye defines the final position of the entity
  5301. * @param target defines where the entity should look at
  5302. * @param up defines the up vector for the entity
  5303. * @returns the new matrix
  5304. */
  5305. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5306. /**
  5307. * 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".
  5308. * This function works in right handed mode
  5309. * @param eye defines the final position of the entity
  5310. * @param target defines where the entity should look at
  5311. * @param up defines the up vector for the entity
  5312. * @param result defines the target matrix
  5313. */
  5314. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5315. /**
  5316. * Create a left-handed orthographic projection matrix
  5317. * @param width defines the viewport width
  5318. * @param height defines the viewport height
  5319. * @param znear defines the near clip plane
  5320. * @param zfar defines the far clip plane
  5321. * @returns a new matrix as a left-handed orthographic projection matrix
  5322. */
  5323. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5324. /**
  5325. * Store a left-handed orthographic projection to a given matrix
  5326. * @param width defines the viewport width
  5327. * @param height defines the viewport height
  5328. * @param znear defines the near clip plane
  5329. * @param zfar defines the far clip plane
  5330. * @param result defines the target matrix
  5331. */
  5332. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5333. /**
  5334. * Create a left-handed orthographic projection matrix
  5335. * @param left defines the viewport left coordinate
  5336. * @param right defines the viewport right coordinate
  5337. * @param bottom defines the viewport bottom coordinate
  5338. * @param top defines the viewport top coordinate
  5339. * @param znear defines the near clip plane
  5340. * @param zfar defines the far clip plane
  5341. * @returns a new matrix as a left-handed orthographic projection matrix
  5342. */
  5343. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5344. /**
  5345. * Stores a left-handed orthographic projection into a given matrix
  5346. * @param left defines the viewport left coordinate
  5347. * @param right defines the viewport right coordinate
  5348. * @param bottom defines the viewport bottom coordinate
  5349. * @param top defines the viewport top coordinate
  5350. * @param znear defines the near clip plane
  5351. * @param zfar defines the far clip plane
  5352. * @param result defines the target matrix
  5353. */
  5354. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5355. /**
  5356. * Creates a right-handed orthographic projection matrix
  5357. * @param left defines the viewport left coordinate
  5358. * @param right defines the viewport right coordinate
  5359. * @param bottom defines the viewport bottom coordinate
  5360. * @param top defines the viewport top coordinate
  5361. * @param znear defines the near clip plane
  5362. * @param zfar defines the far clip plane
  5363. * @returns a new matrix as a right-handed orthographic projection matrix
  5364. */
  5365. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5366. /**
  5367. * Stores a right-handed orthographic projection into a given matrix
  5368. * @param left defines the viewport left coordinate
  5369. * @param right defines the viewport right coordinate
  5370. * @param bottom defines the viewport bottom coordinate
  5371. * @param top defines the viewport top coordinate
  5372. * @param znear defines the near clip plane
  5373. * @param zfar defines the far clip plane
  5374. * @param result defines the target matrix
  5375. */
  5376. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5377. /**
  5378. * Creates a left-handed perspective projection matrix
  5379. * @param width defines the viewport width
  5380. * @param height defines the viewport height
  5381. * @param znear defines the near clip plane
  5382. * @param zfar defines the far clip plane
  5383. * @returns a new matrix as a left-handed perspective projection matrix
  5384. */
  5385. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5386. /**
  5387. * Creates a left-handed perspective projection matrix
  5388. * @param fov defines the horizontal field of view
  5389. * @param aspect defines the aspect ratio
  5390. * @param znear defines the near clip plane
  5391. * @param zfar defines the far clip plane
  5392. * @returns a new matrix as a left-handed perspective projection matrix
  5393. */
  5394. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5395. /**
  5396. * Stores a left-handed perspective projection into a given matrix
  5397. * @param fov defines the horizontal field of view
  5398. * @param aspect defines the aspect ratio
  5399. * @param znear defines the near clip plane
  5400. * @param zfar defines the far clip plane
  5401. * @param result defines the target matrix
  5402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5403. */
  5404. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5405. /**
  5406. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5407. * @param fov defines the horizontal field of view
  5408. * @param aspect defines the aspect ratio
  5409. * @param znear defines the near clip plane
  5410. * @param zfar not used as infinity is used as far clip
  5411. * @param result defines the target matrix
  5412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5413. */
  5414. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5415. /**
  5416. * Creates a right-handed perspective projection matrix
  5417. * @param fov defines the horizontal field of view
  5418. * @param aspect defines the aspect ratio
  5419. * @param znear defines the near clip plane
  5420. * @param zfar defines the far clip plane
  5421. * @returns a new matrix as a right-handed perspective projection matrix
  5422. */
  5423. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5424. /**
  5425. * Stores a right-handed perspective projection into a given matrix
  5426. * @param fov defines the horizontal field of view
  5427. * @param aspect defines the aspect ratio
  5428. * @param znear defines the near clip plane
  5429. * @param zfar defines the far clip plane
  5430. * @param result defines the target matrix
  5431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5432. */
  5433. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5434. /**
  5435. * Stores a right-handed perspective projection into a given matrix
  5436. * @param fov defines the horizontal field of view
  5437. * @param aspect defines the aspect ratio
  5438. * @param znear defines the near clip plane
  5439. * @param zfar not used as infinity is used as far clip
  5440. * @param result defines the target matrix
  5441. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5442. */
  5443. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5444. /**
  5445. * Stores a perspective projection for WebVR info a given matrix
  5446. * @param fov defines the field of view
  5447. * @param znear defines the near clip plane
  5448. * @param zfar defines the far clip plane
  5449. * @param result defines the target matrix
  5450. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5451. */
  5452. static PerspectiveFovWebVRToRef(fov: {
  5453. upDegrees: number;
  5454. downDegrees: number;
  5455. leftDegrees: number;
  5456. rightDegrees: number;
  5457. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5458. /**
  5459. * Computes a complete transformation matrix
  5460. * @param viewport defines the viewport to use
  5461. * @param world defines the world matrix
  5462. * @param view defines the view matrix
  5463. * @param projection defines the projection matrix
  5464. * @param zmin defines the near clip plane
  5465. * @param zmax defines the far clip plane
  5466. * @returns the transformation matrix
  5467. */
  5468. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5469. /**
  5470. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5471. * @param matrix defines the matrix to use
  5472. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5473. */
  5474. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5475. /**
  5476. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5477. * @param matrix defines the matrix to use
  5478. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5479. */
  5480. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5481. /**
  5482. * Compute the transpose of a given matrix
  5483. * @param matrix defines the matrix to transpose
  5484. * @returns the new matrix
  5485. */
  5486. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5487. /**
  5488. * Compute the transpose of a matrix and store it in a target matrix
  5489. * @param matrix defines the matrix to transpose
  5490. * @param result defines the target matrix
  5491. */
  5492. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5493. /**
  5494. * Computes a reflection matrix from a plane
  5495. * @param plane defines the reflection plane
  5496. * @returns a new matrix
  5497. */
  5498. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5499. /**
  5500. * Computes a reflection matrix from a plane
  5501. * @param plane defines the reflection plane
  5502. * @param result defines the target matrix
  5503. */
  5504. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5505. /**
  5506. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5507. * @param xaxis defines the value of the 1st axis
  5508. * @param yaxis defines the value of the 2nd axis
  5509. * @param zaxis defines the value of the 3rd axis
  5510. * @param result defines the target matrix
  5511. */
  5512. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5513. /**
  5514. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5515. * @param quat defines the quaternion to use
  5516. * @param result defines the target matrix
  5517. */
  5518. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5519. }
  5520. /**
  5521. * @hidden
  5522. */
  5523. export class TmpVectors {
  5524. static Vector2: Vector2[];
  5525. static Vector3: Vector3[];
  5526. static Vector4: Vector4[];
  5527. static Quaternion: Quaternion[];
  5528. static Matrix: Matrix[];
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * Defines potential orientation for back face culling
  5534. */
  5535. export enum Orientation {
  5536. /**
  5537. * Clockwise
  5538. */
  5539. CW = 0,
  5540. /** Counter clockwise */
  5541. CCW = 1
  5542. }
  5543. /** Class used to represent a Bezier curve */
  5544. export class BezierCurve {
  5545. /**
  5546. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5547. * @param t defines the time
  5548. * @param x1 defines the left coordinate on X axis
  5549. * @param y1 defines the left coordinate on Y axis
  5550. * @param x2 defines the right coordinate on X axis
  5551. * @param y2 defines the right coordinate on Y axis
  5552. * @returns the interpolated value
  5553. */
  5554. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5555. }
  5556. /**
  5557. * Defines angle representation
  5558. */
  5559. export class Angle {
  5560. private _radians;
  5561. /**
  5562. * Creates an Angle object of "radians" radians (float).
  5563. * @param radians the angle in radians
  5564. */
  5565. constructor(radians: number);
  5566. /**
  5567. * Get value in degrees
  5568. * @returns the Angle value in degrees (float)
  5569. */
  5570. degrees(): number;
  5571. /**
  5572. * Get value in radians
  5573. * @returns the Angle value in radians (float)
  5574. */
  5575. radians(): number;
  5576. /**
  5577. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5578. * @param a defines first point as the origin
  5579. * @param b defines point
  5580. * @returns a new Angle
  5581. */
  5582. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5583. /**
  5584. * Gets a new Angle object from the given float in radians
  5585. * @param radians defines the angle value in radians
  5586. * @returns a new Angle
  5587. */
  5588. static FromRadians(radians: number): Angle;
  5589. /**
  5590. * Gets a new Angle object from the given float in degrees
  5591. * @param degrees defines the angle value in degrees
  5592. * @returns a new Angle
  5593. */
  5594. static FromDegrees(degrees: number): Angle;
  5595. }
  5596. /**
  5597. * This represents an arc in a 2d space.
  5598. */
  5599. export class Arc2 {
  5600. /** Defines the start point of the arc */
  5601. startPoint: Vector2;
  5602. /** Defines the mid point of the arc */
  5603. midPoint: Vector2;
  5604. /** Defines the end point of the arc */
  5605. endPoint: Vector2;
  5606. /**
  5607. * Defines the center point of the arc.
  5608. */
  5609. centerPoint: Vector2;
  5610. /**
  5611. * Defines the radius of the arc.
  5612. */
  5613. radius: number;
  5614. /**
  5615. * Defines the angle of the arc (from mid point to end point).
  5616. */
  5617. angle: Angle;
  5618. /**
  5619. * Defines the start angle of the arc (from start point to middle point).
  5620. */
  5621. startAngle: Angle;
  5622. /**
  5623. * Defines the orientation of the arc (clock wise/counter clock wise).
  5624. */
  5625. orientation: Orientation;
  5626. /**
  5627. * Creates an Arc object from the three given points : start, middle and end.
  5628. * @param startPoint Defines the start point of the arc
  5629. * @param midPoint Defines the midlle point of the arc
  5630. * @param endPoint Defines the end point of the arc
  5631. */
  5632. constructor(
  5633. /** Defines the start point of the arc */
  5634. startPoint: Vector2,
  5635. /** Defines the mid point of the arc */
  5636. midPoint: Vector2,
  5637. /** Defines the end point of the arc */
  5638. endPoint: Vector2);
  5639. }
  5640. /**
  5641. * Represents a 2D path made up of multiple 2D points
  5642. */
  5643. export class Path2 {
  5644. private _points;
  5645. private _length;
  5646. /**
  5647. * If the path start and end point are the same
  5648. */
  5649. closed: boolean;
  5650. /**
  5651. * Creates a Path2 object from the starting 2D coordinates x and y.
  5652. * @param x the starting points x value
  5653. * @param y the starting points y value
  5654. */
  5655. constructor(x: number, y: number);
  5656. /**
  5657. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5658. * @param x the added points x value
  5659. * @param y the added points y value
  5660. * @returns the updated Path2.
  5661. */
  5662. addLineTo(x: number, y: number): Path2;
  5663. /**
  5664. * 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.
  5665. * @param midX middle point x value
  5666. * @param midY middle point y value
  5667. * @param endX end point x value
  5668. * @param endY end point y value
  5669. * @param numberOfSegments (default: 36)
  5670. * @returns the updated Path2.
  5671. */
  5672. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5673. /**
  5674. * Closes the Path2.
  5675. * @returns the Path2.
  5676. */
  5677. close(): Path2;
  5678. /**
  5679. * Gets the sum of the distance between each sequential point in the path
  5680. * @returns the Path2 total length (float).
  5681. */
  5682. length(): number;
  5683. /**
  5684. * Gets the points which construct the path
  5685. * @returns the Path2 internal array of points.
  5686. */
  5687. getPoints(): Vector2[];
  5688. /**
  5689. * Retreives the point at the distance aways from the starting point
  5690. * @param normalizedLengthPosition the length along the path to retreive the point from
  5691. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5692. */
  5693. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5694. /**
  5695. * Creates a new path starting from an x and y position
  5696. * @param x starting x value
  5697. * @param y starting y value
  5698. * @returns a new Path2 starting at the coordinates (x, y).
  5699. */
  5700. static StartingAt(x: number, y: number): Path2;
  5701. }
  5702. /**
  5703. * Represents a 3D path made up of multiple 3D points
  5704. */
  5705. export class Path3D {
  5706. /**
  5707. * an array of Vector3, the curve axis of the Path3D
  5708. */
  5709. path: Vector3[];
  5710. private _curve;
  5711. private _distances;
  5712. private _tangents;
  5713. private _normals;
  5714. private _binormals;
  5715. private _raw;
  5716. private _alignTangentsWithPath;
  5717. private readonly _pointAtData;
  5718. /**
  5719. * new Path3D(path, normal, raw)
  5720. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5721. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5722. * @param path an array of Vector3, the curve axis of the Path3D
  5723. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5724. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5725. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5726. */
  5727. constructor(
  5728. /**
  5729. * an array of Vector3, the curve axis of the Path3D
  5730. */
  5731. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5732. /**
  5733. * Returns the Path3D array of successive Vector3 designing its curve.
  5734. * @returns the Path3D array of successive Vector3 designing its curve.
  5735. */
  5736. getCurve(): Vector3[];
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getPoints(): Vector3[];
  5742. /**
  5743. * @returns the computed length (float) of the path.
  5744. */
  5745. length(): number;
  5746. /**
  5747. * Returns an array populated with tangent vectors on each Path3D curve point.
  5748. * @returns an array populated with tangent vectors on each Path3D curve point.
  5749. */
  5750. getTangents(): Vector3[];
  5751. /**
  5752. * Returns an array populated with normal vectors on each Path3D curve point.
  5753. * @returns an array populated with normal vectors on each Path3D curve point.
  5754. */
  5755. getNormals(): Vector3[];
  5756. /**
  5757. * Returns an array populated with binormal vectors on each Path3D curve point.
  5758. * @returns an array populated with binormal vectors on each Path3D curve point.
  5759. */
  5760. getBinormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5763. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5764. */
  5765. getDistances(): number[];
  5766. /**
  5767. * Returns an interpolated point along this path
  5768. * @param position the position of the point along this path, from 0.0 to 1.0
  5769. * @returns a new Vector3 as the point
  5770. */
  5771. getPointAt(position: number): Vector3;
  5772. /**
  5773. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5774. * @param position the position of the point along this path, from 0.0 to 1.0
  5775. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5776. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5777. */
  5778. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5779. /**
  5780. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5781. * @param position the position of the point along this path, from 0.0 to 1.0
  5782. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5783. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5784. */
  5785. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5786. /**
  5787. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5788. * @param position the position of the point along this path, from 0.0 to 1.0
  5789. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5790. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5791. */
  5792. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5793. /**
  5794. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5795. * @param position the position of the point along this path, from 0.0 to 1.0
  5796. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5797. */
  5798. getDistanceAt(position: number): number;
  5799. /**
  5800. * Returns the array index of the previous point of an interpolated point along this path
  5801. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5802. * @returns the array index
  5803. */
  5804. getPreviousPointIndexAt(position: number): number;
  5805. /**
  5806. * 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)
  5807. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5808. * @returns the sub position
  5809. */
  5810. getSubPositionAt(position: number): number;
  5811. /**
  5812. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5813. * @param target the vector of which to get the closest position to
  5814. * @returns the position of the closest virtual point on this path to the target vector
  5815. */
  5816. getClosestPositionTo(target: Vector3): number;
  5817. /**
  5818. * Returns a sub path (slice) of this path
  5819. * @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
  5820. * @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
  5821. * @returns a sub path (slice) of this path
  5822. */
  5823. slice(start?: number, end?: number): Path3D;
  5824. /**
  5825. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5826. * @param path path which all values are copied into the curves points
  5827. * @param firstNormal which should be projected onto the curve
  5828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5829. * @returns the same object updated.
  5830. */
  5831. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5832. private _compute;
  5833. private _getFirstNonNullVector;
  5834. private _getLastNonNullVector;
  5835. private _normalVector;
  5836. /**
  5837. * Updates the point at data for an interpolated point along this curve
  5838. * @param position the position of the point along this curve, from 0.0 to 1.0
  5839. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5840. * @returns the (updated) point at data
  5841. */
  5842. private _updatePointAtData;
  5843. /**
  5844. * Updates the point at data from the specified parameters
  5845. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5846. * @param point the interpolated point
  5847. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5848. */
  5849. private _setPointAtData;
  5850. /**
  5851. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5852. */
  5853. private _updateInterpolationMatrix;
  5854. }
  5855. /**
  5856. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5857. * A Curve3 is designed from a series of successive Vector3.
  5858. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5859. */
  5860. export class Curve3 {
  5861. private _points;
  5862. private _length;
  5863. /**
  5864. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5865. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5866. * @param v1 (Vector3) the control point
  5867. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5868. * @param nbPoints (integer) the wanted number of points in the curve
  5869. * @returns the created Curve3
  5870. */
  5871. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5872. /**
  5873. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5874. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5875. * @param v1 (Vector3) the first control point
  5876. * @param v2 (Vector3) the second control point
  5877. * @param v3 (Vector3) the end point of the Cubic Bezier
  5878. * @param nbPoints (integer) the wanted number of points in the curve
  5879. * @returns the created Curve3
  5880. */
  5881. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5882. /**
  5883. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5884. * @param p1 (Vector3) the origin point of the Hermite Spline
  5885. * @param t1 (Vector3) the tangent vector at the origin point
  5886. * @param p2 (Vector3) the end point of the Hermite Spline
  5887. * @param t2 (Vector3) the tangent vector at the end point
  5888. * @param nbPoints (integer) the wanted number of points in the curve
  5889. * @returns the created Curve3
  5890. */
  5891. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5892. /**
  5893. * Returns a Curve3 object along a CatmullRom Spline curve :
  5894. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5895. * @param nbPoints (integer) the wanted number of points between each curve control points
  5896. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5897. * @returns the created Curve3
  5898. */
  5899. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5900. /**
  5901. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5902. * A Curve3 is designed from a series of successive Vector3.
  5903. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5904. * @param points points which make up the curve
  5905. */
  5906. constructor(points: Vector3[]);
  5907. /**
  5908. * @returns the Curve3 stored array of successive Vector3
  5909. */
  5910. getPoints(): Vector3[];
  5911. /**
  5912. * @returns the computed length (float) of the curve.
  5913. */
  5914. length(): number;
  5915. /**
  5916. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5917. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5918. * curveA and curveB keep unchanged.
  5919. * @param curve the curve to continue from this curve
  5920. * @returns the newly constructed curve
  5921. */
  5922. continue(curve: DeepImmutable<Curve3>): Curve3;
  5923. private _computeLength;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. /**
  5928. * This represents the main contract an easing function should follow.
  5929. * Easing functions are used throughout the animation system.
  5930. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5931. */
  5932. export interface IEasingFunction {
  5933. /**
  5934. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5935. * of the easing function.
  5936. * The link below provides some of the most common examples of easing functions.
  5937. * @see https://easings.net/
  5938. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5939. * @returns the corresponding value on the curve defined by the easing function
  5940. */
  5941. ease(gradient: number): number;
  5942. }
  5943. /**
  5944. * Base class used for every default easing function.
  5945. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5946. */
  5947. export class EasingFunction implements IEasingFunction {
  5948. /**
  5949. * Interpolation follows the mathematical formula associated with the easing function.
  5950. */
  5951. static readonly EASINGMODE_EASEIN: number;
  5952. /**
  5953. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5954. */
  5955. static readonly EASINGMODE_EASEOUT: number;
  5956. /**
  5957. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5958. */
  5959. static readonly EASINGMODE_EASEINOUT: number;
  5960. private _easingMode;
  5961. /**
  5962. * Sets the easing mode of the current function.
  5963. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5964. */
  5965. setEasingMode(easingMode: number): void;
  5966. /**
  5967. * Gets the current easing mode.
  5968. * @returns the easing mode
  5969. */
  5970. getEasingMode(): number;
  5971. /**
  5972. * @hidden
  5973. */
  5974. easeInCore(gradient: number): number;
  5975. /**
  5976. * Given an input gradient between 0 and 1, this returns the corresponding value
  5977. * of the easing function.
  5978. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5979. * @returns the corresponding value on the curve defined by the easing function
  5980. */
  5981. ease(gradient: number): number;
  5982. }
  5983. /**
  5984. * Easing function with a circle shape (see link below).
  5985. * @see https://easings.net/#easeInCirc
  5986. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5987. */
  5988. export class CircleEase extends EasingFunction implements IEasingFunction {
  5989. /** @hidden */
  5990. easeInCore(gradient: number): number;
  5991. }
  5992. /**
  5993. * Easing function with a ease back shape (see link below).
  5994. * @see https://easings.net/#easeInBack
  5995. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5996. */
  5997. export class BackEase extends EasingFunction implements IEasingFunction {
  5998. /** Defines the amplitude of the function */
  5999. amplitude: number;
  6000. /**
  6001. * Instantiates a back ease easing
  6002. * @see https://easings.net/#easeInBack
  6003. * @param amplitude Defines the amplitude of the function
  6004. */
  6005. constructor(
  6006. /** Defines the amplitude of the function */
  6007. amplitude?: number);
  6008. /** @hidden */
  6009. easeInCore(gradient: number): number;
  6010. }
  6011. /**
  6012. * Easing function with a bouncing shape (see link below).
  6013. * @see https://easings.net/#easeInBounce
  6014. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6015. */
  6016. export class BounceEase extends EasingFunction implements IEasingFunction {
  6017. /** Defines the number of bounces */
  6018. bounces: number;
  6019. /** Defines the amplitude of the bounce */
  6020. bounciness: number;
  6021. /**
  6022. * Instantiates a bounce easing
  6023. * @see https://easings.net/#easeInBounce
  6024. * @param bounces Defines the number of bounces
  6025. * @param bounciness Defines the amplitude of the bounce
  6026. */
  6027. constructor(
  6028. /** Defines the number of bounces */
  6029. bounces?: number,
  6030. /** Defines the amplitude of the bounce */
  6031. bounciness?: number);
  6032. /** @hidden */
  6033. easeInCore(gradient: number): number;
  6034. }
  6035. /**
  6036. * Easing function with a power of 3 shape (see link below).
  6037. * @see https://easings.net/#easeInCubic
  6038. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6039. */
  6040. export class CubicEase extends EasingFunction implements IEasingFunction {
  6041. /** @hidden */
  6042. easeInCore(gradient: number): number;
  6043. }
  6044. /**
  6045. * Easing function with an elastic shape (see link below).
  6046. * @see https://easings.net/#easeInElastic
  6047. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6048. */
  6049. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6050. /** Defines the number of oscillations*/
  6051. oscillations: number;
  6052. /** Defines the amplitude of the oscillations*/
  6053. springiness: number;
  6054. /**
  6055. * Instantiates an elastic easing function
  6056. * @see https://easings.net/#easeInElastic
  6057. * @param oscillations Defines the number of oscillations
  6058. * @param springiness Defines the amplitude of the oscillations
  6059. */
  6060. constructor(
  6061. /** Defines the number of oscillations*/
  6062. oscillations?: number,
  6063. /** Defines the amplitude of the oscillations*/
  6064. springiness?: number);
  6065. /** @hidden */
  6066. easeInCore(gradient: number): number;
  6067. }
  6068. /**
  6069. * Easing function with an exponential shape (see link below).
  6070. * @see https://easings.net/#easeInExpo
  6071. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6072. */
  6073. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6074. /** Defines the exponent of the function */
  6075. exponent: number;
  6076. /**
  6077. * Instantiates an exponential easing function
  6078. * @see https://easings.net/#easeInExpo
  6079. * @param exponent Defines the exponent of the function
  6080. */
  6081. constructor(
  6082. /** Defines the exponent of the function */
  6083. exponent?: number);
  6084. /** @hidden */
  6085. easeInCore(gradient: number): number;
  6086. }
  6087. /**
  6088. * Easing function with a power shape (see link below).
  6089. * @see https://easings.net/#easeInQuad
  6090. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6091. */
  6092. export class PowerEase extends EasingFunction implements IEasingFunction {
  6093. /** Defines the power of the function */
  6094. power: number;
  6095. /**
  6096. * Instantiates an power base easing function
  6097. * @see https://easings.net/#easeInQuad
  6098. * @param power Defines the power of the function
  6099. */
  6100. constructor(
  6101. /** Defines the power of the function */
  6102. power?: number);
  6103. /** @hidden */
  6104. easeInCore(gradient: number): number;
  6105. }
  6106. /**
  6107. * Easing function with a power of 2 shape (see link below).
  6108. * @see https://easings.net/#easeInQuad
  6109. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6112. /** @hidden */
  6113. easeInCore(gradient: number): number;
  6114. }
  6115. /**
  6116. * Easing function with a power of 4 shape (see link below).
  6117. * @see https://easings.net/#easeInQuart
  6118. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6119. */
  6120. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6121. /** @hidden */
  6122. easeInCore(gradient: number): number;
  6123. }
  6124. /**
  6125. * Easing function with a power of 5 shape (see link below).
  6126. * @see https://easings.net/#easeInQuint
  6127. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6128. */
  6129. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6130. /** @hidden */
  6131. easeInCore(gradient: number): number;
  6132. }
  6133. /**
  6134. * Easing function with a sin shape (see link below).
  6135. * @see https://easings.net/#easeInSine
  6136. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6137. */
  6138. export class SineEase extends EasingFunction implements IEasingFunction {
  6139. /** @hidden */
  6140. easeInCore(gradient: number): number;
  6141. }
  6142. /**
  6143. * Easing function with a bezier shape (see link below).
  6144. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6145. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  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. /**
  6157. * Instantiates a bezier function
  6158. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6159. * @param x1 Defines the x component of the start tangent in the bezier curve
  6160. * @param y1 Defines the y component of the start tangent in the bezier curve
  6161. * @param x2 Defines the x component of the end tangent in the bezier curve
  6162. * @param y2 Defines the y component of the end tangent in the bezier curve
  6163. */
  6164. constructor(
  6165. /** Defines the x component of the start tangent in the bezier curve */
  6166. x1?: number,
  6167. /** Defines the y component of the start tangent in the bezier curve */
  6168. y1?: number,
  6169. /** Defines the x component of the end tangent in the bezier curve */
  6170. x2?: number,
  6171. /** Defines the y component of the end tangent in the bezier curve */
  6172. y2?: number);
  6173. /** @hidden */
  6174. easeInCore(gradient: number): number;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. /**
  6179. * Class used to hold a RGB color
  6180. */
  6181. export class Color3 {
  6182. /**
  6183. * Defines the red component (between 0 and 1, default is 0)
  6184. */
  6185. r: number;
  6186. /**
  6187. * Defines the green component (between 0 and 1, default is 0)
  6188. */
  6189. g: number;
  6190. /**
  6191. * Defines the blue component (between 0 and 1, default is 0)
  6192. */
  6193. b: number;
  6194. /**
  6195. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6196. * @param r defines the red component (between 0 and 1, default is 0)
  6197. * @param g defines the green component (between 0 and 1, default is 0)
  6198. * @param b defines the blue component (between 0 and 1, default is 0)
  6199. */
  6200. constructor(
  6201. /**
  6202. * Defines the red component (between 0 and 1, default is 0)
  6203. */
  6204. r?: number,
  6205. /**
  6206. * Defines the green component (between 0 and 1, default is 0)
  6207. */
  6208. g?: number,
  6209. /**
  6210. * Defines the blue component (between 0 and 1, default is 0)
  6211. */
  6212. b?: number);
  6213. /**
  6214. * Creates a string with the Color3 current values
  6215. * @returns the string representation of the Color3 object
  6216. */
  6217. toString(): string;
  6218. /**
  6219. * Returns the string "Color3"
  6220. * @returns "Color3"
  6221. */
  6222. getClassName(): string;
  6223. /**
  6224. * Compute the Color3 hash code
  6225. * @returns an unique number that can be used to hash Color3 objects
  6226. */
  6227. getHashCode(): number;
  6228. /**
  6229. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6230. * @param array defines the array where to store the r,g,b components
  6231. * @param index defines an optional index in the target array to define where to start storing values
  6232. * @returns the current Color3 object
  6233. */
  6234. toArray(array: FloatArray, index?: number): Color3;
  6235. /**
  6236. * Update the current color with values stored in an array from the starting index of the given array
  6237. * @param array defines the source array
  6238. * @param offset defines an offset in the source array
  6239. * @returns the current Color3 object
  6240. */
  6241. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6242. /**
  6243. * Returns a new Color4 object from the current Color3 and the given alpha
  6244. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6245. * @returns a new Color4 object
  6246. */
  6247. toColor4(alpha?: number): Color4;
  6248. /**
  6249. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6250. * @returns the new array
  6251. */
  6252. asArray(): number[];
  6253. /**
  6254. * Returns the luminance value
  6255. * @returns a float value
  6256. */
  6257. toLuminance(): number;
  6258. /**
  6259. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6260. * @param otherColor defines the second operand
  6261. * @returns the new Color3 object
  6262. */
  6263. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6264. /**
  6265. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6266. * @param otherColor defines the second operand
  6267. * @param result defines the Color3 object where to store the result
  6268. * @returns the current Color3
  6269. */
  6270. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6271. /**
  6272. * Determines equality between Color3 objects
  6273. * @param otherColor defines the second operand
  6274. * @returns true if the rgb values are equal to the given ones
  6275. */
  6276. equals(otherColor: DeepImmutable<Color3>): boolean;
  6277. /**
  6278. * Determines equality between the current Color3 object and a set of r,b,g values
  6279. * @param r defines the red component to check
  6280. * @param g defines the green component to check
  6281. * @param b defines the blue component to check
  6282. * @returns true if the rgb values are equal to the given ones
  6283. */
  6284. equalsFloats(r: number, g: number, b: number): boolean;
  6285. /**
  6286. * Multiplies in place each rgb value by scale
  6287. * @param scale defines the scaling factor
  6288. * @returns the updated Color3
  6289. */
  6290. scale(scale: number): Color3;
  6291. /**
  6292. * Multiplies the rgb values by scale and stores the result into "result"
  6293. * @param scale defines the scaling factor
  6294. * @param result defines the Color3 object where to store the result
  6295. * @returns the unmodified current Color3
  6296. */
  6297. scaleToRef(scale: number, result: Color3): Color3;
  6298. /**
  6299. * Scale the current Color3 values by a factor and add the result to a given Color3
  6300. * @param scale defines the scale factor
  6301. * @param result defines color to store the result into
  6302. * @returns the unmodified current Color3
  6303. */
  6304. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6305. /**
  6306. * Clamps the rgb values by the min and max values and stores the result into "result"
  6307. * @param min defines minimum clamping value (default is 0)
  6308. * @param max defines maximum clamping value (default is 1)
  6309. * @param result defines color to store the result into
  6310. * @returns the original Color3
  6311. */
  6312. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6313. /**
  6314. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6315. * @param otherColor defines the second operand
  6316. * @returns the new Color3
  6317. */
  6318. add(otherColor: DeepImmutable<Color3>): Color3;
  6319. /**
  6320. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6321. * @param otherColor defines the second operand
  6322. * @param result defines Color3 object to store the result into
  6323. * @returns the unmodified current Color3
  6324. */
  6325. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6326. /**
  6327. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6328. * @param otherColor defines the second operand
  6329. * @returns the new Color3
  6330. */
  6331. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6332. /**
  6333. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6334. * @param otherColor defines the second operand
  6335. * @param result defines Color3 object to store the result into
  6336. * @returns the unmodified current Color3
  6337. */
  6338. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6339. /**
  6340. * Copy the current object
  6341. * @returns a new Color3 copied the current one
  6342. */
  6343. clone(): Color3;
  6344. /**
  6345. * Copies the rgb values from the source in the current Color3
  6346. * @param source defines the source Color3 object
  6347. * @returns the updated Color3 object
  6348. */
  6349. copyFrom(source: DeepImmutable<Color3>): Color3;
  6350. /**
  6351. * Updates the Color3 rgb values from the given floats
  6352. * @param r defines the red component to read from
  6353. * @param g defines the green component to read from
  6354. * @param b defines the blue component to read from
  6355. * @returns the current Color3 object
  6356. */
  6357. copyFromFloats(r: number, g: number, b: number): Color3;
  6358. /**
  6359. * Updates the Color3 rgb values from the given floats
  6360. * @param r defines the red component to read from
  6361. * @param g defines the green component to read from
  6362. * @param b defines the blue component to read from
  6363. * @returns the current Color3 object
  6364. */
  6365. set(r: number, g: number, b: number): Color3;
  6366. /**
  6367. * Compute the Color3 hexadecimal code as a string
  6368. * @returns a string containing the hexadecimal representation of the Color3 object
  6369. */
  6370. toHexString(): string;
  6371. /**
  6372. * Computes a new Color3 converted from the current one to linear space
  6373. * @returns a new Color3 object
  6374. */
  6375. toLinearSpace(): Color3;
  6376. /**
  6377. * Converts current color in rgb space to HSV values
  6378. * @returns a new color3 representing the HSV values
  6379. */
  6380. toHSV(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @param result defines the Color3 where to store the HSV values
  6384. */
  6385. toHSVToRef(result: Color3): void;
  6386. /**
  6387. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6388. * @param convertedColor defines the Color3 object where to store the linear space version
  6389. * @returns the unmodified Color3
  6390. */
  6391. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6392. /**
  6393. * Computes a new Color3 converted from the current one to gamma space
  6394. * @returns a new Color3 object
  6395. */
  6396. toGammaSpace(): Color3;
  6397. /**
  6398. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6399. * @param convertedColor defines the Color3 object where to store the gamma space version
  6400. * @returns the unmodified Color3
  6401. */
  6402. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6403. private static _BlackReadOnly;
  6404. /**
  6405. * Convert Hue, saturation and value to a Color3 (RGB)
  6406. * @param hue defines the hue
  6407. * @param saturation defines the saturation
  6408. * @param value defines the value
  6409. * @param result defines the Color3 where to store the RGB values
  6410. */
  6411. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6412. /**
  6413. * Creates a new Color3 from the string containing valid hexadecimal values
  6414. * @param hex defines a string containing valid hexadecimal values
  6415. * @returns a new Color3 object
  6416. */
  6417. static FromHexString(hex: string): Color3;
  6418. /**
  6419. * Creates a new Color3 from the starting index of the given array
  6420. * @param array defines the source array
  6421. * @param offset defines an offset in the source array
  6422. * @returns a new Color3 object
  6423. */
  6424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6425. /**
  6426. * Creates a new Color3 from the starting index element of the given array
  6427. * @param array defines the source array to read from
  6428. * @param offset defines the offset in the source array
  6429. * @param result defines the target Color3 object
  6430. */
  6431. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6432. /**
  6433. * Creates a new Color3 from integer values (< 256)
  6434. * @param r defines the red component to read from (value between 0 and 255)
  6435. * @param g defines the green component to read from (value between 0 and 255)
  6436. * @param b defines the blue component to read from (value between 0 and 255)
  6437. * @returns a new Color3 object
  6438. */
  6439. static FromInts(r: number, g: number, b: number): Color3;
  6440. /**
  6441. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6442. * @param start defines the start Color3 value
  6443. * @param end defines the end Color3 value
  6444. * @param amount defines the gradient value between start and end
  6445. * @returns a new Color3 object
  6446. */
  6447. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6448. /**
  6449. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6450. * @param left defines the start value
  6451. * @param right defines the end value
  6452. * @param amount defines the gradient factor
  6453. * @param result defines the Color3 object where to store the result
  6454. */
  6455. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6456. /**
  6457. * Returns a Color3 value containing a red color
  6458. * @returns a new Color3 object
  6459. */
  6460. static Red(): Color3;
  6461. /**
  6462. * Returns a Color3 value containing a green color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Green(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a blue color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Blue(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a black color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Black(): Color3;
  6476. /**
  6477. * Gets a Color3 value containing a black color that must not be updated
  6478. */
  6479. static get BlackReadOnly(): DeepImmutable<Color3>;
  6480. /**
  6481. * Returns a Color3 value containing a white color
  6482. * @returns a new Color3 object
  6483. */
  6484. static White(): Color3;
  6485. /**
  6486. * Returns a Color3 value containing a purple color
  6487. * @returns a new Color3 object
  6488. */
  6489. static Purple(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a magenta color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Magenta(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a yellow color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Yellow(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a gray color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Gray(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a teal color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Teal(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a random color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Random(): Color3;
  6515. }
  6516. /**
  6517. * Class used to hold a RBGA color
  6518. */
  6519. export class Color4 {
  6520. /**
  6521. * Defines the red component (between 0 and 1, default is 0)
  6522. */
  6523. r: number;
  6524. /**
  6525. * Defines the green component (between 0 and 1, default is 0)
  6526. */
  6527. g: number;
  6528. /**
  6529. * Defines the blue component (between 0 and 1, default is 0)
  6530. */
  6531. b: number;
  6532. /**
  6533. * Defines the alpha component (between 0 and 1, default is 1)
  6534. */
  6535. a: number;
  6536. /**
  6537. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6538. * @param r defines the red component (between 0 and 1, default is 0)
  6539. * @param g defines the green component (between 0 and 1, default is 0)
  6540. * @param b defines the blue component (between 0 and 1, default is 0)
  6541. * @param a defines the alpha component (between 0 and 1, default is 1)
  6542. */
  6543. constructor(
  6544. /**
  6545. * Defines the red component (between 0 and 1, default is 0)
  6546. */
  6547. r?: number,
  6548. /**
  6549. * Defines the green component (between 0 and 1, default is 0)
  6550. */
  6551. g?: number,
  6552. /**
  6553. * Defines the blue component (between 0 and 1, default is 0)
  6554. */
  6555. b?: number,
  6556. /**
  6557. * Defines the alpha component (between 0 and 1, default is 1)
  6558. */
  6559. a?: number);
  6560. /**
  6561. * Adds in place the given Color4 values to the current Color4 object
  6562. * @param right defines the second operand
  6563. * @returns the current updated Color4 object
  6564. */
  6565. addInPlace(right: DeepImmutable<Color4>): Color4;
  6566. /**
  6567. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6568. * @returns the new array
  6569. */
  6570. asArray(): number[];
  6571. /**
  6572. * Stores from the starting index in the given array the Color4 successive values
  6573. * @param array defines the array where to store the r,g,b components
  6574. * @param index defines an optional index in the target array to define where to start storing values
  6575. * @returns the current Color4 object
  6576. */
  6577. toArray(array: number[], index?: number): Color4;
  6578. /**
  6579. * Update the current color with values stored in an array from the starting index of the given array
  6580. * @param array defines the source array
  6581. * @param offset defines an offset in the source array
  6582. * @returns the current Color4 object
  6583. */
  6584. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6585. /**
  6586. * Determines equality between Color4 objects
  6587. * @param otherColor defines the second operand
  6588. * @returns true if the rgba values are equal to the given ones
  6589. */
  6590. equals(otherColor: DeepImmutable<Color4>): boolean;
  6591. /**
  6592. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6593. * @param right defines the second operand
  6594. * @returns a new Color4 object
  6595. */
  6596. add(right: DeepImmutable<Color4>): Color4;
  6597. /**
  6598. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6599. * @param right defines the second operand
  6600. * @returns a new Color4 object
  6601. */
  6602. subtract(right: DeepImmutable<Color4>): Color4;
  6603. /**
  6604. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6605. * @param right defines the second operand
  6606. * @param result defines the Color4 object where to store the result
  6607. * @returns the current Color4 object
  6608. */
  6609. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6610. /**
  6611. * Creates a new Color4 with the current Color4 values multiplied by scale
  6612. * @param scale defines the scaling factor to apply
  6613. * @returns a new Color4 object
  6614. */
  6615. scale(scale: number): Color4;
  6616. /**
  6617. * Multiplies the current Color4 values by scale and stores the result in "result"
  6618. * @param scale defines the scaling factor to apply
  6619. * @param result defines the Color4 object where to store the result
  6620. * @returns the current unmodified Color4
  6621. */
  6622. scaleToRef(scale: number, result: Color4): Color4;
  6623. /**
  6624. * Scale the current Color4 values by a factor and add the result to a given Color4
  6625. * @param scale defines the scale factor
  6626. * @param result defines the Color4 object where to store the result
  6627. * @returns the unmodified current Color4
  6628. */
  6629. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6630. /**
  6631. * Clamps the rgb values by the min and max values and stores the result into "result"
  6632. * @param min defines minimum clamping value (default is 0)
  6633. * @param max defines maximum clamping value (default is 1)
  6634. * @param result defines color to store the result into.
  6635. * @returns the cuurent Color4
  6636. */
  6637. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6638. /**
  6639. * Multipy an Color4 value by another and return a new Color4 object
  6640. * @param color defines the Color4 value to multiply by
  6641. * @returns a new Color4 object
  6642. */
  6643. multiply(color: Color4): Color4;
  6644. /**
  6645. * Multipy a Color4 value by another and push the result in a reference value
  6646. * @param color defines the Color4 value to multiply by
  6647. * @param result defines the Color4 to fill the result in
  6648. * @returns the result Color4
  6649. */
  6650. multiplyToRef(color: Color4, result: Color4): Color4;
  6651. /**
  6652. * Creates a string with the Color4 current values
  6653. * @returns the string representation of the Color4 object
  6654. */
  6655. toString(): string;
  6656. /**
  6657. * Returns the string "Color4"
  6658. * @returns "Color4"
  6659. */
  6660. getClassName(): string;
  6661. /**
  6662. * Compute the Color4 hash code
  6663. * @returns an unique number that can be used to hash Color4 objects
  6664. */
  6665. getHashCode(): number;
  6666. /**
  6667. * Creates a new Color4 copied from the current one
  6668. * @returns a new Color4 object
  6669. */
  6670. clone(): Color4;
  6671. /**
  6672. * Copies the given Color4 values into the current one
  6673. * @param source defines the source Color4 object
  6674. * @returns the current updated Color4 object
  6675. */
  6676. copyFrom(source: Color4): Color4;
  6677. /**
  6678. * Copies the given float values into the current one
  6679. * @param r defines the red component to read from
  6680. * @param g defines the green component to read from
  6681. * @param b defines the blue component to read from
  6682. * @param a defines the alpha component to read from
  6683. * @returns the current updated Color4 object
  6684. */
  6685. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6686. /**
  6687. * Copies the given float values into the current one
  6688. * @param r defines the red component to read from
  6689. * @param g defines the green component to read from
  6690. * @param b defines the blue component to read from
  6691. * @param a defines the alpha component to read from
  6692. * @returns the current updated Color4 object
  6693. */
  6694. set(r: number, g: number, b: number, a: number): Color4;
  6695. /**
  6696. * Compute the Color4 hexadecimal code as a string
  6697. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6698. * @returns a string containing the hexadecimal representation of the Color4 object
  6699. */
  6700. toHexString(returnAsColor3?: boolean): string;
  6701. /**
  6702. * Computes a new Color4 converted from the current one to linear space
  6703. * @returns a new Color4 object
  6704. */
  6705. toLinearSpace(): Color4;
  6706. /**
  6707. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6708. * @param convertedColor defines the Color4 object where to store the linear space version
  6709. * @returns the unmodified Color4
  6710. */
  6711. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6712. /**
  6713. * Computes a new Color4 converted from the current one to gamma space
  6714. * @returns a new Color4 object
  6715. */
  6716. toGammaSpace(): Color4;
  6717. /**
  6718. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6719. * @param convertedColor defines the Color4 object where to store the gamma space version
  6720. * @returns the unmodified Color4
  6721. */
  6722. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6723. /**
  6724. * Creates a new Color4 from the string containing valid hexadecimal values
  6725. * @param hex defines a string containing valid hexadecimal values
  6726. * @returns a new Color4 object
  6727. */
  6728. static FromHexString(hex: string): Color4;
  6729. /**
  6730. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6731. * @param left defines the start value
  6732. * @param right defines the end value
  6733. * @param amount defines the gradient factor
  6734. * @returns a new Color4 object
  6735. */
  6736. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6737. /**
  6738. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6739. * @param left defines the start value
  6740. * @param right defines the end value
  6741. * @param amount defines the gradient factor
  6742. * @param result defines the Color4 object where to store data
  6743. */
  6744. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6745. /**
  6746. * Creates a new Color4 from a Color3 and an alpha value
  6747. * @param color3 defines the source Color3 to read from
  6748. * @param alpha defines the alpha component (1.0 by default)
  6749. * @returns a new Color4 object
  6750. */
  6751. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6752. /**
  6753. * Creates a new Color4 from the starting index element of the given array
  6754. * @param array defines the source array to read from
  6755. * @param offset defines the offset in the source array
  6756. * @returns a new Color4 object
  6757. */
  6758. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6759. /**
  6760. * Creates a new Color4 from the starting index element of the given array
  6761. * @param array defines the source array to read from
  6762. * @param offset defines the offset in the source array
  6763. * @param result defines the target Color4 object
  6764. */
  6765. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6766. /**
  6767. * Creates a new Color3 from integer values (< 256)
  6768. * @param r defines the red component to read from (value between 0 and 255)
  6769. * @param g defines the green component to read from (value between 0 and 255)
  6770. * @param b defines the blue component to read from (value between 0 and 255)
  6771. * @param a defines the alpha component to read from (value between 0 and 255)
  6772. * @returns a new Color3 object
  6773. */
  6774. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6775. /**
  6776. * Check the content of a given array and convert it to an array containing RGBA data
  6777. * If the original array was already containing count * 4 values then it is returned directly
  6778. * @param colors defines the array to check
  6779. * @param count defines the number of RGBA data to expect
  6780. * @returns an array containing count * 4 values (RGBA)
  6781. */
  6782. static CheckColors4(colors: number[], count: number): number[];
  6783. }
  6784. /**
  6785. * @hidden
  6786. */
  6787. export class TmpColors {
  6788. static Color3: Color3[];
  6789. static Color4: Color4[];
  6790. }
  6791. }
  6792. declare module BABYLON {
  6793. /**
  6794. * Defines an interface which represents an animation key frame
  6795. */
  6796. export interface IAnimationKey {
  6797. /**
  6798. * Frame of the key frame
  6799. */
  6800. frame: number;
  6801. /**
  6802. * Value at the specifies key frame
  6803. */
  6804. value: any;
  6805. /**
  6806. * The input tangent for the cubic hermite spline
  6807. */
  6808. inTangent?: any;
  6809. /**
  6810. * The output tangent for the cubic hermite spline
  6811. */
  6812. outTangent?: any;
  6813. /**
  6814. * The animation interpolation type
  6815. */
  6816. interpolation?: AnimationKeyInterpolation;
  6817. }
  6818. /**
  6819. * Enum for the animation key frame interpolation type
  6820. */
  6821. export enum AnimationKeyInterpolation {
  6822. /**
  6823. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6824. */
  6825. STEP = 1
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Represents the range of an animation
  6831. */
  6832. export class AnimationRange {
  6833. /**The name of the animation range**/
  6834. name: string;
  6835. /**The starting frame of the animation */
  6836. from: number;
  6837. /**The ending frame of the animation*/
  6838. to: number;
  6839. /**
  6840. * Initializes the range of an animation
  6841. * @param name The name of the animation range
  6842. * @param from The starting frame of the animation
  6843. * @param to The ending frame of the animation
  6844. */
  6845. constructor(
  6846. /**The name of the animation range**/
  6847. name: string,
  6848. /**The starting frame of the animation */
  6849. from: number,
  6850. /**The ending frame of the animation*/
  6851. to: number);
  6852. /**
  6853. * Makes a copy of the animation range
  6854. * @returns A copy of the animation range
  6855. */
  6856. clone(): AnimationRange;
  6857. }
  6858. }
  6859. declare module BABYLON {
  6860. /**
  6861. * Composed of a frame, and an action function
  6862. */
  6863. export class AnimationEvent {
  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. /**
  6871. * Specifies if the animation event is done
  6872. */
  6873. isDone: boolean;
  6874. /**
  6875. * Initializes the animation event
  6876. * @param frame The frame for which the event is triggered
  6877. * @param action The event to perform when triggered
  6878. * @param onlyOnce Specifies if the event should be triggered only once
  6879. */
  6880. constructor(
  6881. /** The frame for which the event is triggered **/
  6882. frame: number,
  6883. /** The event to perform when triggered **/
  6884. action: (currentFrame: number) => void,
  6885. /** Specifies if the event should be triggered only once**/
  6886. onlyOnce?: boolean | undefined);
  6887. /** @hidden */
  6888. _clone(): AnimationEvent;
  6889. }
  6890. }
  6891. declare module BABYLON {
  6892. /**
  6893. * Interface used to define a behavior
  6894. */
  6895. export interface Behavior<T> {
  6896. /** gets or sets behavior's name */
  6897. name: string;
  6898. /**
  6899. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6900. */
  6901. init(): void;
  6902. /**
  6903. * Called when the behavior is attached to a target
  6904. * @param target defines the target where the behavior is attached to
  6905. */
  6906. attach(target: T): void;
  6907. /**
  6908. * Called when the behavior is detached from its target
  6909. */
  6910. detach(): void;
  6911. }
  6912. /**
  6913. * Interface implemented by classes supporting behaviors
  6914. */
  6915. export interface IBehaviorAware<T> {
  6916. /**
  6917. * Attach a behavior
  6918. * @param behavior defines the behavior to attach
  6919. * @returns the current host
  6920. */
  6921. addBehavior(behavior: Behavior<T>): T;
  6922. /**
  6923. * Remove a behavior from the current object
  6924. * @param behavior defines the behavior to detach
  6925. * @returns the current host
  6926. */
  6927. removeBehavior(behavior: Behavior<T>): T;
  6928. /**
  6929. * Gets a behavior using its name to search
  6930. * @param name defines the name to search
  6931. * @returns the behavior or null if not found
  6932. */
  6933. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6934. }
  6935. }
  6936. declare module BABYLON {
  6937. /**
  6938. * Class used to store data that will be store in GPU memory
  6939. */
  6940. export class Buffer {
  6941. private _engine;
  6942. private _buffer;
  6943. /** @hidden */
  6944. _data: Nullable<DataArray>;
  6945. private _updatable;
  6946. private _instanced;
  6947. private _divisor;
  6948. private _isAlreadyOwned;
  6949. /**
  6950. * Gets the byte stride.
  6951. */
  6952. readonly byteStride: number;
  6953. /**
  6954. * Constructor
  6955. * @param engine the engine
  6956. * @param data the data to use for this buffer
  6957. * @param updatable whether the data is updatable
  6958. * @param stride the stride (optional)
  6959. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6960. * @param instanced whether the buffer is instanced (optional)
  6961. * @param useBytes set to true if the stride in in bytes (optional)
  6962. * @param divisor sets an optional divisor for instances (1 by default)
  6963. */
  6964. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6965. /**
  6966. * Create a new VertexBuffer based on the current buffer
  6967. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6968. * @param offset defines offset in the buffer (0 by default)
  6969. * @param size defines the size in floats of attributes (position is 3 for instance)
  6970. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6971. * @param instanced defines if the vertex buffer contains indexed data
  6972. * @param useBytes defines if the offset and stride are in bytes *
  6973. * @param divisor sets an optional divisor for instances (1 by default)
  6974. * @returns the new vertex buffer
  6975. */
  6976. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6977. /**
  6978. * Gets a boolean indicating if the Buffer is updatable?
  6979. * @returns true if the buffer is updatable
  6980. */
  6981. isUpdatable(): boolean;
  6982. /**
  6983. * Gets current buffer's data
  6984. * @returns a DataArray or null
  6985. */
  6986. getData(): Nullable<DataArray>;
  6987. /**
  6988. * Gets underlying native buffer
  6989. * @returns underlying native buffer
  6990. */
  6991. getBuffer(): Nullable<DataBuffer>;
  6992. /**
  6993. * Gets the stride in float32 units (i.e. byte stride / 4).
  6994. * May not be an integer if the byte stride is not divisible by 4.
  6995. * @returns the stride in float32 units
  6996. * @deprecated Please use byteStride instead.
  6997. */
  6998. getStrideSize(): number;
  6999. /**
  7000. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7001. * @param data defines the data to store
  7002. */
  7003. create(data?: Nullable<DataArray>): void;
  7004. /** @hidden */
  7005. _rebuild(): void;
  7006. /**
  7007. * Update current buffer data
  7008. * @param data defines the data to store
  7009. */
  7010. update(data: DataArray): void;
  7011. /**
  7012. * Updates the data directly.
  7013. * @param data the new data
  7014. * @param offset the new offset
  7015. * @param vertexCount the vertex count (optional)
  7016. * @param useBytes set to true if the offset is in bytes
  7017. */
  7018. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7019. /** @hidden */
  7020. _increaseReferences(): void;
  7021. /**
  7022. * Release all resources
  7023. */
  7024. dispose(): void;
  7025. }
  7026. /**
  7027. * Specialized buffer used to store vertex data
  7028. */
  7029. export class VertexBuffer {
  7030. private static _Counter;
  7031. /** @hidden */
  7032. _buffer: Buffer;
  7033. private _kind;
  7034. private _size;
  7035. private _ownsBuffer;
  7036. private _instanced;
  7037. private _instanceDivisor;
  7038. /**
  7039. * The byte type.
  7040. */
  7041. static readonly BYTE: number;
  7042. /**
  7043. * The unsigned byte type.
  7044. */
  7045. static readonly UNSIGNED_BYTE: number;
  7046. /**
  7047. * The short type.
  7048. */
  7049. static readonly SHORT: number;
  7050. /**
  7051. * The unsigned short type.
  7052. */
  7053. static readonly UNSIGNED_SHORT: number;
  7054. /**
  7055. * The integer type.
  7056. */
  7057. static readonly INT: number;
  7058. /**
  7059. * The unsigned integer type.
  7060. */
  7061. static readonly UNSIGNED_INT: number;
  7062. /**
  7063. * The float type.
  7064. */
  7065. static readonly FLOAT: number;
  7066. /**
  7067. * Gets or sets the instance divisor when in instanced mode
  7068. */
  7069. get instanceDivisor(): number;
  7070. set instanceDivisor(value: number);
  7071. /**
  7072. * Gets the byte stride.
  7073. */
  7074. readonly byteStride: number;
  7075. /**
  7076. * Gets the byte offset.
  7077. */
  7078. readonly byteOffset: number;
  7079. /**
  7080. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7081. */
  7082. readonly normalized: boolean;
  7083. /**
  7084. * Gets the data type of each component in the array.
  7085. */
  7086. readonly type: number;
  7087. /**
  7088. * Gets the unique id of this vertex buffer
  7089. */
  7090. readonly uniqueId: number;
  7091. /**
  7092. * Constructor
  7093. * @param engine the engine
  7094. * @param data the data to use for this vertex buffer
  7095. * @param kind the vertex buffer kind
  7096. * @param updatable whether the data is updatable
  7097. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7098. * @param stride the stride (optional)
  7099. * @param instanced whether the buffer is instanced (optional)
  7100. * @param offset the offset of the data (optional)
  7101. * @param size the number of components (optional)
  7102. * @param type the type of the component (optional)
  7103. * @param normalized whether the data contains normalized data (optional)
  7104. * @param useBytes set to true if stride and offset are in bytes (optional)
  7105. * @param divisor defines the instance divisor to use (1 by default)
  7106. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7107. */
  7108. 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);
  7109. /** @hidden */
  7110. _rebuild(): void;
  7111. /**
  7112. * Returns the kind of the VertexBuffer (string)
  7113. * @returns a string
  7114. */
  7115. getKind(): string;
  7116. /**
  7117. * Gets a boolean indicating if the VertexBuffer is updatable?
  7118. * @returns true if the buffer is updatable
  7119. */
  7120. isUpdatable(): boolean;
  7121. /**
  7122. * Gets current buffer's data
  7123. * @returns a DataArray or null
  7124. */
  7125. getData(): Nullable<DataArray>;
  7126. /**
  7127. * Gets underlying native buffer
  7128. * @returns underlying native buffer
  7129. */
  7130. getBuffer(): Nullable<DataBuffer>;
  7131. /**
  7132. * Gets the stride in float32 units (i.e. byte stride / 4).
  7133. * May not be an integer if the byte stride is not divisible by 4.
  7134. * @returns the stride in float32 units
  7135. * @deprecated Please use byteStride instead.
  7136. */
  7137. getStrideSize(): number;
  7138. /**
  7139. * Returns the offset as a multiple of the type byte length.
  7140. * @returns the offset in bytes
  7141. * @deprecated Please use byteOffset instead.
  7142. */
  7143. getOffset(): number;
  7144. /**
  7145. * Returns the number of components per vertex attribute (integer)
  7146. * @returns the size in float
  7147. */
  7148. getSize(): number;
  7149. /**
  7150. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7151. * @returns true if this buffer is instanced
  7152. */
  7153. getIsInstanced(): boolean;
  7154. /**
  7155. * Returns the instancing divisor, zero for non-instanced (integer).
  7156. * @returns a number
  7157. */
  7158. getInstanceDivisor(): number;
  7159. /**
  7160. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7161. * @param data defines the data to store
  7162. */
  7163. create(data?: DataArray): void;
  7164. /**
  7165. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7166. * This function will create a new buffer if the current one is not updatable
  7167. * @param data defines the data to store
  7168. */
  7169. update(data: DataArray): void;
  7170. /**
  7171. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7172. * Returns the directly updated WebGLBuffer.
  7173. * @param data the new data
  7174. * @param offset the new offset
  7175. * @param useBytes set to true if the offset is in bytes
  7176. */
  7177. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7178. /**
  7179. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7180. */
  7181. dispose(): void;
  7182. /**
  7183. * Enumerates each value of this vertex buffer as numbers.
  7184. * @param count the number of values to enumerate
  7185. * @param callback the callback function called for each value
  7186. */
  7187. forEach(count: number, callback: (value: number, index: number) => void): void;
  7188. /**
  7189. * Positions
  7190. */
  7191. static readonly PositionKind: string;
  7192. /**
  7193. * Normals
  7194. */
  7195. static readonly NormalKind: string;
  7196. /**
  7197. * Tangents
  7198. */
  7199. static readonly TangentKind: string;
  7200. /**
  7201. * Texture coordinates
  7202. */
  7203. static readonly UVKind: string;
  7204. /**
  7205. * Texture coordinates 2
  7206. */
  7207. static readonly UV2Kind: string;
  7208. /**
  7209. * Texture coordinates 3
  7210. */
  7211. static readonly UV3Kind: string;
  7212. /**
  7213. * Texture coordinates 4
  7214. */
  7215. static readonly UV4Kind: string;
  7216. /**
  7217. * Texture coordinates 5
  7218. */
  7219. static readonly UV5Kind: string;
  7220. /**
  7221. * Texture coordinates 6
  7222. */
  7223. static readonly UV6Kind: string;
  7224. /**
  7225. * Colors
  7226. */
  7227. static readonly ColorKind: string;
  7228. /**
  7229. * Matrix indices (for bones)
  7230. */
  7231. static readonly MatricesIndicesKind: string;
  7232. /**
  7233. * Matrix weights (for bones)
  7234. */
  7235. static readonly MatricesWeightsKind: string;
  7236. /**
  7237. * Additional matrix indices (for bones)
  7238. */
  7239. static readonly MatricesIndicesExtraKind: string;
  7240. /**
  7241. * Additional matrix weights (for bones)
  7242. */
  7243. static readonly MatricesWeightsExtraKind: string;
  7244. /**
  7245. * Deduces the stride given a kind.
  7246. * @param kind The kind string to deduce
  7247. * @returns The deduced stride
  7248. */
  7249. static DeduceStride(kind: string): number;
  7250. /**
  7251. * Gets the byte length of the given type.
  7252. * @param type the type
  7253. * @returns the number of bytes
  7254. */
  7255. static GetTypeByteLength(type: number): number;
  7256. /**
  7257. * Enumerates each value of the given parameters as numbers.
  7258. * @param data the data to enumerate
  7259. * @param byteOffset the byte offset of the data
  7260. * @param byteStride the byte stride of the data
  7261. * @param componentCount the number of components per element
  7262. * @param componentType the type of the component
  7263. * @param count the number of values to enumerate
  7264. * @param normalized whether the data is normalized
  7265. * @param callback the callback function called for each value
  7266. */
  7267. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7268. private static _GetFloatValue;
  7269. }
  7270. }
  7271. declare module BABYLON {
  7272. /**
  7273. * @hidden
  7274. */
  7275. export class IntersectionInfo {
  7276. bu: Nullable<number>;
  7277. bv: Nullable<number>;
  7278. distance: number;
  7279. faceId: number;
  7280. subMeshId: number;
  7281. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7282. }
  7283. }
  7284. declare module BABYLON {
  7285. /**
  7286. * Class used to store bounding sphere information
  7287. */
  7288. export class BoundingSphere {
  7289. /**
  7290. * Gets the center of the bounding sphere in local space
  7291. */
  7292. readonly center: Vector3;
  7293. /**
  7294. * Radius of the bounding sphere in local space
  7295. */
  7296. radius: number;
  7297. /**
  7298. * Gets the center of the bounding sphere in world space
  7299. */
  7300. readonly centerWorld: Vector3;
  7301. /**
  7302. * Radius of the bounding sphere in world space
  7303. */
  7304. radiusWorld: number;
  7305. /**
  7306. * Gets the minimum vector in local space
  7307. */
  7308. readonly minimum: Vector3;
  7309. /**
  7310. * Gets the maximum vector in local space
  7311. */
  7312. readonly maximum: Vector3;
  7313. private _worldMatrix;
  7314. private static readonly TmpVector3;
  7315. /**
  7316. * Creates a new bounding sphere
  7317. * @param min defines the minimum vector (in local space)
  7318. * @param max defines the maximum vector (in local space)
  7319. * @param worldMatrix defines the new world matrix
  7320. */
  7321. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7322. /**
  7323. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7324. * @param min defines the new minimum vector (in local space)
  7325. * @param max defines the new maximum vector (in local space)
  7326. * @param worldMatrix defines the new world matrix
  7327. */
  7328. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7329. /**
  7330. * Scale the current bounding sphere by applying a scale factor
  7331. * @param factor defines the scale factor to apply
  7332. * @returns the current bounding box
  7333. */
  7334. scale(factor: number): BoundingSphere;
  7335. /**
  7336. * Gets the world matrix of the bounding box
  7337. * @returns a matrix
  7338. */
  7339. getWorldMatrix(): DeepImmutable<Matrix>;
  7340. /** @hidden */
  7341. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7342. /**
  7343. * Tests if the bounding sphere is intersecting the frustum planes
  7344. * @param frustumPlanes defines the frustum planes to test
  7345. * @returns true if there is an intersection
  7346. */
  7347. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /**
  7349. * Tests if the bounding sphere center is in between the frustum planes.
  7350. * Used for optimistic fast inclusion.
  7351. * @param frustumPlanes defines the frustum planes to test
  7352. * @returns true if the sphere center is in between the frustum planes
  7353. */
  7354. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7355. /**
  7356. * Tests if a point is inside the bounding sphere
  7357. * @param point defines the point to test
  7358. * @returns true if the point is inside the bounding sphere
  7359. */
  7360. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7361. /**
  7362. * Checks if two sphere intersct
  7363. * @param sphere0 sphere 0
  7364. * @param sphere1 sphere 1
  7365. * @returns true if the speres intersect
  7366. */
  7367. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7368. }
  7369. }
  7370. declare module BABYLON {
  7371. /**
  7372. * Class used to store bounding box information
  7373. */
  7374. export class BoundingBox implements ICullable {
  7375. /**
  7376. * Gets the 8 vectors representing the bounding box in local space
  7377. */
  7378. readonly vectors: Vector3[];
  7379. /**
  7380. * Gets the center of the bounding box in local space
  7381. */
  7382. readonly center: Vector3;
  7383. /**
  7384. * Gets the center of the bounding box in world space
  7385. */
  7386. readonly centerWorld: Vector3;
  7387. /**
  7388. * Gets the extend size in local space
  7389. */
  7390. readonly extendSize: Vector3;
  7391. /**
  7392. * Gets the extend size in world space
  7393. */
  7394. readonly extendSizeWorld: Vector3;
  7395. /**
  7396. * Gets the OBB (object bounding box) directions
  7397. */
  7398. readonly directions: Vector3[];
  7399. /**
  7400. * Gets the 8 vectors representing the bounding box in world space
  7401. */
  7402. readonly vectorsWorld: Vector3[];
  7403. /**
  7404. * Gets the minimum vector in world space
  7405. */
  7406. readonly minimumWorld: Vector3;
  7407. /**
  7408. * Gets the maximum vector in world space
  7409. */
  7410. readonly maximumWorld: Vector3;
  7411. /**
  7412. * Gets the minimum vector in local space
  7413. */
  7414. readonly minimum: Vector3;
  7415. /**
  7416. * Gets the maximum vector in local space
  7417. */
  7418. readonly maximum: Vector3;
  7419. private _worldMatrix;
  7420. private static readonly TmpVector3;
  7421. /**
  7422. * @hidden
  7423. */
  7424. _tag: number;
  7425. /**
  7426. * Creates a new bounding box
  7427. * @param min defines the minimum vector (in local space)
  7428. * @param max defines the maximum vector (in local space)
  7429. * @param worldMatrix defines the new world matrix
  7430. */
  7431. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7432. /**
  7433. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7434. * @param min defines the new minimum vector (in local space)
  7435. * @param max defines the new maximum vector (in local space)
  7436. * @param worldMatrix defines the new world matrix
  7437. */
  7438. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7439. /**
  7440. * Scale the current bounding box by applying a scale factor
  7441. * @param factor defines the scale factor to apply
  7442. * @returns the current bounding box
  7443. */
  7444. scale(factor: number): BoundingBox;
  7445. /**
  7446. * Gets the world matrix of the bounding box
  7447. * @returns a matrix
  7448. */
  7449. getWorldMatrix(): DeepImmutable<Matrix>;
  7450. /** @hidden */
  7451. _update(world: DeepImmutable<Matrix>): void;
  7452. /**
  7453. * Tests if the bounding box is intersecting the frustum planes
  7454. * @param frustumPlanes defines the frustum planes to test
  7455. * @returns true if there is an intersection
  7456. */
  7457. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7458. /**
  7459. * Tests if the bounding box is entirely inside the frustum planes
  7460. * @param frustumPlanes defines the frustum planes to test
  7461. * @returns true if there is an inclusion
  7462. */
  7463. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7464. /**
  7465. * Tests if a point is inside the bounding box
  7466. * @param point defines the point to test
  7467. * @returns true if the point is inside the bounding box
  7468. */
  7469. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7470. /**
  7471. * Tests if the bounding box intersects with a bounding sphere
  7472. * @param sphere defines the sphere to test
  7473. * @returns true if there is an intersection
  7474. */
  7475. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7476. /**
  7477. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7478. * @param min defines the min vector to use
  7479. * @param max defines the max vector to use
  7480. * @returns true if there is an intersection
  7481. */
  7482. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7483. /**
  7484. * Tests if two bounding boxes are intersections
  7485. * @param box0 defines the first box to test
  7486. * @param box1 defines the second box to test
  7487. * @returns true if there is an intersection
  7488. */
  7489. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7490. /**
  7491. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7492. * @param minPoint defines the minimum vector of the bounding box
  7493. * @param maxPoint defines the maximum vector of the bounding box
  7494. * @param sphereCenter defines the sphere center
  7495. * @param sphereRadius defines the sphere radius
  7496. * @returns true if there is an intersection
  7497. */
  7498. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7499. /**
  7500. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7501. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7502. * @param frustumPlanes defines the frustum planes to test
  7503. * @return true if there is an inclusion
  7504. */
  7505. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7506. /**
  7507. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7508. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7509. * @param frustumPlanes defines the frustum planes to test
  7510. * @return true if there is an intersection
  7511. */
  7512. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7513. }
  7514. }
  7515. declare module BABYLON {
  7516. /** @hidden */
  7517. export class Collider {
  7518. /** Define if a collision was found */
  7519. collisionFound: boolean;
  7520. /**
  7521. * Define last intersection point in local space
  7522. */
  7523. intersectionPoint: Vector3;
  7524. /**
  7525. * Define last collided mesh
  7526. */
  7527. collidedMesh: Nullable<AbstractMesh>;
  7528. private _collisionPoint;
  7529. private _planeIntersectionPoint;
  7530. private _tempVector;
  7531. private _tempVector2;
  7532. private _tempVector3;
  7533. private _tempVector4;
  7534. private _edge;
  7535. private _baseToVertex;
  7536. private _destinationPoint;
  7537. private _slidePlaneNormal;
  7538. private _displacementVector;
  7539. /** @hidden */
  7540. _radius: Vector3;
  7541. /** @hidden */
  7542. _retry: number;
  7543. private _velocity;
  7544. private _basePoint;
  7545. private _epsilon;
  7546. /** @hidden */
  7547. _velocityWorldLength: number;
  7548. /** @hidden */
  7549. _basePointWorld: Vector3;
  7550. private _velocityWorld;
  7551. private _normalizedVelocity;
  7552. /** @hidden */
  7553. _initialVelocity: Vector3;
  7554. /** @hidden */
  7555. _initialPosition: Vector3;
  7556. private _nearestDistance;
  7557. private _collisionMask;
  7558. get collisionMask(): number;
  7559. set collisionMask(mask: number);
  7560. /**
  7561. * Gets the plane normal used to compute the sliding response (in local space)
  7562. */
  7563. get slidePlaneNormal(): Vector3;
  7564. /** @hidden */
  7565. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7566. /** @hidden */
  7567. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7568. /** @hidden */
  7569. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7570. /** @hidden */
  7571. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7572. /** @hidden */
  7573. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7574. /** @hidden */
  7575. _getResponse(pos: Vector3, vel: Vector3): void;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Interface for cullable objects
  7581. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7582. */
  7583. export interface ICullable {
  7584. /**
  7585. * Checks if the object or part of the object is in the frustum
  7586. * @param frustumPlanes Camera near/planes
  7587. * @returns true if the object is in frustum otherwise false
  7588. */
  7589. isInFrustum(frustumPlanes: Plane[]): boolean;
  7590. /**
  7591. * Checks if a cullable object (mesh...) is in the camera frustum
  7592. * Unlike isInFrustum this cheks the full bounding box
  7593. * @param frustumPlanes Camera near/planes
  7594. * @returns true if the object is in frustum otherwise false
  7595. */
  7596. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7597. }
  7598. /**
  7599. * Info for a bounding data of a mesh
  7600. */
  7601. export class BoundingInfo implements ICullable {
  7602. /**
  7603. * Bounding box for the mesh
  7604. */
  7605. readonly boundingBox: BoundingBox;
  7606. /**
  7607. * Bounding sphere for the mesh
  7608. */
  7609. readonly boundingSphere: BoundingSphere;
  7610. private _isLocked;
  7611. private static readonly TmpVector3;
  7612. /**
  7613. * Constructs bounding info
  7614. * @param minimum min vector of the bounding box/sphere
  7615. * @param maximum max vector of the bounding box/sphere
  7616. * @param worldMatrix defines the new world matrix
  7617. */
  7618. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7619. /**
  7620. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7621. * @param min defines the new minimum vector (in local space)
  7622. * @param max defines the new maximum vector (in local space)
  7623. * @param worldMatrix defines the new world matrix
  7624. */
  7625. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7626. /**
  7627. * min vector of the bounding box/sphere
  7628. */
  7629. get minimum(): Vector3;
  7630. /**
  7631. * max vector of the bounding box/sphere
  7632. */
  7633. get maximum(): Vector3;
  7634. /**
  7635. * If the info is locked and won't be updated to avoid perf overhead
  7636. */
  7637. get isLocked(): boolean;
  7638. set isLocked(value: boolean);
  7639. /**
  7640. * Updates the bounding sphere and box
  7641. * @param world world matrix to be used to update
  7642. */
  7643. update(world: DeepImmutable<Matrix>): void;
  7644. /**
  7645. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7646. * @param center New center of the bounding info
  7647. * @param extend New extend of the bounding info
  7648. * @returns the current bounding info
  7649. */
  7650. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7651. /**
  7652. * Grows the bounding info to include the given point.
  7653. * @param point The point that will be included in the current bounding info
  7654. * @returns the current bounding info
  7655. */
  7656. encapsulate(point: Vector3): BoundingInfo;
  7657. /**
  7658. * Grows the bounding info to encapsulate the given bounding info.
  7659. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7660. * @returns the current bounding info
  7661. */
  7662. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7663. /**
  7664. * Scale the current bounding info by applying a scale factor
  7665. * @param factor defines the scale factor to apply
  7666. * @returns the current bounding info
  7667. */
  7668. scale(factor: number): BoundingInfo;
  7669. /**
  7670. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7671. * @param frustumPlanes defines the frustum to test
  7672. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7673. * @returns true if the bounding info is in the frustum planes
  7674. */
  7675. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7676. /**
  7677. * Gets the world distance between the min and max points of the bounding box
  7678. */
  7679. get diagonalLength(): number;
  7680. /**
  7681. * Checks if a cullable object (mesh...) is in the camera frustum
  7682. * Unlike isInFrustum this cheks the full bounding box
  7683. * @param frustumPlanes Camera near/planes
  7684. * @returns true if the object is in frustum otherwise false
  7685. */
  7686. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7687. /** @hidden */
  7688. _checkCollision(collider: Collider): boolean;
  7689. /**
  7690. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7691. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7692. * @param point the point to check intersection with
  7693. * @returns if the point intersects
  7694. */
  7695. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7696. /**
  7697. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7698. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7699. * @param boundingInfo the bounding info to check intersection with
  7700. * @param precise if the intersection should be done using OBB
  7701. * @returns if the bounding info intersects
  7702. */
  7703. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7704. }
  7705. }
  7706. declare module BABYLON {
  7707. /**
  7708. * Extracts minimum and maximum values from a list of indexed positions
  7709. * @param positions defines the positions to use
  7710. * @param indices defines the indices to the positions
  7711. * @param indexStart defines the start index
  7712. * @param indexCount defines the end index
  7713. * @param bias defines bias value to add to the result
  7714. * @return minimum and maximum values
  7715. */
  7716. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7717. minimum: Vector3;
  7718. maximum: Vector3;
  7719. };
  7720. /**
  7721. * Extracts minimum and maximum values from a list of positions
  7722. * @param positions defines the positions to use
  7723. * @param start defines the start index in the positions array
  7724. * @param count defines the number of positions to handle
  7725. * @param bias defines bias value to add to the result
  7726. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7727. * @return minimum and maximum values
  7728. */
  7729. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7730. minimum: Vector3;
  7731. maximum: Vector3;
  7732. };
  7733. }
  7734. declare module BABYLON {
  7735. /**
  7736. * Class used to manipulate GUIDs
  7737. */
  7738. export class GUID {
  7739. /**
  7740. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7741. * Be aware Math.random() could cause collisions, but:
  7742. * "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"
  7743. * @returns a pseudo random id
  7744. */
  7745. static RandomId(): string;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Base class of all the textures in babylon.
  7751. * It groups all the common properties the materials, post process, lights... might need
  7752. * in order to make a correct use of the texture.
  7753. */
  7754. export class BaseTexture extends ThinTexture implements IAnimatable {
  7755. /**
  7756. * Default anisotropic filtering level for the application.
  7757. * It is set to 4 as a good tradeoff between perf and quality.
  7758. */
  7759. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7760. /**
  7761. * Gets or sets the unique id of the texture
  7762. */
  7763. uniqueId: number;
  7764. /**
  7765. * Define the name of the texture.
  7766. */
  7767. name: string;
  7768. /**
  7769. * Gets or sets an object used to store user defined information.
  7770. */
  7771. metadata: any;
  7772. /**
  7773. * For internal use only. Please do not use.
  7774. */
  7775. reservedDataStore: any;
  7776. private _hasAlpha;
  7777. /**
  7778. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7779. */
  7780. set hasAlpha(value: boolean);
  7781. get hasAlpha(): boolean;
  7782. /**
  7783. * Defines if the alpha value should be determined via the rgb values.
  7784. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7785. */
  7786. getAlphaFromRGB: boolean;
  7787. /**
  7788. * Intensity or strength of the texture.
  7789. * It is commonly used by materials to fine tune the intensity of the texture
  7790. */
  7791. level: number;
  7792. /**
  7793. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7794. * This is part of the texture as textures usually maps to one uv set.
  7795. */
  7796. coordinatesIndex: number;
  7797. protected _coordinatesMode: number;
  7798. /**
  7799. * How a texture is mapped.
  7800. *
  7801. * | Value | Type | Description |
  7802. * | ----- | ----------------------------------- | ----------- |
  7803. * | 0 | EXPLICIT_MODE | |
  7804. * | 1 | SPHERICAL_MODE | |
  7805. * | 2 | PLANAR_MODE | |
  7806. * | 3 | CUBIC_MODE | |
  7807. * | 4 | PROJECTION_MODE | |
  7808. * | 5 | SKYBOX_MODE | |
  7809. * | 6 | INVCUBIC_MODE | |
  7810. * | 7 | EQUIRECTANGULAR_MODE | |
  7811. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7812. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7813. */
  7814. set coordinatesMode(value: number);
  7815. get coordinatesMode(): number;
  7816. /**
  7817. * | Value | Type | Description |
  7818. * | ----- | ------------------ | ----------- |
  7819. * | 0 | CLAMP_ADDRESSMODE | |
  7820. * | 1 | WRAP_ADDRESSMODE | |
  7821. * | 2 | MIRROR_ADDRESSMODE | |
  7822. */
  7823. get wrapU(): number;
  7824. set wrapU(value: number);
  7825. /**
  7826. * | Value | Type | Description |
  7827. * | ----- | ------------------ | ----------- |
  7828. * | 0 | CLAMP_ADDRESSMODE | |
  7829. * | 1 | WRAP_ADDRESSMODE | |
  7830. * | 2 | MIRROR_ADDRESSMODE | |
  7831. */
  7832. get wrapV(): number;
  7833. set wrapV(value: number);
  7834. /**
  7835. * | Value | Type | Description |
  7836. * | ----- | ------------------ | ----------- |
  7837. * | 0 | CLAMP_ADDRESSMODE | |
  7838. * | 1 | WRAP_ADDRESSMODE | |
  7839. * | 2 | MIRROR_ADDRESSMODE | |
  7840. */
  7841. wrapR: number;
  7842. /**
  7843. * With compliant hardware and browser (supporting anisotropic filtering)
  7844. * this defines the level of anisotropic filtering in the texture.
  7845. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7846. */
  7847. anisotropicFilteringLevel: number;
  7848. private _isCube;
  7849. /**
  7850. * Define if the texture is a cube texture or if false a 2d texture.
  7851. */
  7852. get isCube(): boolean;
  7853. set isCube(value: boolean);
  7854. /**
  7855. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7856. */
  7857. get is3D(): boolean;
  7858. set is3D(value: boolean);
  7859. /**
  7860. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7861. */
  7862. get is2DArray(): boolean;
  7863. set is2DArray(value: boolean);
  7864. private _gammaSpace;
  7865. /**
  7866. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7867. * HDR texture are usually stored in linear space.
  7868. * This only impacts the PBR and Background materials
  7869. */
  7870. get gammaSpace(): boolean;
  7871. set gammaSpace(gamma: boolean);
  7872. /**
  7873. * Gets or sets whether or not the texture contains RGBD data.
  7874. */
  7875. get isRGBD(): boolean;
  7876. set isRGBD(value: boolean);
  7877. /**
  7878. * Is Z inverted in the texture (useful in a cube texture).
  7879. */
  7880. invertZ: boolean;
  7881. /**
  7882. * Are mip maps generated for this texture or not.
  7883. */
  7884. get noMipmap(): boolean;
  7885. /**
  7886. * @hidden
  7887. */
  7888. lodLevelInAlpha: boolean;
  7889. /**
  7890. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7891. */
  7892. get lodGenerationOffset(): number;
  7893. set lodGenerationOffset(value: number);
  7894. /**
  7895. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7896. */
  7897. get lodGenerationScale(): number;
  7898. set lodGenerationScale(value: number);
  7899. /**
  7900. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7901. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7902. * average roughness values.
  7903. */
  7904. get linearSpecularLOD(): boolean;
  7905. set linearSpecularLOD(value: boolean);
  7906. /**
  7907. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7908. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7909. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7910. */
  7911. get irradianceTexture(): Nullable<BaseTexture>;
  7912. set irradianceTexture(value: Nullable<BaseTexture>);
  7913. /**
  7914. * Define if the texture is a render target.
  7915. */
  7916. isRenderTarget: boolean;
  7917. /**
  7918. * Define the unique id of the texture in the scene.
  7919. */
  7920. get uid(): string;
  7921. /** @hidden */
  7922. _prefiltered: boolean;
  7923. /**
  7924. * Return a string representation of the texture.
  7925. * @returns the texture as a string
  7926. */
  7927. toString(): string;
  7928. /**
  7929. * Get the class name of the texture.
  7930. * @returns "BaseTexture"
  7931. */
  7932. getClassName(): string;
  7933. /**
  7934. * Define the list of animation attached to the texture.
  7935. */
  7936. animations: Animation[];
  7937. /**
  7938. * An event triggered when the texture is disposed.
  7939. */
  7940. onDisposeObservable: Observable<BaseTexture>;
  7941. private _onDisposeObserver;
  7942. /**
  7943. * Callback triggered when the texture has been disposed.
  7944. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7945. */
  7946. set onDispose(callback: () => void);
  7947. protected _scene: Nullable<Scene>;
  7948. /** @hidden */
  7949. _texture: Nullable<InternalTexture>;
  7950. private _uid;
  7951. /**
  7952. * Define if the texture is preventinga material to render or not.
  7953. * If not and the texture is not ready, the engine will use a default black texture instead.
  7954. */
  7955. get isBlocking(): boolean;
  7956. /**
  7957. * Instantiates a new BaseTexture.
  7958. * Base class of all the textures in babylon.
  7959. * It groups all the common properties the materials, post process, lights... might need
  7960. * in order to make a correct use of the texture.
  7961. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7962. */
  7963. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7964. /**
  7965. * Get the scene the texture belongs to.
  7966. * @returns the scene or null if undefined
  7967. */
  7968. getScene(): Nullable<Scene>;
  7969. /** @hidden */
  7970. protected _getEngine(): Nullable<ThinEngine>;
  7971. /**
  7972. * Checks if the texture has the same transform matrix than another texture
  7973. * @param texture texture to check against
  7974. * @returns true if the transforms are the same, else false
  7975. */
  7976. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7977. /**
  7978. * Get the texture transform matrix used to offset tile the texture for istance.
  7979. * @returns the transformation matrix
  7980. */
  7981. getTextureMatrix(): Matrix;
  7982. /**
  7983. * Get the texture reflection matrix used to rotate/transform the reflection.
  7984. * @returns the reflection matrix
  7985. */
  7986. getReflectionTextureMatrix(): Matrix;
  7987. /**
  7988. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7989. * @returns true if ready or not blocking
  7990. */
  7991. isReadyOrNotBlocking(): boolean;
  7992. /**
  7993. * Scales the texture if is `canRescale()`
  7994. * @param ratio the resize factor we want to use to rescale
  7995. */
  7996. scale(ratio: number): void;
  7997. /**
  7998. * Get if the texture can rescale.
  7999. */
  8000. get canRescale(): boolean;
  8001. /** @hidden */
  8002. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8003. /** @hidden */
  8004. _rebuild(): void;
  8005. /**
  8006. * Clones the texture.
  8007. * @returns the cloned texture
  8008. */
  8009. clone(): Nullable<BaseTexture>;
  8010. /**
  8011. * Get the texture underlying type (INT, FLOAT...)
  8012. */
  8013. get textureType(): number;
  8014. /**
  8015. * Get the texture underlying format (RGB, RGBA...)
  8016. */
  8017. get textureFormat(): number;
  8018. /**
  8019. * Indicates that textures need to be re-calculated for all materials
  8020. */
  8021. protected _markAllSubMeshesAsTexturesDirty(): void;
  8022. /**
  8023. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8024. * This will returns an RGBA array buffer containing either in values (0-255) or
  8025. * float values (0-1) depending of the underlying buffer type.
  8026. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8027. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8028. * @param buffer defines a user defined buffer to fill with data (can be null)
  8029. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8030. * @returns The Array buffer promise containing the pixels data.
  8031. */
  8032. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8033. /** @hidden */
  8034. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8035. /** @hidden */
  8036. get _lodTextureHigh(): Nullable<BaseTexture>;
  8037. /** @hidden */
  8038. get _lodTextureMid(): Nullable<BaseTexture>;
  8039. /** @hidden */
  8040. get _lodTextureLow(): Nullable<BaseTexture>;
  8041. /**
  8042. * Dispose the texture and release its associated resources.
  8043. */
  8044. dispose(): void;
  8045. /**
  8046. * Serialize the texture into a JSON representation that can be parsed later on.
  8047. * @returns the JSON representation of the texture
  8048. */
  8049. serialize(): any;
  8050. /**
  8051. * Helper function to be called back once a list of texture contains only ready textures.
  8052. * @param textures Define the list of textures to wait for
  8053. * @param callback Define the callback triggered once the entire list will be ready
  8054. */
  8055. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8056. private static _isScene;
  8057. }
  8058. }
  8059. declare module BABYLON {
  8060. /** @hidden */
  8061. export class WebGLDataBuffer extends DataBuffer {
  8062. private _buffer;
  8063. constructor(resource: WebGLBuffer);
  8064. get underlyingResource(): any;
  8065. }
  8066. }
  8067. declare module BABYLON {
  8068. /** @hidden */
  8069. export class WebGLPipelineContext implements IPipelineContext {
  8070. private _valueCache;
  8071. private _uniforms;
  8072. engine: ThinEngine;
  8073. program: Nullable<WebGLProgram>;
  8074. context?: WebGLRenderingContext;
  8075. vertexShader?: WebGLShader;
  8076. fragmentShader?: WebGLShader;
  8077. isParallelCompiled: boolean;
  8078. onCompiled?: () => void;
  8079. transformFeedback?: WebGLTransformFeedback | null;
  8080. vertexCompilationError: Nullable<string>;
  8081. fragmentCompilationError: Nullable<string>;
  8082. programLinkError: Nullable<string>;
  8083. programValidationError: Nullable<string>;
  8084. get isAsync(): boolean;
  8085. get isReady(): boolean;
  8086. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8087. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8088. [key: string]: number;
  8089. }, uniformsNames: string[], uniforms: {
  8090. [key: string]: Nullable<WebGLUniformLocation>;
  8091. }, samplerList: string[], samplers: {
  8092. [key: string]: number;
  8093. }, attributesNames: string[], attributes: number[]): void;
  8094. /**
  8095. * Release all associated resources.
  8096. **/
  8097. dispose(): void;
  8098. /** @hidden */
  8099. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8100. /** @hidden */
  8101. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8102. /** @hidden */
  8103. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8104. /** @hidden */
  8105. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8106. /**
  8107. * Sets an interger value on a uniform variable.
  8108. * @param uniformName Name of the variable.
  8109. * @param value Value to be set.
  8110. */
  8111. setInt(uniformName: string, value: number): void;
  8112. /**
  8113. * Sets a int2 on a uniform variable.
  8114. * @param uniformName Name of the variable.
  8115. * @param x First int in int2.
  8116. * @param y Second int in int2.
  8117. */
  8118. setInt2(uniformName: string, x: number, y: number): void;
  8119. /**
  8120. * Sets a int3 on a uniform variable.
  8121. * @param uniformName Name of the variable.
  8122. * @param x First int in int3.
  8123. * @param y Second int in int3.
  8124. * @param y Third int in int3.
  8125. */
  8126. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8127. /**
  8128. * Sets a int4 on a uniform variable.
  8129. * @param uniformName Name of the variable.
  8130. * @param x First int in int4.
  8131. * @param y Second int in int4.
  8132. * @param y Third int in int4.
  8133. * @param w Fourth int in int4.
  8134. */
  8135. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8136. /**
  8137. * Sets an int array on a uniform variable.
  8138. * @param uniformName Name of the variable.
  8139. * @param array array to be set.
  8140. */
  8141. setIntArray(uniformName: string, array: Int32Array): void;
  8142. /**
  8143. * 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)
  8144. * @param uniformName Name of the variable.
  8145. * @param array array to be set.
  8146. */
  8147. setIntArray2(uniformName: string, array: Int32Array): void;
  8148. /**
  8149. * 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)
  8150. * @param uniformName Name of the variable.
  8151. * @param array array to be set.
  8152. */
  8153. setIntArray3(uniformName: string, array: Int32Array): void;
  8154. /**
  8155. * 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)
  8156. * @param uniformName Name of the variable.
  8157. * @param array array to be set.
  8158. */
  8159. setIntArray4(uniformName: string, array: Int32Array): void;
  8160. /**
  8161. * Sets an array on a uniform variable.
  8162. * @param uniformName Name of the variable.
  8163. * @param array array to be set.
  8164. */
  8165. setArray(uniformName: string, array: number[]): void;
  8166. /**
  8167. * 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)
  8168. * @param uniformName Name of the variable.
  8169. * @param array array to be set.
  8170. */
  8171. setArray2(uniformName: string, array: number[]): void;
  8172. /**
  8173. * 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)
  8174. * @param uniformName Name of the variable.
  8175. * @param array array to be set.
  8176. * @returns this effect.
  8177. */
  8178. setArray3(uniformName: string, array: number[]): void;
  8179. /**
  8180. * 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)
  8181. * @param uniformName Name of the variable.
  8182. * @param array array to be set.
  8183. */
  8184. setArray4(uniformName: string, array: number[]): void;
  8185. /**
  8186. * Sets matrices on a uniform variable.
  8187. * @param uniformName Name of the variable.
  8188. * @param matrices matrices to be set.
  8189. */
  8190. setMatrices(uniformName: string, matrices: Float32Array): void;
  8191. /**
  8192. * Sets matrix on a uniform variable.
  8193. * @param uniformName Name of the variable.
  8194. * @param matrix matrix to be set.
  8195. */
  8196. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8197. /**
  8198. * 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)
  8199. * @param uniformName Name of the variable.
  8200. * @param matrix matrix to be set.
  8201. */
  8202. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8203. /**
  8204. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8205. * @param uniformName Name of the variable.
  8206. * @param matrix matrix to be set.
  8207. */
  8208. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8209. /**
  8210. * Sets a float on a uniform variable.
  8211. * @param uniformName Name of the variable.
  8212. * @param value value to be set.
  8213. * @returns this effect.
  8214. */
  8215. setFloat(uniformName: string, value: number): void;
  8216. /**
  8217. * Sets a Vector2 on a uniform variable.
  8218. * @param uniformName Name of the variable.
  8219. * @param vector2 vector2 to be set.
  8220. */
  8221. setVector2(uniformName: string, vector2: IVector2Like): void;
  8222. /**
  8223. * Sets a float2 on a uniform variable.
  8224. * @param uniformName Name of the variable.
  8225. * @param x First float in float2.
  8226. * @param y Second float in float2.
  8227. */
  8228. setFloat2(uniformName: string, x: number, y: number): void;
  8229. /**
  8230. * Sets a Vector3 on a uniform variable.
  8231. * @param uniformName Name of the variable.
  8232. * @param vector3 Value to be set.
  8233. */
  8234. setVector3(uniformName: string, vector3: IVector3Like): void;
  8235. /**
  8236. * Sets a float3 on a uniform variable.
  8237. * @param uniformName Name of the variable.
  8238. * @param x First float in float3.
  8239. * @param y Second float in float3.
  8240. * @param z Third float in float3.
  8241. */
  8242. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8243. /**
  8244. * Sets a Vector4 on a uniform variable.
  8245. * @param uniformName Name of the variable.
  8246. * @param vector4 Value to be set.
  8247. */
  8248. setVector4(uniformName: string, vector4: IVector4Like): void;
  8249. /**
  8250. * Sets a float4 on a uniform variable.
  8251. * @param uniformName Name of the variable.
  8252. * @param x First float in float4.
  8253. * @param y Second float in float4.
  8254. * @param z Third float in float4.
  8255. * @param w Fourth float in float4.
  8256. * @returns this effect.
  8257. */
  8258. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8259. /**
  8260. * Sets a Color3 on a uniform variable.
  8261. * @param uniformName Name of the variable.
  8262. * @param color3 Value to be set.
  8263. */
  8264. setColor3(uniformName: string, color3: IColor3Like): void;
  8265. /**
  8266. * Sets a Color4 on a uniform variable.
  8267. * @param uniformName Name of the variable.
  8268. * @param color3 Value to be set.
  8269. * @param alpha Alpha value to be set.
  8270. */
  8271. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8272. /**
  8273. * Sets a Color4 on a uniform variable
  8274. * @param uniformName defines the name of the variable
  8275. * @param color4 defines the value to be set
  8276. */
  8277. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8278. _getVertexShaderCode(): string | null;
  8279. _getFragmentShaderCode(): string | null;
  8280. }
  8281. }
  8282. declare module BABYLON {
  8283. interface ThinEngine {
  8284. /**
  8285. * Create an uniform buffer
  8286. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8287. * @param elements defines the content of the uniform buffer
  8288. * @returns the webGL uniform buffer
  8289. */
  8290. createUniformBuffer(elements: FloatArray): DataBuffer;
  8291. /**
  8292. * Create a dynamic uniform buffer
  8293. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8294. * @param elements defines the content of the uniform buffer
  8295. * @returns the webGL uniform buffer
  8296. */
  8297. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8298. /**
  8299. * Update an existing uniform buffer
  8300. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8301. * @param uniformBuffer defines the target uniform buffer
  8302. * @param elements defines the content to update
  8303. * @param offset defines the offset in the uniform buffer where update should start
  8304. * @param count defines the size of the data to update
  8305. */
  8306. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8307. /**
  8308. * Bind an uniform buffer to the current webGL context
  8309. * @param buffer defines the buffer to bind
  8310. */
  8311. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8312. /**
  8313. * Bind a buffer to the current webGL context at a given location
  8314. * @param buffer defines the buffer to bind
  8315. * @param location defines the index where to bind the buffer
  8316. * @param name Name of the uniform variable to bind
  8317. */
  8318. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8319. /**
  8320. * Bind a specific block at a given index in a specific shader program
  8321. * @param pipelineContext defines the pipeline context to use
  8322. * @param blockName defines the block name
  8323. * @param index defines the index where to bind the block
  8324. */
  8325. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8326. }
  8327. }
  8328. declare module BABYLON {
  8329. /**
  8330. * Uniform buffer objects.
  8331. *
  8332. * Handles blocks of uniform on the GPU.
  8333. *
  8334. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8335. *
  8336. * For more information, please refer to :
  8337. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8338. */
  8339. export class UniformBuffer {
  8340. /** @hidden */
  8341. static _updatedUbosInFrame: {
  8342. [name: string]: number;
  8343. };
  8344. private _engine;
  8345. private _buffer;
  8346. private _buffers;
  8347. private _bufferIndex;
  8348. private _createBufferOnWrite;
  8349. private _data;
  8350. private _bufferData;
  8351. private _dynamic?;
  8352. private _uniformLocations;
  8353. private _uniformSizes;
  8354. private _uniformArraySizes;
  8355. private _uniformLocationPointer;
  8356. private _needSync;
  8357. private _noUBO;
  8358. private _currentEffect;
  8359. private _currentEffectName;
  8360. private _name;
  8361. private _currentFrameId;
  8362. /** @hidden */
  8363. _alreadyBound: boolean;
  8364. private static _MAX_UNIFORM_SIZE;
  8365. private static _tempBuffer;
  8366. private static _tempBufferInt32View;
  8367. /**
  8368. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8373. /**
  8374. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8379. /**
  8380. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  8385. /**
  8386. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8391. /**
  8392. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8397. /**
  8398. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8403. /**
  8404. * Lambda to Update an array of float 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. updateFloatArray: (name: string, array: Float32Array) => void;
  8409. /**
  8410. * Lambda to Update an array of number 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. updateArray: (name: string, array: number[]) => void;
  8415. /**
  8416. * Lambda to Update an array of number 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. updateIntArray: (name: string, array: Int32Array) => void;
  8421. /**
  8422. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8427. /**
  8428. * Lambda to Update an array of 4x4 Matrix 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. updateMatrices: (name: string, mat: Float32Array) => void;
  8433. /**
  8434. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  8439. /**
  8440. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  8445. /**
  8446. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8447. * This is dynamic to allow compat with webgl 1 and 2.
  8448. * You will need to pass the name of the uniform as well as the value.
  8449. */
  8450. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8451. /**
  8452. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8453. * This is dynamic to allow compat with webgl 1 and 2.
  8454. * You will need to pass the name of the uniform as well as the value.
  8455. */
  8456. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8457. /**
  8458. * Lambda to Update a int a uniform buffer.
  8459. * This is dynamic to allow compat with webgl 1 and 2.
  8460. * You will need to pass the name of the uniform as well as the value.
  8461. */
  8462. updateInt: (name: string, x: number, suffix?: string) => void;
  8463. /**
  8464. * Lambda to Update a vec2 of int in a uniform buffer.
  8465. * This is dynamic to allow compat with webgl 1 and 2.
  8466. * You will need to pass the name of the uniform as well as the value.
  8467. */
  8468. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8469. /**
  8470. * Lambda to Update a vec3 of int in a uniform buffer.
  8471. * This is dynamic to allow compat with webgl 1 and 2.
  8472. * You will need to pass the name of the uniform as well as the value.
  8473. */
  8474. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8475. /**
  8476. * Lambda to Update a vec4 of int in a uniform buffer.
  8477. * This is dynamic to allow compat with webgl 1 and 2.
  8478. * You will need to pass the name of the uniform as well as the value.
  8479. */
  8480. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8481. /**
  8482. * Instantiates a new Uniform buffer objects.
  8483. *
  8484. * Handles blocks of uniform on the GPU.
  8485. *
  8486. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8487. *
  8488. * For more information, please refer to :
  8489. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8490. * @param engine Define the engine the buffer is associated with
  8491. * @param data Define the data contained in the buffer
  8492. * @param dynamic Define if the buffer is updatable
  8493. * @param name to assign to the buffer (debugging purpose)
  8494. */
  8495. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8496. /**
  8497. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8498. * or just falling back on setUniformXXX calls.
  8499. */
  8500. get useUbo(): boolean;
  8501. /**
  8502. * Indicates if the WebGL underlying uniform buffer is in sync
  8503. * with the javascript cache data.
  8504. */
  8505. get isSync(): boolean;
  8506. /**
  8507. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8508. * Also, a dynamic UniformBuffer will disable cache verification and always
  8509. * update the underlying WebGL uniform buffer to the GPU.
  8510. * @returns if Dynamic, otherwise false
  8511. */
  8512. isDynamic(): boolean;
  8513. /**
  8514. * The data cache on JS side.
  8515. * @returns the underlying data as a float array
  8516. */
  8517. getData(): Float32Array;
  8518. /**
  8519. * The underlying WebGL Uniform buffer.
  8520. * @returns the webgl buffer
  8521. */
  8522. getBuffer(): Nullable<DataBuffer>;
  8523. /**
  8524. * std140 layout specifies how to align data within an UBO structure.
  8525. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8526. * for specs.
  8527. */
  8528. private _fillAlignment;
  8529. /**
  8530. * Adds an uniform in the buffer.
  8531. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8532. * for the layout to be correct !
  8533. * @param name Name of the uniform, as used in the uniform block in the shader.
  8534. * @param size Data size, or data directly.
  8535. * @param arraySize The number of elements in the array, 0 if not an array.
  8536. */
  8537. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8538. /**
  8539. * Adds a Matrix 4x4 to the uniform buffer.
  8540. * @param name Name of the uniform, as used in the uniform block in the shader.
  8541. * @param mat A 4x4 matrix.
  8542. */
  8543. addMatrix(name: string, mat: Matrix): void;
  8544. /**
  8545. * Adds a vec2 to the uniform buffer.
  8546. * @param name Name of the uniform, as used in the uniform block in the shader.
  8547. * @param x Define the x component value of the vec2
  8548. * @param y Define the y component value of the vec2
  8549. */
  8550. addFloat2(name: string, x: number, y: number): void;
  8551. /**
  8552. * Adds a vec3 to the uniform buffer.
  8553. * @param name Name of the uniform, as used in the uniform block in the shader.
  8554. * @param x Define the x component value of the vec3
  8555. * @param y Define the y component value of the vec3
  8556. * @param z Define the z component value of the vec3
  8557. */
  8558. addFloat3(name: string, x: number, y: number, z: number): void;
  8559. /**
  8560. * Adds a vec3 to the uniform buffer.
  8561. * @param name Name of the uniform, as used in the uniform block in the shader.
  8562. * @param color Define the vec3 from a Color
  8563. */
  8564. addColor3(name: string, color: Color3): void;
  8565. /**
  8566. * Adds a vec4 to the uniform buffer.
  8567. * @param name Name of the uniform, as used in the uniform block in the shader.
  8568. * @param color Define the rgb components from a Color
  8569. * @param alpha Define the a component of the vec4
  8570. */
  8571. addColor4(name: string, color: Color3, alpha: number): void;
  8572. /**
  8573. * Adds a vec3 to the uniform buffer.
  8574. * @param name Name of the uniform, as used in the uniform block in the shader.
  8575. * @param vector Define the vec3 components from a Vector
  8576. */
  8577. addVector3(name: string, vector: Vector3): void;
  8578. /**
  8579. * Adds a Matrix 3x3 to the uniform buffer.
  8580. * @param name Name of the uniform, as used in the uniform block in the shader.
  8581. */
  8582. addMatrix3x3(name: string): void;
  8583. /**
  8584. * Adds a Matrix 2x2 to the uniform buffer.
  8585. * @param name Name of the uniform, as used in the uniform block in the shader.
  8586. */
  8587. addMatrix2x2(name: string): void;
  8588. /**
  8589. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8590. */
  8591. create(): void;
  8592. /** @hidden */
  8593. _rebuild(): void;
  8594. /** @hidden */
  8595. get _numBuffers(): number;
  8596. /** @hidden */
  8597. get _indexBuffer(): number;
  8598. /** Gets the name of this buffer */
  8599. get name(): string;
  8600. /**
  8601. * Updates the WebGL Uniform Buffer on the GPU.
  8602. * If the `dynamic` flag is set to true, no cache comparison is done.
  8603. * Otherwise, the buffer will be updated only if the cache differs.
  8604. */
  8605. update(): void;
  8606. private _createNewBuffer;
  8607. private _checkNewFrame;
  8608. /**
  8609. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8610. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8611. * @param data Define the flattened data
  8612. * @param size Define the size of the data.
  8613. */
  8614. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8615. /**
  8616. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8617. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8618. * @param data Define the flattened data
  8619. * @param size Define the size of the data.
  8620. */
  8621. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8622. private _valueCache;
  8623. private _cacheMatrix;
  8624. private _updateMatrix3x3ForUniform;
  8625. private _updateMatrix3x3ForEffect;
  8626. private _updateMatrix2x2ForEffect;
  8627. private _updateMatrix2x2ForUniform;
  8628. private _updateFloatForEffect;
  8629. private _updateFloatForUniform;
  8630. private _updateFloat2ForEffect;
  8631. private _updateFloat2ForUniform;
  8632. private _updateFloat3ForEffect;
  8633. private _updateFloat3ForUniform;
  8634. private _updateFloat4ForEffect;
  8635. private _updateFloat4ForUniform;
  8636. private _updateFloatArrayForEffect;
  8637. private _updateFloatArrayForUniform;
  8638. private _updateArrayForEffect;
  8639. private _updateArrayForUniform;
  8640. private _updateIntArrayForEffect;
  8641. private _updateIntArrayForUniform;
  8642. private _updateMatrixForEffect;
  8643. private _updateMatrixForUniform;
  8644. private _updateMatricesForEffect;
  8645. private _updateMatricesForUniform;
  8646. private _updateVector3ForEffect;
  8647. private _updateVector3ForUniform;
  8648. private _updateVector4ForEffect;
  8649. private _updateVector4ForUniform;
  8650. private _updateColor3ForEffect;
  8651. private _updateColor3ForUniform;
  8652. private _updateColor4ForEffect;
  8653. private _updateColor4ForUniform;
  8654. private _updateIntForEffect;
  8655. private _updateIntForUniform;
  8656. private _updateInt2ForEffect;
  8657. private _updateInt2ForUniform;
  8658. private _updateInt3ForEffect;
  8659. private _updateInt3ForUniform;
  8660. private _updateInt4ForEffect;
  8661. private _updateInt4ForUniform;
  8662. /**
  8663. * Sets a sampler uniform on the effect.
  8664. * @param name Define the name of the sampler.
  8665. * @param texture Define the texture to set in the sampler
  8666. */
  8667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8668. /**
  8669. * Directly updates the value of the uniform in the cache AND on the GPU.
  8670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8671. * @param data Define the flattened data
  8672. */
  8673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8674. /**
  8675. * Binds this uniform buffer to an effect.
  8676. * @param effect Define the effect to bind the buffer to
  8677. * @param name Name of the uniform block in the shader.
  8678. */
  8679. bindToEffect(effect: Effect, name: string): void;
  8680. /**
  8681. * Disposes the uniform buffer.
  8682. */
  8683. dispose(): void;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * Manages the defines for the Material
  8689. */
  8690. export class MaterialDefines {
  8691. /** @hidden */
  8692. protected _keys: string[];
  8693. private _isDirty;
  8694. /** @hidden */
  8695. _renderId: number;
  8696. /** @hidden */
  8697. _areLightsDirty: boolean;
  8698. /** @hidden */
  8699. _areLightsDisposed: boolean;
  8700. /** @hidden */
  8701. _areAttributesDirty: boolean;
  8702. /** @hidden */
  8703. _areTexturesDirty: boolean;
  8704. /** @hidden */
  8705. _areFresnelDirty: boolean;
  8706. /** @hidden */
  8707. _areMiscDirty: boolean;
  8708. /** @hidden */
  8709. _arePrePassDirty: boolean;
  8710. /** @hidden */
  8711. _areImageProcessingDirty: boolean;
  8712. /** @hidden */
  8713. _normals: boolean;
  8714. /** @hidden */
  8715. _uvs: boolean;
  8716. /** @hidden */
  8717. _needNormals: boolean;
  8718. /** @hidden */
  8719. _needUVs: boolean;
  8720. [id: string]: any;
  8721. /**
  8722. * Specifies if the material needs to be re-calculated
  8723. */
  8724. get isDirty(): boolean;
  8725. /**
  8726. * Marks the material to indicate that it has been re-calculated
  8727. */
  8728. markAsProcessed(): void;
  8729. /**
  8730. * Marks the material to indicate that it needs to be re-calculated
  8731. */
  8732. markAsUnprocessed(): void;
  8733. /**
  8734. * Marks the material to indicate all of its defines need to be re-calculated
  8735. */
  8736. markAllAsDirty(): void;
  8737. /**
  8738. * Marks the material to indicate that image processing needs to be re-calculated
  8739. */
  8740. markAsImageProcessingDirty(): void;
  8741. /**
  8742. * Marks the material to indicate the lights need to be re-calculated
  8743. * @param disposed Defines whether the light is dirty due to dispose or not
  8744. */
  8745. markAsLightDirty(disposed?: boolean): void;
  8746. /**
  8747. * Marks the attribute state as changed
  8748. */
  8749. markAsAttributesDirty(): void;
  8750. /**
  8751. * Marks the texture state as changed
  8752. */
  8753. markAsTexturesDirty(): void;
  8754. /**
  8755. * Marks the fresnel state as changed
  8756. */
  8757. markAsFresnelDirty(): void;
  8758. /**
  8759. * Marks the misc state as changed
  8760. */
  8761. markAsMiscDirty(): void;
  8762. /**
  8763. * Marks the prepass state as changed
  8764. */
  8765. markAsPrePassDirty(): void;
  8766. /**
  8767. * Rebuilds the material defines
  8768. */
  8769. rebuild(): void;
  8770. /**
  8771. * Specifies if two material defines are equal
  8772. * @param other - A material define instance to compare to
  8773. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8774. */
  8775. isEqual(other: MaterialDefines): boolean;
  8776. /**
  8777. * Clones this instance's defines to another instance
  8778. * @param other - material defines to clone values to
  8779. */
  8780. cloneTo(other: MaterialDefines): void;
  8781. /**
  8782. * Resets the material define values
  8783. */
  8784. reset(): void;
  8785. /**
  8786. * Converts the material define values to a string
  8787. * @returns - String of material define information
  8788. */
  8789. toString(): string;
  8790. }
  8791. }
  8792. declare module BABYLON {
  8793. /**
  8794. * Enum that determines the text-wrapping mode to use.
  8795. */
  8796. export enum InspectableType {
  8797. /**
  8798. * Checkbox for booleans
  8799. */
  8800. Checkbox = 0,
  8801. /**
  8802. * Sliders for numbers
  8803. */
  8804. Slider = 1,
  8805. /**
  8806. * Vector3
  8807. */
  8808. Vector3 = 2,
  8809. /**
  8810. * Quaternions
  8811. */
  8812. Quaternion = 3,
  8813. /**
  8814. * Color3
  8815. */
  8816. Color3 = 4,
  8817. /**
  8818. * String
  8819. */
  8820. String = 5
  8821. }
  8822. /**
  8823. * Interface used to define custom inspectable properties.
  8824. * This interface is used by the inspector to display custom property grids
  8825. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8826. */
  8827. export interface IInspectable {
  8828. /**
  8829. * Gets the label to display
  8830. */
  8831. label: string;
  8832. /**
  8833. * Gets the name of the property to edit
  8834. */
  8835. propertyName: string;
  8836. /**
  8837. * Gets the type of the editor to use
  8838. */
  8839. type: InspectableType;
  8840. /**
  8841. * Gets the minimum value of the property when using in "slider" mode
  8842. */
  8843. min?: number;
  8844. /**
  8845. * Gets the maximum value of the property when using in "slider" mode
  8846. */
  8847. max?: number;
  8848. /**
  8849. * Gets the setp to use when using in "slider" mode
  8850. */
  8851. step?: number;
  8852. }
  8853. }
  8854. declare module BABYLON {
  8855. /**
  8856. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8857. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8858. * 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.
  8859. */
  8860. export abstract class Light extends Node {
  8861. /**
  8862. * Falloff Default: light is falling off following the material specification:
  8863. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8864. */
  8865. static readonly FALLOFF_DEFAULT: number;
  8866. /**
  8867. * Falloff Physical: light is falling off following the inverse squared distance law.
  8868. */
  8869. static readonly FALLOFF_PHYSICAL: number;
  8870. /**
  8871. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8872. * to enhance interoperability with other engines.
  8873. */
  8874. static readonly FALLOFF_GLTF: number;
  8875. /**
  8876. * Falloff Standard: light is falling off like in the standard material
  8877. * to enhance interoperability with other materials.
  8878. */
  8879. static readonly FALLOFF_STANDARD: number;
  8880. /**
  8881. * If every light affecting the material is in this lightmapMode,
  8882. * material.lightmapTexture adds or multiplies
  8883. * (depends on material.useLightmapAsShadowmap)
  8884. * after every other light calculations.
  8885. */
  8886. static readonly LIGHTMAP_DEFAULT: number;
  8887. /**
  8888. * material.lightmapTexture as only diffuse lighting from this light
  8889. * adds only specular lighting from this light
  8890. * adds dynamic shadows
  8891. */
  8892. static readonly LIGHTMAP_SPECULAR: number;
  8893. /**
  8894. * material.lightmapTexture as only lighting
  8895. * no light calculation from this light
  8896. * only adds dynamic shadows from this light
  8897. */
  8898. static readonly LIGHTMAP_SHADOWSONLY: number;
  8899. /**
  8900. * Each light type uses the default quantity according to its type:
  8901. * point/spot lights use luminous intensity
  8902. * directional lights use illuminance
  8903. */
  8904. static readonly INTENSITYMODE_AUTOMATIC: number;
  8905. /**
  8906. * lumen (lm)
  8907. */
  8908. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8909. /**
  8910. * candela (lm/sr)
  8911. */
  8912. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8913. /**
  8914. * lux (lm/m^2)
  8915. */
  8916. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8917. /**
  8918. * nit (cd/m^2)
  8919. */
  8920. static readonly INTENSITYMODE_LUMINANCE: number;
  8921. /**
  8922. * Light type const id of the point light.
  8923. */
  8924. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8925. /**
  8926. * Light type const id of the directional light.
  8927. */
  8928. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8929. /**
  8930. * Light type const id of the spot light.
  8931. */
  8932. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8933. /**
  8934. * Light type const id of the hemispheric light.
  8935. */
  8936. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8937. /**
  8938. * Diffuse gives the basic color to an object.
  8939. */
  8940. diffuse: Color3;
  8941. /**
  8942. * Specular produces a highlight color on an object.
  8943. * Note: This is note affecting PBR materials.
  8944. */
  8945. specular: Color3;
  8946. /**
  8947. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8948. * falling off base on range or angle.
  8949. * This can be set to any values in Light.FALLOFF_x.
  8950. *
  8951. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8952. * other types of materials.
  8953. */
  8954. falloffType: number;
  8955. /**
  8956. * Strength of the light.
  8957. * Note: By default it is define in the framework own unit.
  8958. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8959. */
  8960. intensity: number;
  8961. private _range;
  8962. protected _inverseSquaredRange: number;
  8963. /**
  8964. * Defines how far from the source the light is impacting in scene units.
  8965. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8966. */
  8967. get range(): number;
  8968. /**
  8969. * Defines how far from the source the light is impacting in scene units.
  8970. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8971. */
  8972. set range(value: number);
  8973. /**
  8974. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8975. * of light.
  8976. */
  8977. private _photometricScale;
  8978. private _intensityMode;
  8979. /**
  8980. * Gets the photometric scale used to interpret the intensity.
  8981. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8982. */
  8983. get intensityMode(): number;
  8984. /**
  8985. * Sets the photometric scale used to interpret the intensity.
  8986. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8987. */
  8988. set intensityMode(value: number);
  8989. private _radius;
  8990. /**
  8991. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8992. */
  8993. get radius(): number;
  8994. /**
  8995. * sets the light radius used by PBR Materials to simulate soft area lights.
  8996. */
  8997. set radius(value: number);
  8998. private _renderPriority;
  8999. /**
  9000. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9001. * exceeding the number allowed of the materials.
  9002. */
  9003. renderPriority: number;
  9004. private _shadowEnabled;
  9005. /**
  9006. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9007. * the current shadow generator.
  9008. */
  9009. get shadowEnabled(): boolean;
  9010. /**
  9011. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9012. * the current shadow generator.
  9013. */
  9014. set shadowEnabled(value: boolean);
  9015. private _includedOnlyMeshes;
  9016. /**
  9017. * Gets the only meshes impacted by this light.
  9018. */
  9019. get includedOnlyMeshes(): AbstractMesh[];
  9020. /**
  9021. * Sets the only meshes impacted by this light.
  9022. */
  9023. set includedOnlyMeshes(value: AbstractMesh[]);
  9024. private _excludedMeshes;
  9025. /**
  9026. * Gets the meshes not impacted by this light.
  9027. */
  9028. get excludedMeshes(): AbstractMesh[];
  9029. /**
  9030. * Sets the meshes not impacted by this light.
  9031. */
  9032. set excludedMeshes(value: AbstractMesh[]);
  9033. private _excludeWithLayerMask;
  9034. /**
  9035. * Gets the layer id use to find what meshes are not impacted by the light.
  9036. * Inactive if 0
  9037. */
  9038. get excludeWithLayerMask(): number;
  9039. /**
  9040. * Sets the layer id use to find what meshes are not impacted by the light.
  9041. * Inactive if 0
  9042. */
  9043. set excludeWithLayerMask(value: number);
  9044. private _includeOnlyWithLayerMask;
  9045. /**
  9046. * Gets the layer id use to find what meshes are impacted by the light.
  9047. * Inactive if 0
  9048. */
  9049. get includeOnlyWithLayerMask(): number;
  9050. /**
  9051. * Sets the layer id use to find what meshes are impacted by the light.
  9052. * Inactive if 0
  9053. */
  9054. set includeOnlyWithLayerMask(value: number);
  9055. private _lightmapMode;
  9056. /**
  9057. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9058. */
  9059. get lightmapMode(): number;
  9060. /**
  9061. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9062. */
  9063. set lightmapMode(value: number);
  9064. /**
  9065. * Shadow generator associted to the light.
  9066. * @hidden Internal use only.
  9067. */
  9068. _shadowGenerator: Nullable<IShadowGenerator>;
  9069. /**
  9070. * @hidden Internal use only.
  9071. */
  9072. _excludedMeshesIds: string[];
  9073. /**
  9074. * @hidden Internal use only.
  9075. */
  9076. _includedOnlyMeshesIds: string[];
  9077. /**
  9078. * The current light unifom buffer.
  9079. * @hidden Internal use only.
  9080. */
  9081. _uniformBuffer: UniformBuffer;
  9082. /** @hidden */
  9083. _renderId: number;
  9084. /**
  9085. * Creates a Light object in the scene.
  9086. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9087. * @param name The firendly name of the light
  9088. * @param scene The scene the light belongs too
  9089. */
  9090. constructor(name: string, scene: Scene);
  9091. protected abstract _buildUniformLayout(): void;
  9092. /**
  9093. * Sets the passed Effect "effect" with the Light information.
  9094. * @param effect The effect to update
  9095. * @param lightIndex The index of the light in the effect to update
  9096. * @returns The light
  9097. */
  9098. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9099. /**
  9100. * Sets the passed Effect "effect" with the Light textures.
  9101. * @param effect The effect to update
  9102. * @param lightIndex The index of the light in the effect to update
  9103. * @returns The light
  9104. */
  9105. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9106. /**
  9107. * Binds the lights information from the scene to the effect for the given mesh.
  9108. * @param lightIndex Light index
  9109. * @param scene The scene where the light belongs to
  9110. * @param effect The effect we are binding the data to
  9111. * @param useSpecular Defines if specular is supported
  9112. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9113. */
  9114. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9115. /**
  9116. * Sets the passed Effect "effect" with the Light information.
  9117. * @param effect The effect to update
  9118. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9119. * @returns The light
  9120. */
  9121. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9122. /**
  9123. * Returns the string "Light".
  9124. * @returns the class name
  9125. */
  9126. getClassName(): string;
  9127. /** @hidden */
  9128. readonly _isLight: boolean;
  9129. /**
  9130. * Converts the light information to a readable string for debug purpose.
  9131. * @param fullDetails Supports for multiple levels of logging within scene loading
  9132. * @returns the human readable light info
  9133. */
  9134. toString(fullDetails?: boolean): string;
  9135. /** @hidden */
  9136. protected _syncParentEnabledState(): void;
  9137. /**
  9138. * Set the enabled state of this node.
  9139. * @param value - the new enabled state
  9140. */
  9141. setEnabled(value: boolean): void;
  9142. /**
  9143. * Returns the Light associated shadow generator if any.
  9144. * @return the associated shadow generator.
  9145. */
  9146. getShadowGenerator(): Nullable<IShadowGenerator>;
  9147. /**
  9148. * Returns a Vector3, the absolute light position in the World.
  9149. * @returns the world space position of the light
  9150. */
  9151. getAbsolutePosition(): Vector3;
  9152. /**
  9153. * Specifies if the light will affect the passed mesh.
  9154. * @param mesh The mesh to test against the light
  9155. * @return true the mesh is affected otherwise, false.
  9156. */
  9157. canAffectMesh(mesh: AbstractMesh): boolean;
  9158. /**
  9159. * Sort function to order lights for rendering.
  9160. * @param a First Light object to compare to second.
  9161. * @param b Second Light object to compare first.
  9162. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9163. */
  9164. static CompareLightsPriority(a: Light, b: Light): number;
  9165. /**
  9166. * Releases resources associated with this node.
  9167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9169. */
  9170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9171. /**
  9172. * Returns the light type ID (integer).
  9173. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9174. */
  9175. getTypeID(): number;
  9176. /**
  9177. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9178. * @returns the scaled intensity in intensity mode unit
  9179. */
  9180. getScaledIntensity(): number;
  9181. /**
  9182. * Returns a new Light object, named "name", from the current one.
  9183. * @param name The name of the cloned light
  9184. * @param newParent The parent of this light, if it has one
  9185. * @returns the new created light
  9186. */
  9187. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9188. /**
  9189. * Serializes the current light into a Serialization object.
  9190. * @returns the serialized object.
  9191. */
  9192. serialize(): any;
  9193. /**
  9194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9195. * This new light is named "name" and added to the passed scene.
  9196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9197. * @param name The friendly name of the light
  9198. * @param scene The scene the new light will belong to
  9199. * @returns the constructor function
  9200. */
  9201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9202. /**
  9203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9204. * @param parsedLight The JSON representation of the light
  9205. * @param scene The scene to create the parsed light in
  9206. * @returns the created light after parsing
  9207. */
  9208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9209. private _hookArrayForExcluded;
  9210. private _hookArrayForIncludedOnly;
  9211. private _resyncMeshes;
  9212. /**
  9213. * Forces the meshes to update their light related information in their rendering used effects
  9214. * @hidden Internal Use Only
  9215. */
  9216. _markMeshesAsLightDirty(): void;
  9217. /**
  9218. * Recomputes the cached photometric scale if needed.
  9219. */
  9220. private _computePhotometricScale;
  9221. /**
  9222. * Returns the Photometric Scale according to the light type and intensity mode.
  9223. */
  9224. private _getPhotometricScale;
  9225. /**
  9226. * Reorder the light in the scene according to their defined priority.
  9227. * @hidden Internal Use Only
  9228. */
  9229. _reorderLightsInScene(): void;
  9230. /**
  9231. * Prepares the list of defines specific to the light type.
  9232. * @param defines the list of defines
  9233. * @param lightIndex defines the index of the light for the effect
  9234. */
  9235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9236. }
  9237. }
  9238. declare module BABYLON {
  9239. /** Defines supported spaces */
  9240. export enum Space {
  9241. /** Local (object) space */
  9242. LOCAL = 0,
  9243. /** World space */
  9244. WORLD = 1,
  9245. /** Bone space */
  9246. BONE = 2
  9247. }
  9248. /** Defines the 3 main axes */
  9249. export class Axis {
  9250. /** X axis */
  9251. static X: Vector3;
  9252. /** Y axis */
  9253. static Y: Vector3;
  9254. /** Z axis */
  9255. static Z: Vector3;
  9256. }
  9257. /**
  9258. * Defines cartesian components.
  9259. */
  9260. export enum Coordinate {
  9261. /** X axis */
  9262. X = 0,
  9263. /** Y axis */
  9264. Y = 1,
  9265. /** Z axis */
  9266. Z = 2
  9267. }
  9268. }
  9269. declare module BABYLON {
  9270. /**
  9271. * Interface describing all the common properties and methods a shadow light needs to implement.
  9272. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9273. * as well as binding the different shadow properties to the effects.
  9274. */
  9275. export interface IShadowLight extends Light {
  9276. /**
  9277. * The light id in the scene (used in scene.findLighById for instance)
  9278. */
  9279. id: string;
  9280. /**
  9281. * The position the shdow will be casted from.
  9282. */
  9283. position: Vector3;
  9284. /**
  9285. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9286. */
  9287. direction: Vector3;
  9288. /**
  9289. * The transformed position. Position of the light in world space taking parenting in account.
  9290. */
  9291. transformedPosition: Vector3;
  9292. /**
  9293. * The transformed direction. Direction of the light in world space taking parenting in account.
  9294. */
  9295. transformedDirection: Vector3;
  9296. /**
  9297. * The friendly name of the light in the scene.
  9298. */
  9299. name: string;
  9300. /**
  9301. * Defines the shadow projection clipping minimum z value.
  9302. */
  9303. shadowMinZ: number;
  9304. /**
  9305. * Defines the shadow projection clipping maximum z value.
  9306. */
  9307. shadowMaxZ: number;
  9308. /**
  9309. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9310. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9311. */
  9312. computeTransformedInformation(): boolean;
  9313. /**
  9314. * Gets the scene the light belongs to.
  9315. * @returns The scene
  9316. */
  9317. getScene(): Scene;
  9318. /**
  9319. * Callback defining a custom Projection Matrix Builder.
  9320. * This can be used to override the default projection matrix computation.
  9321. */
  9322. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9323. /**
  9324. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9325. * @param matrix The materix to updated with the projection information
  9326. * @param viewMatrix The transform matrix of the light
  9327. * @param renderList The list of mesh to render in the map
  9328. * @returns The current light
  9329. */
  9330. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9331. /**
  9332. * Gets the current depth scale used in ESM.
  9333. * @returns The scale
  9334. */
  9335. getDepthScale(): number;
  9336. /**
  9337. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9338. * @returns true if a cube texture needs to be use
  9339. */
  9340. needCube(): boolean;
  9341. /**
  9342. * Detects if the projection matrix requires to be recomputed this frame.
  9343. * @returns true if it requires to be recomputed otherwise, false.
  9344. */
  9345. needProjectionMatrixCompute(): boolean;
  9346. /**
  9347. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9348. */
  9349. forceProjectionMatrixCompute(): void;
  9350. /**
  9351. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9352. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9353. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9354. */
  9355. getShadowDirection(faceIndex?: number): Vector3;
  9356. /**
  9357. * Gets the minZ used for shadow according to both the scene and the light.
  9358. * @param activeCamera The camera we are returning the min for
  9359. * @returns the depth min z
  9360. */
  9361. getDepthMinZ(activeCamera: Camera): number;
  9362. /**
  9363. * Gets the maxZ used for shadow according to both the scene and the light.
  9364. * @param activeCamera The camera we are returning the max for
  9365. * @returns the depth max z
  9366. */
  9367. getDepthMaxZ(activeCamera: Camera): number;
  9368. }
  9369. /**
  9370. * Base implementation IShadowLight
  9371. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9372. */
  9373. export abstract class ShadowLight extends Light implements IShadowLight {
  9374. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9375. protected _position: Vector3;
  9376. protected _setPosition(value: Vector3): void;
  9377. /**
  9378. * Sets the position the shadow will be casted from. Also use as the light position for both
  9379. * point and spot lights.
  9380. */
  9381. get position(): Vector3;
  9382. /**
  9383. * Sets the position the shadow will be casted from. Also use as the light position for both
  9384. * point and spot lights.
  9385. */
  9386. set position(value: Vector3);
  9387. protected _direction: Vector3;
  9388. protected _setDirection(value: Vector3): void;
  9389. /**
  9390. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9391. * Also use as the light direction on spot and directional lights.
  9392. */
  9393. get direction(): Vector3;
  9394. /**
  9395. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9396. * Also use as the light direction on spot and directional lights.
  9397. */
  9398. set direction(value: Vector3);
  9399. protected _shadowMinZ: number;
  9400. /**
  9401. * Gets the shadow projection clipping minimum z value.
  9402. */
  9403. get shadowMinZ(): number;
  9404. /**
  9405. * Sets the shadow projection clipping minimum z value.
  9406. */
  9407. set shadowMinZ(value: number);
  9408. protected _shadowMaxZ: number;
  9409. /**
  9410. * Sets the shadow projection clipping maximum z value.
  9411. */
  9412. get shadowMaxZ(): number;
  9413. /**
  9414. * Gets the shadow projection clipping maximum z value.
  9415. */
  9416. set shadowMaxZ(value: number);
  9417. /**
  9418. * Callback defining a custom Projection Matrix Builder.
  9419. * This can be used to override the default projection matrix computation.
  9420. */
  9421. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9422. /**
  9423. * The transformed position. Position of the light in world space taking parenting in account.
  9424. */
  9425. transformedPosition: Vector3;
  9426. /**
  9427. * The transformed direction. Direction of the light in world space taking parenting in account.
  9428. */
  9429. transformedDirection: Vector3;
  9430. private _needProjectionMatrixCompute;
  9431. /**
  9432. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9433. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9434. */
  9435. computeTransformedInformation(): boolean;
  9436. /**
  9437. * Return the depth scale used for the shadow map.
  9438. * @returns the depth scale.
  9439. */
  9440. getDepthScale(): number;
  9441. /**
  9442. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9443. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9444. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9445. */
  9446. getShadowDirection(faceIndex?: number): Vector3;
  9447. /**
  9448. * Returns the ShadowLight absolute position in the World.
  9449. * @returns the position vector in world space
  9450. */
  9451. getAbsolutePosition(): Vector3;
  9452. /**
  9453. * Sets the ShadowLight direction toward the passed target.
  9454. * @param target The point to target in local space
  9455. * @returns the updated ShadowLight direction
  9456. */
  9457. setDirectionToTarget(target: Vector3): Vector3;
  9458. /**
  9459. * Returns the light rotation in euler definition.
  9460. * @returns the x y z rotation in local space.
  9461. */
  9462. getRotation(): Vector3;
  9463. /**
  9464. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9465. * @returns true if a cube texture needs to be use
  9466. */
  9467. needCube(): boolean;
  9468. /**
  9469. * Detects if the projection matrix requires to be recomputed this frame.
  9470. * @returns true if it requires to be recomputed otherwise, false.
  9471. */
  9472. needProjectionMatrixCompute(): boolean;
  9473. /**
  9474. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9475. */
  9476. forceProjectionMatrixCompute(): void;
  9477. /** @hidden */
  9478. _initCache(): void;
  9479. /** @hidden */
  9480. _isSynchronized(): boolean;
  9481. /**
  9482. * Computes the world matrix of the node
  9483. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9484. * @returns the world matrix
  9485. */
  9486. computeWorldMatrix(force?: boolean): Matrix;
  9487. /**
  9488. * Gets the minZ used for shadow according to both the scene and the light.
  9489. * @param activeCamera The camera we are returning the min for
  9490. * @returns the depth min z
  9491. */
  9492. getDepthMinZ(activeCamera: Camera): number;
  9493. /**
  9494. * Gets the maxZ used for shadow according to both the scene and the light.
  9495. * @param activeCamera The camera we are returning the max for
  9496. * @returns the depth max z
  9497. */
  9498. getDepthMaxZ(activeCamera: Camera): number;
  9499. /**
  9500. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9501. * @param matrix The materix to updated with the projection information
  9502. * @param viewMatrix The transform matrix of the light
  9503. * @param renderList The list of mesh to render in the map
  9504. * @returns The current light
  9505. */
  9506. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9507. }
  9508. }
  9509. declare module BABYLON {
  9510. /**
  9511. * Configuration needed for prepass-capable materials
  9512. */
  9513. export class PrePassConfiguration {
  9514. /**
  9515. * Previous world matrices of meshes carrying this material
  9516. * Used for computing velocity
  9517. */
  9518. previousWorldMatrices: {
  9519. [index: number]: Matrix;
  9520. };
  9521. /**
  9522. * Previous view project matrix
  9523. * Used for computing velocity
  9524. */
  9525. previousViewProjection: Matrix;
  9526. /**
  9527. * Previous bones of meshes carrying this material
  9528. * Used for computing velocity
  9529. */
  9530. previousBones: {
  9531. [index: number]: Float32Array;
  9532. };
  9533. /**
  9534. * Add the required uniforms to the current list.
  9535. * @param uniforms defines the current uniform list.
  9536. */
  9537. static AddUniforms(uniforms: string[]): void;
  9538. /**
  9539. * Add the required samplers to the current list.
  9540. * @param samplers defines the current sampler list.
  9541. */
  9542. static AddSamplers(samplers: string[]): void;
  9543. /**
  9544. * Binds the material data.
  9545. * @param effect defines the effect to update
  9546. * @param scene defines the scene the material belongs to.
  9547. * @param mesh The mesh
  9548. * @param world World matrix of this mesh
  9549. * @param isFrozen Is the material frozen
  9550. */
  9551. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9552. }
  9553. }
  9554. declare module BABYLON {
  9555. /**
  9556. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9557. * This is the base of the follow, arc rotate cameras and Free camera
  9558. * @see https://doc.babylonjs.com/features/cameras
  9559. */
  9560. export class TargetCamera extends Camera {
  9561. private static _RigCamTransformMatrix;
  9562. private static _TargetTransformMatrix;
  9563. private static _TargetFocalPoint;
  9564. private _tmpUpVector;
  9565. private _tmpTargetVector;
  9566. /**
  9567. * Define the current direction the camera is moving to
  9568. */
  9569. cameraDirection: Vector3;
  9570. /**
  9571. * Define the current rotation the camera is rotating to
  9572. */
  9573. cameraRotation: Vector2;
  9574. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9575. ignoreParentScaling: boolean;
  9576. /**
  9577. * When set, the up vector of the camera will be updated by the rotation of the camera
  9578. */
  9579. updateUpVectorFromRotation: boolean;
  9580. private _tmpQuaternion;
  9581. /**
  9582. * Define the current rotation of the camera
  9583. */
  9584. rotation: Vector3;
  9585. /**
  9586. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9587. */
  9588. rotationQuaternion: Quaternion;
  9589. /**
  9590. * Define the current speed of the camera
  9591. */
  9592. speed: number;
  9593. /**
  9594. * Add constraint to the camera to prevent it to move freely in all directions and
  9595. * around all axis.
  9596. */
  9597. noRotationConstraint: boolean;
  9598. /**
  9599. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9600. * panning
  9601. */
  9602. invertRotation: boolean;
  9603. /**
  9604. * Speed multiplier for inverse camera panning
  9605. */
  9606. inverseRotationSpeed: number;
  9607. /**
  9608. * Define the current target of the camera as an object or a position.
  9609. */
  9610. lockedTarget: any;
  9611. /** @hidden */
  9612. _currentTarget: Vector3;
  9613. /** @hidden */
  9614. _initialFocalDistance: number;
  9615. /** @hidden */
  9616. _viewMatrix: Matrix;
  9617. /** @hidden */
  9618. _camMatrix: Matrix;
  9619. /** @hidden */
  9620. _cameraTransformMatrix: Matrix;
  9621. /** @hidden */
  9622. _cameraRotationMatrix: Matrix;
  9623. /** @hidden */
  9624. _referencePoint: Vector3;
  9625. /** @hidden */
  9626. _transformedReferencePoint: Vector3;
  9627. /** @hidden */
  9628. _reset: () => void;
  9629. private _defaultUp;
  9630. /**
  9631. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9632. * This is the base of the follow, arc rotate cameras and Free camera
  9633. * @see https://doc.babylonjs.com/features/cameras
  9634. * @param name Defines the name of the camera in the scene
  9635. * @param position Defines the start position of the camera in the scene
  9636. * @param scene Defines the scene the camera belongs to
  9637. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9638. */
  9639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9640. /**
  9641. * Gets the position in front of the camera at a given distance.
  9642. * @param distance The distance from the camera we want the position to be
  9643. * @returns the position
  9644. */
  9645. getFrontPosition(distance: number): Vector3;
  9646. /** @hidden */
  9647. _getLockedTargetPosition(): Nullable<Vector3>;
  9648. private _storedPosition;
  9649. private _storedRotation;
  9650. private _storedRotationQuaternion;
  9651. /**
  9652. * Store current camera state of the camera (fov, position, rotation, etc..)
  9653. * @returns the camera
  9654. */
  9655. storeState(): Camera;
  9656. /**
  9657. * Restored camera state. You must call storeState() first
  9658. * @returns whether it was successful or not
  9659. * @hidden
  9660. */
  9661. _restoreStateValues(): boolean;
  9662. /** @hidden */
  9663. _initCache(): void;
  9664. /** @hidden */
  9665. _updateCache(ignoreParentClass?: boolean): void;
  9666. /** @hidden */
  9667. _isSynchronizedViewMatrix(): boolean;
  9668. /** @hidden */
  9669. _computeLocalCameraSpeed(): number;
  9670. /**
  9671. * Defines the target the camera should look at.
  9672. * @param target Defines the new target as a Vector or a mesh
  9673. */
  9674. setTarget(target: Vector3): void;
  9675. /**
  9676. * Defines the target point of the camera.
  9677. * The camera looks towards it form the radius distance.
  9678. */
  9679. get target(): Vector3;
  9680. set target(value: Vector3);
  9681. /**
  9682. * Return the current target position of the camera. This value is expressed in local space.
  9683. * @returns the target position
  9684. */
  9685. getTarget(): Vector3;
  9686. /** @hidden */
  9687. _decideIfNeedsToMove(): boolean;
  9688. /** @hidden */
  9689. _updatePosition(): void;
  9690. /** @hidden */
  9691. _checkInputs(): void;
  9692. protected _updateCameraRotationMatrix(): void;
  9693. /**
  9694. * 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)
  9695. * @returns the current camera
  9696. */
  9697. private _rotateUpVectorWithCameraRotationMatrix;
  9698. private _cachedRotationZ;
  9699. private _cachedQuaternionRotationZ;
  9700. /** @hidden */
  9701. _getViewMatrix(): Matrix;
  9702. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9703. /**
  9704. * @hidden
  9705. */
  9706. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9707. /**
  9708. * @hidden
  9709. */
  9710. _updateRigCameras(): void;
  9711. private _getRigCamPositionAndTarget;
  9712. /**
  9713. * Gets the current object class name.
  9714. * @return the class name
  9715. */
  9716. getClassName(): string;
  9717. }
  9718. }
  9719. declare module BABYLON {
  9720. /**
  9721. * @ignore
  9722. * This is a list of all the different input types that are available in the application.
  9723. * Fo instance: ArcRotateCameraGamepadInput...
  9724. */
  9725. export var CameraInputTypes: {};
  9726. /**
  9727. * This is the contract to implement in order to create a new input class.
  9728. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9729. */
  9730. export interface ICameraInput<TCamera extends Camera> {
  9731. /**
  9732. * Defines the camera the input is attached to.
  9733. */
  9734. camera: Nullable<TCamera>;
  9735. /**
  9736. * Gets the class name of the current intput.
  9737. * @returns the class name
  9738. */
  9739. getClassName(): string;
  9740. /**
  9741. * Get the friendly name associated with the input class.
  9742. * @returns the input friendly name
  9743. */
  9744. getSimpleName(): string;
  9745. /**
  9746. * Attach the input controls to a specific dom element to get the input from.
  9747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9748. */
  9749. attachControl(noPreventDefault?: boolean): void;
  9750. /**
  9751. * Detach the current controls from the specified dom element.
  9752. */
  9753. detachControl(): void;
  9754. /**
  9755. * Update the current camera state depending on the inputs that have been used this frame.
  9756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9757. */
  9758. checkInputs?: () => void;
  9759. }
  9760. /**
  9761. * Represents a map of input types to input instance or input index to input instance.
  9762. */
  9763. export interface CameraInputsMap<TCamera extends Camera> {
  9764. /**
  9765. * Accessor to the input by input type.
  9766. */
  9767. [name: string]: ICameraInput<TCamera>;
  9768. /**
  9769. * Accessor to the input by input index.
  9770. */
  9771. [idx: number]: ICameraInput<TCamera>;
  9772. }
  9773. /**
  9774. * This represents the input manager used within a camera.
  9775. * It helps dealing with all the different kind of input attached to a camera.
  9776. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9777. */
  9778. export class CameraInputsManager<TCamera extends Camera> {
  9779. /**
  9780. * Defines the list of inputs attahed to the camera.
  9781. */
  9782. attached: CameraInputsMap<TCamera>;
  9783. /**
  9784. * Defines the dom element the camera is collecting inputs from.
  9785. * This is null if the controls have not been attached.
  9786. */
  9787. attachedToElement: boolean;
  9788. /**
  9789. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9790. */
  9791. noPreventDefault: boolean;
  9792. /**
  9793. * Defined the camera the input manager belongs to.
  9794. */
  9795. camera: TCamera;
  9796. /**
  9797. * Update the current camera state depending on the inputs that have been used this frame.
  9798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9799. */
  9800. checkInputs: () => void;
  9801. /**
  9802. * Instantiate a new Camera Input Manager.
  9803. * @param camera Defines the camera the input manager blongs to
  9804. */
  9805. constructor(camera: TCamera);
  9806. /**
  9807. * Add an input method to a camera
  9808. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9809. * @param input camera input method
  9810. */
  9811. add(input: ICameraInput<TCamera>): void;
  9812. /**
  9813. * Remove a specific input method from a camera
  9814. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9815. * @param inputToRemove camera input method
  9816. */
  9817. remove(inputToRemove: ICameraInput<TCamera>): void;
  9818. /**
  9819. * Remove a specific input type from a camera
  9820. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9821. * @param inputType the type of the input to remove
  9822. */
  9823. removeByType(inputType: string): void;
  9824. private _addCheckInputs;
  9825. /**
  9826. * Attach the input controls to the currently attached dom element to listen the events from.
  9827. * @param input Defines the input to attach
  9828. */
  9829. attachInput(input: ICameraInput<TCamera>): void;
  9830. /**
  9831. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9832. * @param element Defines the dom element to collect the events from
  9833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9834. */
  9835. attachElement(noPreventDefault?: boolean): void;
  9836. /**
  9837. * Detach the current manager inputs controls from a specific dom element.
  9838. * @param element Defines the dom element to collect the events from
  9839. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9840. */
  9841. detachElement(disconnect?: boolean): void;
  9842. /**
  9843. * Rebuild the dynamic inputCheck function from the current list of
  9844. * defined inputs in the manager.
  9845. */
  9846. rebuildInputCheck(): void;
  9847. /**
  9848. * Remove all attached input methods from a camera
  9849. */
  9850. clear(): void;
  9851. /**
  9852. * Serialize the current input manager attached to a camera.
  9853. * This ensures than once parsed,
  9854. * the input associated to the camera will be identical to the current ones
  9855. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9856. */
  9857. serialize(serializedCamera: any): void;
  9858. /**
  9859. * Parses an input manager serialized JSON to restore the previous list of inputs
  9860. * and states associated to a camera.
  9861. * @param parsedCamera Defines the JSON to parse
  9862. */
  9863. parse(parsedCamera: any): void;
  9864. }
  9865. }
  9866. declare module BABYLON {
  9867. /**
  9868. * Gather the list of keyboard event types as constants.
  9869. */
  9870. export class KeyboardEventTypes {
  9871. /**
  9872. * The keydown event is fired when a key becomes active (pressed).
  9873. */
  9874. static readonly KEYDOWN: number;
  9875. /**
  9876. * The keyup event is fired when a key has been released.
  9877. */
  9878. static readonly KEYUP: number;
  9879. }
  9880. /**
  9881. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9882. */
  9883. export class KeyboardInfo {
  9884. /**
  9885. * Defines the type of event (KeyboardEventTypes)
  9886. */
  9887. type: number;
  9888. /**
  9889. * Defines the related dom event
  9890. */
  9891. event: KeyboardEvent;
  9892. /**
  9893. * Instantiates a new keyboard info.
  9894. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9895. * @param type Defines the type of event (KeyboardEventTypes)
  9896. * @param event Defines the related dom event
  9897. */
  9898. constructor(
  9899. /**
  9900. * Defines the type of event (KeyboardEventTypes)
  9901. */
  9902. type: number,
  9903. /**
  9904. * Defines the related dom event
  9905. */
  9906. event: KeyboardEvent);
  9907. }
  9908. /**
  9909. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9910. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9911. */
  9912. export class KeyboardInfoPre extends KeyboardInfo {
  9913. /**
  9914. * Defines the type of event (KeyboardEventTypes)
  9915. */
  9916. type: number;
  9917. /**
  9918. * Defines the related dom event
  9919. */
  9920. event: KeyboardEvent;
  9921. /**
  9922. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9923. */
  9924. skipOnPointerObservable: boolean;
  9925. /**
  9926. * Instantiates a new keyboard pre info.
  9927. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9928. * @param type Defines the type of event (KeyboardEventTypes)
  9929. * @param event Defines the related dom event
  9930. */
  9931. constructor(
  9932. /**
  9933. * Defines the type of event (KeyboardEventTypes)
  9934. */
  9935. type: number,
  9936. /**
  9937. * Defines the related dom event
  9938. */
  9939. event: KeyboardEvent);
  9940. }
  9941. }
  9942. declare module BABYLON {
  9943. /**
  9944. * Manage the keyboard inputs to control the movement of a free camera.
  9945. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9946. */
  9947. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9948. /**
  9949. * Defines the camera the input is attached to.
  9950. */
  9951. camera: FreeCamera;
  9952. /**
  9953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9954. */
  9955. keysUp: number[];
  9956. /**
  9957. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9958. */
  9959. keysUpward: number[];
  9960. /**
  9961. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9962. */
  9963. keysDown: number[];
  9964. /**
  9965. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9966. */
  9967. keysDownward: number[];
  9968. /**
  9969. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9970. */
  9971. keysLeft: number[];
  9972. /**
  9973. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9974. */
  9975. keysRight: number[];
  9976. private _keys;
  9977. private _onCanvasBlurObserver;
  9978. private _onKeyboardObserver;
  9979. private _engine;
  9980. private _scene;
  9981. /**
  9982. * Attach the input controls to a specific dom element to get the input from.
  9983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9984. */
  9985. attachControl(noPreventDefault?: boolean): void;
  9986. /**
  9987. * Detach the current controls from the specified dom element.
  9988. */
  9989. detachControl(): void;
  9990. /**
  9991. * Update the current camera state depending on the inputs that have been used this frame.
  9992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9993. */
  9994. checkInputs(): void;
  9995. /**
  9996. * Gets the class name of the current intput.
  9997. * @returns the class name
  9998. */
  9999. getClassName(): string;
  10000. /** @hidden */
  10001. _onLostFocus(): void;
  10002. /**
  10003. * Get the friendly name associated with the input class.
  10004. * @returns the input friendly name
  10005. */
  10006. getSimpleName(): string;
  10007. }
  10008. }
  10009. declare module BABYLON {
  10010. /**
  10011. * Interface used to define Action
  10012. */
  10013. export interface IAction {
  10014. /**
  10015. * Trigger for the action
  10016. */
  10017. trigger: number;
  10018. /** Options of the trigger */
  10019. triggerOptions: any;
  10020. /**
  10021. * Gets the trigger parameters
  10022. * @returns the trigger parameters
  10023. */
  10024. getTriggerParameter(): any;
  10025. /**
  10026. * Internal only - executes current action event
  10027. * @hidden
  10028. */
  10029. _executeCurrent(evt?: ActionEvent): void;
  10030. /**
  10031. * Serialize placeholder for child classes
  10032. * @param parent of child
  10033. * @returns the serialized object
  10034. */
  10035. serialize(parent: any): any;
  10036. /**
  10037. * Internal only
  10038. * @hidden
  10039. */
  10040. _prepare(): void;
  10041. /**
  10042. * Internal only - manager for action
  10043. * @hidden
  10044. */
  10045. _actionManager: Nullable<AbstractActionManager>;
  10046. /**
  10047. * Adds action to chain of actions, may be a DoNothingAction
  10048. * @param action defines the next action to execute
  10049. * @returns The action passed in
  10050. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10051. */
  10052. then(action: IAction): IAction;
  10053. }
  10054. /**
  10055. * The action to be carried out following a trigger
  10056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10057. */
  10058. export class Action implements IAction {
  10059. /** the trigger, with or without parameters, for the action */
  10060. triggerOptions: any;
  10061. /**
  10062. * Trigger for the action
  10063. */
  10064. trigger: number;
  10065. /**
  10066. * Internal only - manager for action
  10067. * @hidden
  10068. */
  10069. _actionManager: ActionManager;
  10070. private _nextActiveAction;
  10071. private _child;
  10072. private _condition?;
  10073. private _triggerParameter;
  10074. /**
  10075. * An event triggered prior to action being executed.
  10076. */
  10077. onBeforeExecuteObservable: Observable<Action>;
  10078. /**
  10079. * Creates a new Action
  10080. * @param triggerOptions the trigger, with or without parameters, for the action
  10081. * @param condition an optional determinant of action
  10082. */
  10083. constructor(
  10084. /** the trigger, with or without parameters, for the action */
  10085. triggerOptions: any, condition?: Condition);
  10086. /**
  10087. * Internal only
  10088. * @hidden
  10089. */
  10090. _prepare(): void;
  10091. /**
  10092. * Gets the trigger parameter
  10093. * @returns the trigger parameter
  10094. */
  10095. getTriggerParameter(): any;
  10096. /**
  10097. * Sets the trigger parameter
  10098. * @param value defines the new trigger parameter
  10099. */
  10100. setTriggerParameter(value: any): void;
  10101. /**
  10102. * Internal only - executes current action event
  10103. * @hidden
  10104. */
  10105. _executeCurrent(evt?: ActionEvent): void;
  10106. /**
  10107. * Execute placeholder for child classes
  10108. * @param evt optional action event
  10109. */
  10110. execute(evt?: ActionEvent): void;
  10111. /**
  10112. * Skips to next active action
  10113. */
  10114. skipToNextActiveAction(): void;
  10115. /**
  10116. * Adds action to chain of actions, may be a DoNothingAction
  10117. * @param action defines the next action to execute
  10118. * @returns The action passed in
  10119. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10120. */
  10121. then(action: Action): Action;
  10122. /**
  10123. * Internal only
  10124. * @hidden
  10125. */
  10126. _getProperty(propertyPath: string): string;
  10127. /**
  10128. * Internal only
  10129. * @hidden
  10130. */
  10131. _getEffectiveTarget(target: any, propertyPath: string): any;
  10132. /**
  10133. * Serialize placeholder for child classes
  10134. * @param parent of child
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. /**
  10139. * Internal only called by serialize
  10140. * @hidden
  10141. */
  10142. protected _serialize(serializedAction: any, parent?: any): any;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. static _SerializeValueAsString: (value: any) => string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. static _GetTargetProperty: (target: Scene | Node) => {
  10153. name: string;
  10154. targetType: string;
  10155. value: string;
  10156. };
  10157. }
  10158. }
  10159. declare module BABYLON {
  10160. /**
  10161. * A Condition applied to an Action
  10162. */
  10163. export class Condition {
  10164. /**
  10165. * Internal only - manager for action
  10166. * @hidden
  10167. */
  10168. _actionManager: ActionManager;
  10169. /**
  10170. * Internal only
  10171. * @hidden
  10172. */
  10173. _evaluationId: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. _currentResult: boolean;
  10179. /**
  10180. * Creates a new Condition
  10181. * @param actionManager the manager of the action the condition is applied to
  10182. */
  10183. constructor(actionManager: ActionManager);
  10184. /**
  10185. * Check if the current condition is valid
  10186. * @returns a boolean
  10187. */
  10188. isValid(): boolean;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. _getProperty(propertyPath: string): string;
  10194. /**
  10195. * Internal only
  10196. * @hidden
  10197. */
  10198. _getEffectiveTarget(target: any, propertyPath: string): any;
  10199. /**
  10200. * Serialize placeholder for child classes
  10201. * @returns the serialized object
  10202. */
  10203. serialize(): any;
  10204. /**
  10205. * Internal only
  10206. * @hidden
  10207. */
  10208. protected _serialize(serializedCondition: any): any;
  10209. }
  10210. /**
  10211. * Defines specific conditional operators as extensions of Condition
  10212. */
  10213. export class ValueCondition extends Condition {
  10214. /** path to specify the property of the target the conditional operator uses */
  10215. propertyPath: string;
  10216. /** the value compared by the conditional operator against the current value of the property */
  10217. value: any;
  10218. /** the conditional operator, default ValueCondition.IsEqual */
  10219. operator: number;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private static _IsEqual;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private static _IsDifferent;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. private static _IsGreater;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. private static _IsLesser;
  10240. /**
  10241. * returns the number for IsEqual
  10242. */
  10243. static get IsEqual(): number;
  10244. /**
  10245. * Returns the number for IsDifferent
  10246. */
  10247. static get IsDifferent(): number;
  10248. /**
  10249. * Returns the number for IsGreater
  10250. */
  10251. static get IsGreater(): number;
  10252. /**
  10253. * Returns the number for IsLesser
  10254. */
  10255. static get IsLesser(): number;
  10256. /**
  10257. * Internal only The action manager for the condition
  10258. * @hidden
  10259. */
  10260. _actionManager: ActionManager;
  10261. /**
  10262. * Internal only
  10263. * @hidden
  10264. */
  10265. private _target;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. private _effectiveTarget;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. private _property;
  10276. /**
  10277. * Creates a new ValueCondition
  10278. * @param actionManager manager for the action the condition applies to
  10279. * @param target for the action
  10280. * @param propertyPath path to specify the property of the target the conditional operator uses
  10281. * @param value the value compared by the conditional operator against the current value of the property
  10282. * @param operator the conditional operator, default ValueCondition.IsEqual
  10283. */
  10284. constructor(actionManager: ActionManager, target: any,
  10285. /** path to specify the property of the target the conditional operator uses */
  10286. propertyPath: string,
  10287. /** the value compared by the conditional operator against the current value of the property */
  10288. value: any,
  10289. /** the conditional operator, default ValueCondition.IsEqual */
  10290. operator?: number);
  10291. /**
  10292. * Compares the given value with the property value for the specified conditional operator
  10293. * @returns the result of the comparison
  10294. */
  10295. isValid(): boolean;
  10296. /**
  10297. * Serialize the ValueCondition into a JSON compatible object
  10298. * @returns serialization object
  10299. */
  10300. serialize(): any;
  10301. /**
  10302. * Gets the name of the conditional operator for the ValueCondition
  10303. * @param operator the conditional operator
  10304. * @returns the name
  10305. */
  10306. static GetOperatorName(operator: number): string;
  10307. }
  10308. /**
  10309. * Defines a predicate condition as an extension of Condition
  10310. */
  10311. export class PredicateCondition extends Condition {
  10312. /** defines the predicate function used to validate the condition */
  10313. predicate: () => boolean;
  10314. /**
  10315. * Internal only - manager for action
  10316. * @hidden
  10317. */
  10318. _actionManager: ActionManager;
  10319. /**
  10320. * Creates a new PredicateCondition
  10321. * @param actionManager manager for the action the condition applies to
  10322. * @param predicate defines the predicate function used to validate the condition
  10323. */
  10324. constructor(actionManager: ActionManager,
  10325. /** defines the predicate function used to validate the condition */
  10326. predicate: () => boolean);
  10327. /**
  10328. * @returns the validity of the predicate condition
  10329. */
  10330. isValid(): boolean;
  10331. }
  10332. /**
  10333. * Defines a state condition as an extension of Condition
  10334. */
  10335. export class StateCondition extends Condition {
  10336. /** Value to compare with target state */
  10337. value: string;
  10338. /**
  10339. * Internal only - manager for action
  10340. * @hidden
  10341. */
  10342. _actionManager: ActionManager;
  10343. /**
  10344. * Internal only
  10345. * @hidden
  10346. */
  10347. private _target;
  10348. /**
  10349. * Creates a new StateCondition
  10350. * @param actionManager manager for the action the condition applies to
  10351. * @param target of the condition
  10352. * @param value to compare with target state
  10353. */
  10354. constructor(actionManager: ActionManager, target: any,
  10355. /** Value to compare with target state */
  10356. value: string);
  10357. /**
  10358. * Gets a boolean indicating if the current condition is met
  10359. * @returns the validity of the state
  10360. */
  10361. isValid(): boolean;
  10362. /**
  10363. * Serialize the StateCondition into a JSON compatible object
  10364. * @returns serialization object
  10365. */
  10366. serialize(): any;
  10367. }
  10368. }
  10369. declare module BABYLON {
  10370. /**
  10371. * This defines an action responsible to toggle a boolean once triggered.
  10372. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10373. */
  10374. export class SwitchBooleanAction extends Action {
  10375. /**
  10376. * The path to the boolean property in the target object
  10377. */
  10378. propertyPath: string;
  10379. private _target;
  10380. private _effectiveTarget;
  10381. private _property;
  10382. /**
  10383. * Instantiate the action
  10384. * @param triggerOptions defines the trigger options
  10385. * @param target defines the object containing the boolean
  10386. * @param propertyPath defines the path to the boolean property in the target object
  10387. * @param condition defines the trigger related conditions
  10388. */
  10389. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10390. /** @hidden */
  10391. _prepare(): void;
  10392. /**
  10393. * Execute the action toggle the boolean value.
  10394. */
  10395. execute(): void;
  10396. /**
  10397. * Serializes the actions and its related information.
  10398. * @param parent defines the object to serialize in
  10399. * @returns the serialized object
  10400. */
  10401. serialize(parent: any): any;
  10402. }
  10403. /**
  10404. * This defines an action responsible to set a the state field of the target
  10405. * to a desired value once triggered.
  10406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10407. */
  10408. export class SetStateAction extends Action {
  10409. /**
  10410. * The value to store in the state field.
  10411. */
  10412. value: string;
  10413. private _target;
  10414. /**
  10415. * Instantiate the action
  10416. * @param triggerOptions defines the trigger options
  10417. * @param target defines the object containing the state property
  10418. * @param value defines the value to store in the state field
  10419. * @param condition defines the trigger related conditions
  10420. */
  10421. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10422. /**
  10423. * Execute the action and store the value on the target state property.
  10424. */
  10425. execute(): void;
  10426. /**
  10427. * Serializes the actions and its related information.
  10428. * @param parent defines the object to serialize in
  10429. * @returns the serialized object
  10430. */
  10431. serialize(parent: any): any;
  10432. }
  10433. /**
  10434. * This defines an action responsible to set a property of the target
  10435. * to a desired value once triggered.
  10436. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10437. */
  10438. export class SetValueAction extends Action {
  10439. /**
  10440. * The path of the property to set in the target.
  10441. */
  10442. propertyPath: string;
  10443. /**
  10444. * The value to set in the property
  10445. */
  10446. value: any;
  10447. private _target;
  10448. private _effectiveTarget;
  10449. private _property;
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param target defines the object containing the property
  10454. * @param propertyPath defines the path of the property to set in the target
  10455. * @param value defines the value to set in the property
  10456. * @param condition defines the trigger related conditions
  10457. */
  10458. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10459. /** @hidden */
  10460. _prepare(): void;
  10461. /**
  10462. * Execute the action and set the targetted property to the desired value.
  10463. */
  10464. execute(): void;
  10465. /**
  10466. * Serializes the actions and its related information.
  10467. * @param parent defines the object to serialize in
  10468. * @returns the serialized object
  10469. */
  10470. serialize(parent: any): any;
  10471. }
  10472. /**
  10473. * This defines an action responsible to increment the target value
  10474. * to a desired value once triggered.
  10475. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class IncrementValueAction extends Action {
  10478. /**
  10479. * The path of the property to increment in the target.
  10480. */
  10481. propertyPath: string;
  10482. /**
  10483. * The value we should increment the property by.
  10484. */
  10485. value: any;
  10486. private _target;
  10487. private _effectiveTarget;
  10488. private _property;
  10489. /**
  10490. * Instantiate the action
  10491. * @param triggerOptions defines the trigger options
  10492. * @param target defines the object containing the property
  10493. * @param propertyPath defines the path of the property to increment in the target
  10494. * @param value defines the value value we should increment the property by
  10495. * @param condition defines the trigger related conditions
  10496. */
  10497. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10498. /** @hidden */
  10499. _prepare(): void;
  10500. /**
  10501. * Execute the action and increment the target of the value amount.
  10502. */
  10503. execute(): void;
  10504. /**
  10505. * Serializes the actions and its related information.
  10506. * @param parent defines the object to serialize in
  10507. * @returns the serialized object
  10508. */
  10509. serialize(parent: any): any;
  10510. }
  10511. /**
  10512. * This defines an action responsible to start an animation once triggered.
  10513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10514. */
  10515. export class PlayAnimationAction extends Action {
  10516. /**
  10517. * Where the animation should start (animation frame)
  10518. */
  10519. from: number;
  10520. /**
  10521. * Where the animation should stop (animation frame)
  10522. */
  10523. to: number;
  10524. /**
  10525. * Define if the animation should loop or stop after the first play.
  10526. */
  10527. loop?: boolean;
  10528. private _target;
  10529. /**
  10530. * Instantiate the action
  10531. * @param triggerOptions defines the trigger options
  10532. * @param target defines the target animation or animation name
  10533. * @param from defines from where the animation should start (animation frame)
  10534. * @param end defines where the animation should stop (animation frame)
  10535. * @param loop defines if the animation should loop or stop after the first play
  10536. * @param condition defines the trigger related conditions
  10537. */
  10538. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10539. /** @hidden */
  10540. _prepare(): void;
  10541. /**
  10542. * Execute the action and play the animation.
  10543. */
  10544. execute(): void;
  10545. /**
  10546. * Serializes the actions and its related information.
  10547. * @param parent defines the object to serialize in
  10548. * @returns the serialized object
  10549. */
  10550. serialize(parent: any): any;
  10551. }
  10552. /**
  10553. * This defines an action responsible to stop an animation once triggered.
  10554. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10555. */
  10556. export class StopAnimationAction extends Action {
  10557. private _target;
  10558. /**
  10559. * Instantiate the action
  10560. * @param triggerOptions defines the trigger options
  10561. * @param target defines the target animation or animation name
  10562. * @param condition defines the trigger related conditions
  10563. */
  10564. constructor(triggerOptions: any, target: any, condition?: Condition);
  10565. /** @hidden */
  10566. _prepare(): void;
  10567. /**
  10568. * Execute the action and stop the animation.
  10569. */
  10570. execute(): void;
  10571. /**
  10572. * Serializes the actions and its related information.
  10573. * @param parent defines the object to serialize in
  10574. * @returns the serialized object
  10575. */
  10576. serialize(parent: any): any;
  10577. }
  10578. /**
  10579. * This defines an action responsible that does nothing once triggered.
  10580. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10581. */
  10582. export class DoNothingAction extends Action {
  10583. /**
  10584. * Instantiate the action
  10585. * @param triggerOptions defines the trigger options
  10586. * @param condition defines the trigger related conditions
  10587. */
  10588. constructor(triggerOptions?: any, condition?: Condition);
  10589. /**
  10590. * Execute the action and do nothing.
  10591. */
  10592. execute(): void;
  10593. /**
  10594. * Serializes the actions and its related information.
  10595. * @param parent defines the object to serialize in
  10596. * @returns the serialized object
  10597. */
  10598. serialize(parent: any): any;
  10599. }
  10600. /**
  10601. * This defines an action responsible to trigger several actions once triggered.
  10602. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class CombineAction extends Action {
  10605. /**
  10606. * The list of aggregated animations to run.
  10607. */
  10608. children: Action[];
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param children defines the list of aggregated animations to run
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10616. /** @hidden */
  10617. _prepare(): void;
  10618. /**
  10619. * Execute the action and executes all the aggregated actions.
  10620. */
  10621. execute(evt: ActionEvent): void;
  10622. /**
  10623. * Serializes the actions and its related information.
  10624. * @param parent defines the object to serialize in
  10625. * @returns the serialized object
  10626. */
  10627. serialize(parent: any): any;
  10628. }
  10629. /**
  10630. * This defines an action responsible to run code (external event) once triggered.
  10631. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10632. */
  10633. export class ExecuteCodeAction extends Action {
  10634. /**
  10635. * The callback function to run.
  10636. */
  10637. func: (evt: ActionEvent) => void;
  10638. /**
  10639. * Instantiate the action
  10640. * @param triggerOptions defines the trigger options
  10641. * @param func defines the callback function to run
  10642. * @param condition defines the trigger related conditions
  10643. */
  10644. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10645. /**
  10646. * Execute the action and run the attached code.
  10647. */
  10648. execute(evt: ActionEvent): void;
  10649. }
  10650. /**
  10651. * This defines an action responsible to set the parent property of the target once triggered.
  10652. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10653. */
  10654. export class SetParentAction extends Action {
  10655. private _parent;
  10656. private _target;
  10657. /**
  10658. * Instantiate the action
  10659. * @param triggerOptions defines the trigger options
  10660. * @param target defines the target containing the parent property
  10661. * @param parent defines from where the animation should start (animation frame)
  10662. * @param condition defines the trigger related conditions
  10663. */
  10664. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10665. /** @hidden */
  10666. _prepare(): void;
  10667. /**
  10668. * Execute the action and set the parent property.
  10669. */
  10670. execute(): void;
  10671. /**
  10672. * Serializes the actions and its related information.
  10673. * @param parent defines the object to serialize in
  10674. * @returns the serialized object
  10675. */
  10676. serialize(parent: any): any;
  10677. }
  10678. }
  10679. declare module BABYLON {
  10680. /**
  10681. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10682. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10683. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class ActionManager extends AbstractActionManager {
  10686. /**
  10687. * Nothing
  10688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly NothingTrigger: number;
  10691. /**
  10692. * On pick
  10693. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPickTrigger: number;
  10696. /**
  10697. * On left pick
  10698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnLeftPickTrigger: number;
  10701. /**
  10702. * On right pick
  10703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnRightPickTrigger: number;
  10706. /**
  10707. * On center pick
  10708. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnCenterPickTrigger: number;
  10711. /**
  10712. * On pick down
  10713. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnPickDownTrigger: number;
  10716. /**
  10717. * On double pick
  10718. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnDoublePickTrigger: number;
  10721. /**
  10722. * On pick up
  10723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnPickUpTrigger: number;
  10726. /**
  10727. * On pick out.
  10728. * This trigger will only be raised if you also declared a OnPickDown
  10729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnPickOutTrigger: number;
  10732. /**
  10733. * On long press
  10734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10735. */
  10736. static readonly OnLongPressTrigger: number;
  10737. /**
  10738. * On pointer over
  10739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly OnPointerOverTrigger: number;
  10742. /**
  10743. * On pointer out
  10744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10745. */
  10746. static readonly OnPointerOutTrigger: number;
  10747. /**
  10748. * On every frame
  10749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly OnEveryFrameTrigger: number;
  10752. /**
  10753. * On intersection enter
  10754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnIntersectionEnterTrigger: number;
  10757. /**
  10758. * On intersection exit
  10759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10760. */
  10761. static readonly OnIntersectionExitTrigger: number;
  10762. /**
  10763. * On key down
  10764. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10765. */
  10766. static readonly OnKeyDownTrigger: number;
  10767. /**
  10768. * On key up
  10769. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10770. */
  10771. static readonly OnKeyUpTrigger: number;
  10772. private _scene;
  10773. /**
  10774. * Creates a new action manager
  10775. * @param scene defines the hosting scene
  10776. */
  10777. constructor(scene: Scene);
  10778. /**
  10779. * Releases all associated resources
  10780. */
  10781. dispose(): void;
  10782. /**
  10783. * Gets hosting scene
  10784. * @returns the hosting scene
  10785. */
  10786. getScene(): Scene;
  10787. /**
  10788. * Does this action manager handles actions of any of the given triggers
  10789. * @param triggers defines the triggers to be tested
  10790. * @return a boolean indicating whether one (or more) of the triggers is handled
  10791. */
  10792. hasSpecificTriggers(triggers: number[]): boolean;
  10793. /**
  10794. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10795. * speed.
  10796. * @param triggerA defines the trigger to be tested
  10797. * @param triggerB defines the trigger to be tested
  10798. * @return a boolean indicating whether one (or more) of the triggers is handled
  10799. */
  10800. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10801. /**
  10802. * Does this action manager handles actions of a given trigger
  10803. * @param trigger defines the trigger to be tested
  10804. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10805. * @return whether the trigger is handled
  10806. */
  10807. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10808. /**
  10809. * Does this action manager has pointer triggers
  10810. */
  10811. get hasPointerTriggers(): boolean;
  10812. /**
  10813. * Does this action manager has pick triggers
  10814. */
  10815. get hasPickTriggers(): boolean;
  10816. /**
  10817. * Registers an action to this action manager
  10818. * @param action defines the action to be registered
  10819. * @return the action amended (prepared) after registration
  10820. */
  10821. registerAction(action: IAction): Nullable<IAction>;
  10822. /**
  10823. * Unregisters an action to this action manager
  10824. * @param action defines the action to be unregistered
  10825. * @return a boolean indicating whether the action has been unregistered
  10826. */
  10827. unregisterAction(action: IAction): Boolean;
  10828. /**
  10829. * Process a specific trigger
  10830. * @param trigger defines the trigger to process
  10831. * @param evt defines the event details to be processed
  10832. */
  10833. processTrigger(trigger: number, evt?: IActionEvent): void;
  10834. /** @hidden */
  10835. _getEffectiveTarget(target: any, propertyPath: string): any;
  10836. /** @hidden */
  10837. _getProperty(propertyPath: string): string;
  10838. /**
  10839. * Serialize this manager to a JSON object
  10840. * @param name defines the property name to store this manager
  10841. * @returns a JSON representation of this manager
  10842. */
  10843. serialize(name: string): any;
  10844. /**
  10845. * Creates a new ActionManager from a JSON data
  10846. * @param parsedActions defines the JSON data to read from
  10847. * @param object defines the hosting mesh
  10848. * @param scene defines the hosting scene
  10849. */
  10850. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10851. /**
  10852. * Get a trigger name by index
  10853. * @param trigger defines the trigger index
  10854. * @returns a trigger name
  10855. */
  10856. static GetTriggerName(trigger: number): string;
  10857. }
  10858. }
  10859. declare module BABYLON {
  10860. /**
  10861. * Class representing a ray with position and direction
  10862. */
  10863. export class Ray {
  10864. /** origin point */
  10865. origin: Vector3;
  10866. /** direction */
  10867. direction: Vector3;
  10868. /** length of the ray */
  10869. length: number;
  10870. private static readonly _TmpVector3;
  10871. private _tmpRay;
  10872. /**
  10873. * Creates a new ray
  10874. * @param origin origin point
  10875. * @param direction direction
  10876. * @param length length of the ray
  10877. */
  10878. constructor(
  10879. /** origin point */
  10880. origin: Vector3,
  10881. /** direction */
  10882. direction: Vector3,
  10883. /** length of the ray */
  10884. length?: number);
  10885. /**
  10886. * Checks if the ray intersects a box
  10887. * This does not account for the ray lenght by design to improve perfs.
  10888. * @param minimum bound of the box
  10889. * @param maximum bound of the box
  10890. * @param intersectionTreshold extra extend to be added to the box in all direction
  10891. * @returns if the box was hit
  10892. */
  10893. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10894. /**
  10895. * Checks if the ray intersects a box
  10896. * This does not account for the ray lenght by design to improve perfs.
  10897. * @param box the bounding box to check
  10898. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10899. * @returns if the box was hit
  10900. */
  10901. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10902. /**
  10903. * If the ray hits a sphere
  10904. * @param sphere the bounding sphere to check
  10905. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10906. * @returns true if it hits the sphere
  10907. */
  10908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10909. /**
  10910. * If the ray hits a triange
  10911. * @param vertex0 triangle vertex
  10912. * @param vertex1 triangle vertex
  10913. * @param vertex2 triangle vertex
  10914. * @returns intersection information if hit
  10915. */
  10916. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10917. /**
  10918. * Checks if ray intersects a plane
  10919. * @param plane the plane to check
  10920. * @returns the distance away it was hit
  10921. */
  10922. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10923. /**
  10924. * Calculate the intercept of a ray on a given axis
  10925. * @param axis to check 'x' | 'y' | 'z'
  10926. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10927. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10928. */
  10929. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10930. /**
  10931. * Checks if ray intersects a mesh
  10932. * @param mesh the mesh to check
  10933. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10934. * @returns picking info of the intersecton
  10935. */
  10936. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10937. /**
  10938. * Checks if ray intersects a mesh
  10939. * @param meshes the meshes to check
  10940. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10941. * @param results array to store result in
  10942. * @returns Array of picking infos
  10943. */
  10944. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10945. private _comparePickingInfo;
  10946. private static smallnum;
  10947. private static rayl;
  10948. /**
  10949. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10950. * @param sega the first point of the segment to test the intersection against
  10951. * @param segb the second point of the segment to test the intersection against
  10952. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10953. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10954. */
  10955. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10956. /**
  10957. * Update the ray from viewport position
  10958. * @param x position
  10959. * @param y y position
  10960. * @param viewportWidth viewport width
  10961. * @param viewportHeight viewport height
  10962. * @param world world matrix
  10963. * @param view view matrix
  10964. * @param projection projection matrix
  10965. * @returns this ray updated
  10966. */
  10967. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10968. /**
  10969. * Creates a ray with origin and direction of 0,0,0
  10970. * @returns the new ray
  10971. */
  10972. static Zero(): Ray;
  10973. /**
  10974. * Creates a new ray from screen space and viewport
  10975. * @param x position
  10976. * @param y y position
  10977. * @param viewportWidth viewport width
  10978. * @param viewportHeight viewport height
  10979. * @param world world matrix
  10980. * @param view view matrix
  10981. * @param projection projection matrix
  10982. * @returns new ray
  10983. */
  10984. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10985. /**
  10986. * 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
  10987. * transformed to the given world matrix.
  10988. * @param origin The origin point
  10989. * @param end The end point
  10990. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10991. * @returns the new ray
  10992. */
  10993. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10994. /**
  10995. * Transforms a ray by a matrix
  10996. * @param ray ray to transform
  10997. * @param matrix matrix to apply
  10998. * @returns the resulting new ray
  10999. */
  11000. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11001. /**
  11002. * Transforms a ray by a matrix
  11003. * @param ray ray to transform
  11004. * @param matrix matrix to apply
  11005. * @param result ray to store result in
  11006. */
  11007. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11008. /**
  11009. * Unproject a ray from screen space to object space
  11010. * @param sourceX defines the screen space x coordinate to use
  11011. * @param sourceY defines the screen space y coordinate to use
  11012. * @param viewportWidth defines the current width of the viewport
  11013. * @param viewportHeight defines the current height of the viewport
  11014. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11015. * @param view defines the view matrix to use
  11016. * @param projection defines the projection matrix to use
  11017. */
  11018. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11019. }
  11020. /**
  11021. * Type used to define predicate used to select faces when a mesh intersection is detected
  11022. */
  11023. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11024. interface Scene {
  11025. /** @hidden */
  11026. _tempPickingRay: Nullable<Ray>;
  11027. /** @hidden */
  11028. _cachedRayForTransform: Ray;
  11029. /** @hidden */
  11030. _pickWithRayInverseMatrix: Matrix;
  11031. /** @hidden */
  11032. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11033. /** @hidden */
  11034. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11035. /** @hidden */
  11036. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11037. }
  11038. }
  11039. declare module BABYLON {
  11040. /**
  11041. * Groups all the scene component constants in one place to ease maintenance.
  11042. * @hidden
  11043. */
  11044. export class SceneComponentConstants {
  11045. static readonly NAME_EFFECTLAYER: string;
  11046. static readonly NAME_LAYER: string;
  11047. static readonly NAME_LENSFLARESYSTEM: string;
  11048. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11049. static readonly NAME_PARTICLESYSTEM: string;
  11050. static readonly NAME_GAMEPAD: string;
  11051. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11052. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11053. static readonly NAME_PREPASSRENDERER: string;
  11054. static readonly NAME_DEPTHRENDERER: string;
  11055. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11056. static readonly NAME_SPRITE: string;
  11057. static readonly NAME_SUBSURFACE: string;
  11058. static readonly NAME_OUTLINERENDERER: string;
  11059. static readonly NAME_PROCEDURALTEXTURE: string;
  11060. static readonly NAME_SHADOWGENERATOR: string;
  11061. static readonly NAME_OCTREE: string;
  11062. static readonly NAME_PHYSICSENGINE: string;
  11063. static readonly NAME_AUDIO: string;
  11064. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11065. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11066. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11067. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11068. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11069. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11070. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11071. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11072. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11073. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11074. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11075. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11076. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11077. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11078. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11079. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11080. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11081. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11082. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11083. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11084. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11085. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11086. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11087. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11088. static readonly STEP_AFTERRENDER_AUDIO: number;
  11089. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11090. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11091. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11092. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11093. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11094. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11095. static readonly STEP_POINTERMOVE_SPRITE: number;
  11096. static readonly STEP_POINTERDOWN_SPRITE: number;
  11097. static readonly STEP_POINTERUP_SPRITE: number;
  11098. }
  11099. /**
  11100. * This represents a scene component.
  11101. *
  11102. * This is used to decouple the dependency the scene is having on the different workloads like
  11103. * layers, post processes...
  11104. */
  11105. export interface ISceneComponent {
  11106. /**
  11107. * The name of the component. Each component must have a unique name.
  11108. */
  11109. name: string;
  11110. /**
  11111. * The scene the component belongs to.
  11112. */
  11113. scene: Scene;
  11114. /**
  11115. * Register the component to one instance of a scene.
  11116. */
  11117. register(): void;
  11118. /**
  11119. * Rebuilds the elements related to this component in case of
  11120. * context lost for instance.
  11121. */
  11122. rebuild(): void;
  11123. /**
  11124. * Disposes the component and the associated ressources.
  11125. */
  11126. dispose(): void;
  11127. }
  11128. /**
  11129. * This represents a SERIALIZABLE scene component.
  11130. *
  11131. * This extends Scene Component to add Serialization methods on top.
  11132. */
  11133. export interface ISceneSerializableComponent extends ISceneComponent {
  11134. /**
  11135. * Adds all the elements from the container to the scene
  11136. * @param container the container holding the elements
  11137. */
  11138. addFromContainer(container: AbstractScene): void;
  11139. /**
  11140. * Removes all the elements in the container from the scene
  11141. * @param container contains the elements to remove
  11142. * @param dispose if the removed element should be disposed (default: false)
  11143. */
  11144. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11145. /**
  11146. * Serializes the component data to the specified json object
  11147. * @param serializationObject The object to serialize to
  11148. */
  11149. serialize(serializationObject: any): void;
  11150. }
  11151. /**
  11152. * Strong typing of a Mesh related stage step action
  11153. */
  11154. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11155. /**
  11156. * Strong typing of a Evaluate Sub Mesh related stage step action
  11157. */
  11158. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11159. /**
  11160. * Strong typing of a pre active Mesh related stage step action
  11161. */
  11162. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11163. /**
  11164. * Strong typing of a Camera related stage step action
  11165. */
  11166. export type CameraStageAction = (camera: Camera) => void;
  11167. /**
  11168. * Strong typing of a Camera Frame buffer related stage step action
  11169. */
  11170. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11171. /**
  11172. * Strong typing of a Render Target related stage step action
  11173. */
  11174. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11175. /**
  11176. * Strong typing of a RenderingGroup related stage step action
  11177. */
  11178. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11179. /**
  11180. * Strong typing of a Mesh Render related stage step action
  11181. */
  11182. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11183. /**
  11184. * Strong typing of a simple stage step action
  11185. */
  11186. export type SimpleStageAction = () => void;
  11187. /**
  11188. * Strong typing of a render target action.
  11189. */
  11190. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11191. /**
  11192. * Strong typing of a pointer move action.
  11193. */
  11194. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11195. /**
  11196. * Strong typing of a pointer up/down action.
  11197. */
  11198. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11199. /**
  11200. * Representation of a stage in the scene (Basically a list of ordered steps)
  11201. * @hidden
  11202. */
  11203. export class Stage<T extends Function> extends Array<{
  11204. index: number;
  11205. component: ISceneComponent;
  11206. action: T;
  11207. }> {
  11208. /**
  11209. * Hide ctor from the rest of the world.
  11210. * @param items The items to add.
  11211. */
  11212. private constructor();
  11213. /**
  11214. * Creates a new Stage.
  11215. * @returns A new instance of a Stage
  11216. */
  11217. static Create<T extends Function>(): Stage<T>;
  11218. /**
  11219. * Registers a step in an ordered way in the targeted stage.
  11220. * @param index Defines the position to register the step in
  11221. * @param component Defines the component attached to the step
  11222. * @param action Defines the action to launch during the step
  11223. */
  11224. registerStep(index: number, component: ISceneComponent, action: T): void;
  11225. /**
  11226. * Clears all the steps from the stage.
  11227. */
  11228. clear(): void;
  11229. }
  11230. }
  11231. declare module BABYLON {
  11232. interface Scene {
  11233. /** @hidden */
  11234. _pointerOverSprite: Nullable<Sprite>;
  11235. /** @hidden */
  11236. _pickedDownSprite: Nullable<Sprite>;
  11237. /** @hidden */
  11238. _tempSpritePickingRay: Nullable<Ray>;
  11239. /**
  11240. * All of the sprite managers added to this scene
  11241. * @see https://doc.babylonjs.com/babylon101/sprites
  11242. */
  11243. spriteManagers: Array<ISpriteManager>;
  11244. /**
  11245. * An event triggered when sprites rendering is about to start
  11246. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11247. */
  11248. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11249. /**
  11250. * An event triggered when sprites rendering is done
  11251. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11252. */
  11253. onAfterSpritesRenderingObservable: Observable<Scene>;
  11254. /** @hidden */
  11255. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11256. /** Launch a ray to try to pick a sprite in the scene
  11257. * @param x position on screen
  11258. * @param y position on screen
  11259. * @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
  11260. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11261. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11262. * @returns a PickingInfo
  11263. */
  11264. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11265. /** Use the given ray to pick a sprite in the scene
  11266. * @param ray The ray (in world space) to use to pick meshes
  11267. * @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
  11268. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11269. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11270. * @returns a PickingInfo
  11271. */
  11272. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11273. /** @hidden */
  11274. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11275. /** Launch a ray to try to pick sprites in the scene
  11276. * @param x position on screen
  11277. * @param y position on screen
  11278. * @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
  11279. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11280. * @returns a PickingInfo array
  11281. */
  11282. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11283. /** Use the given ray to pick sprites in the scene
  11284. * @param ray The ray (in world space) to use to pick meshes
  11285. * @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
  11286. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11287. * @returns a PickingInfo array
  11288. */
  11289. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11290. /**
  11291. * Force the sprite under the pointer
  11292. * @param sprite defines the sprite to use
  11293. */
  11294. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11295. /**
  11296. * Gets the sprite under the pointer
  11297. * @returns a Sprite or null if no sprite is under the pointer
  11298. */
  11299. getPointerOverSprite(): Nullable<Sprite>;
  11300. }
  11301. /**
  11302. * Defines the sprite scene component responsible to manage sprites
  11303. * in a given scene.
  11304. */
  11305. export class SpriteSceneComponent implements ISceneComponent {
  11306. /**
  11307. * The component name helpfull to identify the component in the list of scene components.
  11308. */
  11309. readonly name: string;
  11310. /**
  11311. * The scene the component belongs to.
  11312. */
  11313. scene: Scene;
  11314. /** @hidden */
  11315. private _spritePredicate;
  11316. /**
  11317. * Creates a new instance of the component for the given scene
  11318. * @param scene Defines the scene to register the component in
  11319. */
  11320. constructor(scene: Scene);
  11321. /**
  11322. * Registers the component in a given scene
  11323. */
  11324. register(): void;
  11325. /**
  11326. * Rebuilds the elements related to this component in case of
  11327. * context lost for instance.
  11328. */
  11329. rebuild(): void;
  11330. /**
  11331. * Disposes the component and the associated ressources.
  11332. */
  11333. dispose(): void;
  11334. private _pickSpriteButKeepRay;
  11335. private _pointerMove;
  11336. private _pointerDown;
  11337. private _pointerUp;
  11338. }
  11339. }
  11340. declare module BABYLON {
  11341. /**
  11342. * Class used to provide helper for timing
  11343. */
  11344. export class TimingTools {
  11345. /**
  11346. * Polyfill for setImmediate
  11347. * @param action defines the action to execute after the current execution block
  11348. */
  11349. static SetImmediate(action: () => void): void;
  11350. }
  11351. }
  11352. declare module BABYLON {
  11353. /**
  11354. * Class used to enable instatition of objects by class name
  11355. */
  11356. export class InstantiationTools {
  11357. /**
  11358. * Use this object to register external classes like custom textures or material
  11359. * to allow the laoders to instantiate them
  11360. */
  11361. static RegisteredExternalClasses: {
  11362. [key: string]: Object;
  11363. };
  11364. /**
  11365. * Tries to instantiate a new object from a given class name
  11366. * @param className defines the class name to instantiate
  11367. * @returns the new object or null if the system was not able to do the instantiation
  11368. */
  11369. static Instantiate(className: string): any;
  11370. }
  11371. }
  11372. declare module BABYLON {
  11373. /**
  11374. * Class used to host copy specific utilities
  11375. */
  11376. export class CopyTools {
  11377. /**
  11378. * Transform some pixel data to a base64 string
  11379. * @param pixels defines the pixel data to transform to base64
  11380. * @param size defines the width and height of the (texture) data
  11381. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11382. * @returns The base64 encoded string or null
  11383. */
  11384. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11385. /**
  11386. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11387. * @param texture defines the texture to read pixels from
  11388. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11389. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11390. * @returns The base64 encoded string or null
  11391. */
  11392. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11393. /**
  11394. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11395. * @param texture defines the texture to read pixels from
  11396. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11397. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11398. * @returns The base64 encoded string or null wrapped in a promise
  11399. */
  11400. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11401. }
  11402. }
  11403. declare module BABYLON {
  11404. /**
  11405. * Define options used to create a depth texture
  11406. */
  11407. export class DepthTextureCreationOptions {
  11408. /** Specifies whether or not a stencil should be allocated in the texture */
  11409. generateStencil?: boolean;
  11410. /** Specifies whether or not bilinear filtering is enable on the texture */
  11411. bilinearFiltering?: boolean;
  11412. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11413. comparisonFunction?: number;
  11414. /** Specifies if the created texture is a cube texture */
  11415. isCube?: boolean;
  11416. /** Specifies the sample count of the depth/stencil texture texture */
  11417. samples?: number;
  11418. }
  11419. }
  11420. declare module BABYLON {
  11421. interface ThinEngine {
  11422. /**
  11423. * Creates a depth stencil cube texture.
  11424. * This is only available in WebGL 2.
  11425. * @param size The size of face edge in the cube texture.
  11426. * @param options The options defining the cube texture.
  11427. * @returns The cube texture
  11428. */
  11429. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11430. /**
  11431. * Creates a cube texture
  11432. * @param rootUrl defines the url where the files to load is located
  11433. * @param scene defines the current scene
  11434. * @param files defines the list of files to load (1 per face)
  11435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11436. * @param onLoad defines an optional callback raised when the texture is loaded
  11437. * @param onError defines an optional callback raised if there is an issue to load the texture
  11438. * @param format defines the format of the data
  11439. * @param forcedExtension defines the extension to use to pick the right loader
  11440. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11441. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11442. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11443. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11444. * @param loaderOptions options to be passed to the loader
  11445. * @returns the cube texture as an InternalTexture
  11446. */
  11447. 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;
  11448. /**
  11449. * Creates a cube texture
  11450. * @param rootUrl defines the url where the files to load is located
  11451. * @param scene defines the current scene
  11452. * @param files defines the list of files to load (1 per face)
  11453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11454. * @param onLoad defines an optional callback raised when the texture is loaded
  11455. * @param onError defines an optional callback raised if there is an issue to load the texture
  11456. * @param format defines the format of the data
  11457. * @param forcedExtension defines the extension to use to pick the right loader
  11458. * @returns the cube texture as an InternalTexture
  11459. */
  11460. 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;
  11461. /**
  11462. * Creates a cube texture
  11463. * @param rootUrl defines the url where the files to load is located
  11464. * @param scene defines the current scene
  11465. * @param files defines the list of files to load (1 per face)
  11466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11467. * @param onLoad defines an optional callback raised when the texture is loaded
  11468. * @param onError defines an optional callback raised if there is an issue to load the texture
  11469. * @param format defines the format of the data
  11470. * @param forcedExtension defines the extension to use to pick the right loader
  11471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11474. * @returns the cube texture as an InternalTexture
  11475. */
  11476. 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;
  11477. /** @hidden */
  11478. 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;
  11479. /** @hidden */
  11480. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11481. /** @hidden */
  11482. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11483. /** @hidden */
  11484. _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;
  11485. /** @hidden */
  11486. _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;
  11487. /**
  11488. * @hidden
  11489. */
  11490. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11491. }
  11492. }
  11493. declare module BABYLON {
  11494. /**
  11495. * Class for creating a cube texture
  11496. */
  11497. export class CubeTexture extends BaseTexture {
  11498. private _delayedOnLoad;
  11499. /**
  11500. * Observable triggered once the texture has been loaded.
  11501. */
  11502. onLoadObservable: Observable<CubeTexture>;
  11503. /**
  11504. * The url of the texture
  11505. */
  11506. url: string;
  11507. /**
  11508. * Gets or sets the center of the bounding box associated with the cube texture.
  11509. * It must define where the camera used to render the texture was set
  11510. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11511. */
  11512. boundingBoxPosition: Vector3;
  11513. private _boundingBoxSize;
  11514. /**
  11515. * Gets or sets the size of the bounding box associated with the cube texture
  11516. * When defined, the cubemap will switch to local mode
  11517. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11518. * @example https://www.babylonjs-playground.com/#RNASML
  11519. */
  11520. set boundingBoxSize(value: Vector3);
  11521. /**
  11522. * Returns the bounding box size
  11523. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11524. */
  11525. get boundingBoxSize(): Vector3;
  11526. protected _rotationY: number;
  11527. /**
  11528. * Sets texture matrix rotation angle around Y axis in radians.
  11529. */
  11530. set rotationY(value: number);
  11531. /**
  11532. * Gets texture matrix rotation angle around Y axis radians.
  11533. */
  11534. get rotationY(): number;
  11535. /**
  11536. * Are mip maps generated for this texture or not.
  11537. */
  11538. get noMipmap(): boolean;
  11539. private _noMipmap;
  11540. private _files;
  11541. protected _forcedExtension: Nullable<string>;
  11542. private _extensions;
  11543. private _textureMatrix;
  11544. private _format;
  11545. private _createPolynomials;
  11546. private _loaderOptions;
  11547. /**
  11548. * Creates a cube texture from an array of image urls
  11549. * @param files defines an array of image urls
  11550. * @param scene defines the hosting scene
  11551. * @param noMipmap specifies if mip maps are not used
  11552. * @returns a cube texture
  11553. */
  11554. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11555. /**
  11556. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11557. * @param url defines the url of the prefiltered texture
  11558. * @param scene defines the scene the texture is attached to
  11559. * @param forcedExtension defines the extension of the file if different from the url
  11560. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11561. * @return the prefiltered texture
  11562. */
  11563. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11564. /**
  11565. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11566. * as prefiltered data.
  11567. * @param rootUrl defines the url of the texture or the root name of the six images
  11568. * @param null defines the scene or engine the texture is attached to
  11569. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11570. * @param noMipmap defines if mipmaps should be created or not
  11571. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11572. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11573. * @param onError defines a callback triggered in case of error during load
  11574. * @param format defines the internal format to use for the texture once loaded
  11575. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11576. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11577. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11580. * @param loaderOptions options to be passed to the loader
  11581. * @return the cube texture
  11582. */
  11583. 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);
  11584. /**
  11585. * Get the current class name of the texture useful for serialization or dynamic coding.
  11586. * @returns "CubeTexture"
  11587. */
  11588. getClassName(): string;
  11589. /**
  11590. * Update the url (and optional buffer) of this texture if url was null during construction.
  11591. * @param url the url of the texture
  11592. * @param forcedExtension defines the extension to use
  11593. * @param onLoad callback called when the texture is loaded (defaults to null)
  11594. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11595. */
  11596. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11597. /**
  11598. * Delays loading of the cube texture
  11599. * @param forcedExtension defines the extension to use
  11600. */
  11601. delayLoad(forcedExtension?: string): void;
  11602. /**
  11603. * Returns the reflection texture matrix
  11604. * @returns the reflection texture matrix
  11605. */
  11606. getReflectionTextureMatrix(): Matrix;
  11607. /**
  11608. * Sets the reflection texture matrix
  11609. * @param value Reflection texture matrix
  11610. */
  11611. setReflectionTextureMatrix(value: Matrix): void;
  11612. /**
  11613. * Parses text to create a cube texture
  11614. * @param parsedTexture define the serialized text to read from
  11615. * @param scene defines the hosting scene
  11616. * @param rootUrl defines the root url of the cube texture
  11617. * @returns a cube texture
  11618. */
  11619. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11620. /**
  11621. * Makes a clone, or deep copy, of the cube texture
  11622. * @returns a new cube texture
  11623. */
  11624. clone(): CubeTexture;
  11625. }
  11626. }
  11627. declare module BABYLON {
  11628. /**
  11629. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11630. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11631. * 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;
  11632. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11633. */
  11634. export class ColorCurves {
  11635. private _dirty;
  11636. private _tempColor;
  11637. private _globalCurve;
  11638. private _highlightsCurve;
  11639. private _midtonesCurve;
  11640. private _shadowsCurve;
  11641. private _positiveCurve;
  11642. private _negativeCurve;
  11643. private _globalHue;
  11644. private _globalDensity;
  11645. private _globalSaturation;
  11646. private _globalExposure;
  11647. /**
  11648. * Gets the global Hue value.
  11649. * 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).
  11650. */
  11651. get globalHue(): number;
  11652. /**
  11653. * Sets the global Hue value.
  11654. * 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).
  11655. */
  11656. set globalHue(value: number);
  11657. /**
  11658. * Gets the global 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. get globalDensity(): number;
  11663. /**
  11664. * Sets the global Density value.
  11665. * 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.
  11666. * Values less than zero provide a filter of opposite hue.
  11667. */
  11668. set globalDensity(value: number);
  11669. /**
  11670. * Gets the global Saturation value.
  11671. * 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.
  11672. */
  11673. get globalSaturation(): number;
  11674. /**
  11675. * Sets the global Saturation value.
  11676. * 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.
  11677. */
  11678. set globalSaturation(value: number);
  11679. /**
  11680. * Gets the global Exposure value.
  11681. * 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.
  11682. */
  11683. get globalExposure(): number;
  11684. /**
  11685. * Sets the global Exposure value.
  11686. * 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.
  11687. */
  11688. set globalExposure(value: number);
  11689. private _highlightsHue;
  11690. private _highlightsDensity;
  11691. private _highlightsSaturation;
  11692. private _highlightsExposure;
  11693. /**
  11694. * Gets the highlights Hue value.
  11695. * 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).
  11696. */
  11697. get highlightsHue(): number;
  11698. /**
  11699. * Sets the highlights Hue value.
  11700. * 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).
  11701. */
  11702. set highlightsHue(value: number);
  11703. /**
  11704. * Gets the highlights 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. get highlightsDensity(): number;
  11709. /**
  11710. * Sets the highlights Density value.
  11711. * 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.
  11712. * Values less than zero provide a filter of opposite hue.
  11713. */
  11714. set highlightsDensity(value: number);
  11715. /**
  11716. * Gets the highlights Saturation value.
  11717. * 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.
  11718. */
  11719. get highlightsSaturation(): number;
  11720. /**
  11721. * Sets the highlights Saturation value.
  11722. * 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.
  11723. */
  11724. set highlightsSaturation(value: number);
  11725. /**
  11726. * Gets the highlights Exposure value.
  11727. * 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.
  11728. */
  11729. get highlightsExposure(): number;
  11730. /**
  11731. * Sets the highlights Exposure value.
  11732. * 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.
  11733. */
  11734. set highlightsExposure(value: number);
  11735. private _midtonesHue;
  11736. private _midtonesDensity;
  11737. private _midtonesSaturation;
  11738. private _midtonesExposure;
  11739. /**
  11740. * Gets the midtones Hue value.
  11741. * 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).
  11742. */
  11743. get midtonesHue(): number;
  11744. /**
  11745. * Sets the midtones Hue value.
  11746. * 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).
  11747. */
  11748. set midtonesHue(value: number);
  11749. /**
  11750. * Gets the midtones 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. get midtonesDensity(): number;
  11755. /**
  11756. * Sets the midtones Density value.
  11757. * 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.
  11758. * Values less than zero provide a filter of opposite hue.
  11759. */
  11760. set midtonesDensity(value: number);
  11761. /**
  11762. * Gets the midtones Saturation value.
  11763. * 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.
  11764. */
  11765. get midtonesSaturation(): number;
  11766. /**
  11767. * Sets the midtones Saturation value.
  11768. * 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.
  11769. */
  11770. set midtonesSaturation(value: number);
  11771. /**
  11772. * Gets the midtones Exposure value.
  11773. * 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.
  11774. */
  11775. get midtonesExposure(): number;
  11776. /**
  11777. * Sets the midtones Exposure value.
  11778. * 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.
  11779. */
  11780. set midtonesExposure(value: number);
  11781. private _shadowsHue;
  11782. private _shadowsDensity;
  11783. private _shadowsSaturation;
  11784. private _shadowsExposure;
  11785. /**
  11786. * Gets the shadows Hue value.
  11787. * 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).
  11788. */
  11789. get shadowsHue(): number;
  11790. /**
  11791. * Sets the shadows Hue value.
  11792. * 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).
  11793. */
  11794. set shadowsHue(value: number);
  11795. /**
  11796. * Gets the shadows Density value.
  11797. * 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.
  11798. * Values less than zero provide a filter of opposite hue.
  11799. */
  11800. get shadowsDensity(): number;
  11801. /**
  11802. * Sets the shadows Density value.
  11803. * 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.
  11804. * Values less than zero provide a filter of opposite hue.
  11805. */
  11806. set shadowsDensity(value: number);
  11807. /**
  11808. * Gets the shadows Saturation value.
  11809. * 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.
  11810. */
  11811. get shadowsSaturation(): number;
  11812. /**
  11813. * Sets the shadows Saturation value.
  11814. * 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.
  11815. */
  11816. set shadowsSaturation(value: number);
  11817. /**
  11818. * Gets the shadows Exposure value.
  11819. * 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.
  11820. */
  11821. get shadowsExposure(): number;
  11822. /**
  11823. * Sets the shadows Exposure value.
  11824. * 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.
  11825. */
  11826. set shadowsExposure(value: number);
  11827. /**
  11828. * Returns the class name
  11829. * @returns The class name
  11830. */
  11831. getClassName(): string;
  11832. /**
  11833. * Binds the color curves to the shader.
  11834. * @param colorCurves The color curve to bind
  11835. * @param effect The effect to bind to
  11836. * @param positiveUniform The positive uniform shader parameter
  11837. * @param neutralUniform The neutral uniform shader parameter
  11838. * @param negativeUniform The negative uniform shader parameter
  11839. */
  11840. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11841. /**
  11842. * Prepare the list of uniforms associated with the ColorCurves effects.
  11843. * @param uniformsList The list of uniforms used in the effect
  11844. */
  11845. static PrepareUniforms(uniformsList: string[]): void;
  11846. /**
  11847. * Returns color grading data based on a hue, density, saturation and exposure value.
  11848. * @param filterHue The hue of the color filter.
  11849. * @param filterDensity The density of the color filter.
  11850. * @param saturation The saturation.
  11851. * @param exposure The exposure.
  11852. * @param result The result data container.
  11853. */
  11854. private getColorGradingDataToRef;
  11855. /**
  11856. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11857. * @param value The input slider value in range [-100,100].
  11858. * @returns Adjusted value.
  11859. */
  11860. private static applyColorGradingSliderNonlinear;
  11861. /**
  11862. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11863. * @param hue The hue (H) input.
  11864. * @param saturation The saturation (S) input.
  11865. * @param brightness The brightness (B) input.
  11866. * @result An RGBA color represented as Vector4.
  11867. */
  11868. private static fromHSBToRef;
  11869. /**
  11870. * Returns a value clamped between min and max
  11871. * @param value The value to clamp
  11872. * @param min The minimum of value
  11873. * @param max The maximum of value
  11874. * @returns The clamped value.
  11875. */
  11876. private static clamp;
  11877. /**
  11878. * Clones the current color curve instance.
  11879. * @return The cloned curves
  11880. */
  11881. clone(): ColorCurves;
  11882. /**
  11883. * Serializes the current color curve instance to a json representation.
  11884. * @return a JSON representation
  11885. */
  11886. serialize(): any;
  11887. /**
  11888. * Parses the color curve from a json representation.
  11889. * @param source the JSON source to parse
  11890. * @return The parsed curves
  11891. */
  11892. static Parse(source: any): ColorCurves;
  11893. }
  11894. }
  11895. declare module BABYLON {
  11896. /**
  11897. * Interface to follow in your material defines to integrate easily the
  11898. * Image proccessing functions.
  11899. * @hidden
  11900. */
  11901. export interface IImageProcessingConfigurationDefines {
  11902. IMAGEPROCESSING: boolean;
  11903. VIGNETTE: boolean;
  11904. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11905. VIGNETTEBLENDMODEOPAQUE: boolean;
  11906. TONEMAPPING: boolean;
  11907. TONEMAPPING_ACES: boolean;
  11908. CONTRAST: boolean;
  11909. EXPOSURE: boolean;
  11910. COLORCURVES: boolean;
  11911. COLORGRADING: boolean;
  11912. COLORGRADING3D: boolean;
  11913. SAMPLER3DGREENDEPTH: boolean;
  11914. SAMPLER3DBGRMAP: boolean;
  11915. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11916. }
  11917. /**
  11918. * @hidden
  11919. */
  11920. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11921. IMAGEPROCESSING: boolean;
  11922. VIGNETTE: boolean;
  11923. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11924. VIGNETTEBLENDMODEOPAQUE: boolean;
  11925. TONEMAPPING: boolean;
  11926. TONEMAPPING_ACES: boolean;
  11927. CONTRAST: boolean;
  11928. COLORCURVES: boolean;
  11929. COLORGRADING: boolean;
  11930. COLORGRADING3D: boolean;
  11931. SAMPLER3DGREENDEPTH: boolean;
  11932. SAMPLER3DBGRMAP: boolean;
  11933. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11934. EXPOSURE: boolean;
  11935. constructor();
  11936. }
  11937. /**
  11938. * This groups together the common properties used for image processing either in direct forward pass
  11939. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11940. * or not.
  11941. */
  11942. export class ImageProcessingConfiguration {
  11943. /**
  11944. * Default tone mapping applied in BabylonJS.
  11945. */
  11946. static readonly TONEMAPPING_STANDARD: number;
  11947. /**
  11948. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11949. * to other engines rendering to increase portability.
  11950. */
  11951. static readonly TONEMAPPING_ACES: number;
  11952. /**
  11953. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11954. */
  11955. colorCurves: Nullable<ColorCurves>;
  11956. private _colorCurvesEnabled;
  11957. /**
  11958. * Gets wether the color curves effect is enabled.
  11959. */
  11960. get colorCurvesEnabled(): boolean;
  11961. /**
  11962. * Sets wether the color curves effect is enabled.
  11963. */
  11964. set colorCurvesEnabled(value: boolean);
  11965. private _colorGradingTexture;
  11966. /**
  11967. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11968. */
  11969. get colorGradingTexture(): Nullable<BaseTexture>;
  11970. /**
  11971. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11972. */
  11973. set colorGradingTexture(value: Nullable<BaseTexture>);
  11974. private _colorGradingEnabled;
  11975. /**
  11976. * Gets wether the color grading effect is enabled.
  11977. */
  11978. get colorGradingEnabled(): boolean;
  11979. /**
  11980. * Sets wether the color grading effect is enabled.
  11981. */
  11982. set colorGradingEnabled(value: boolean);
  11983. private _colorGradingWithGreenDepth;
  11984. /**
  11985. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11986. */
  11987. get colorGradingWithGreenDepth(): boolean;
  11988. /**
  11989. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11990. */
  11991. set colorGradingWithGreenDepth(value: boolean);
  11992. private _colorGradingBGR;
  11993. /**
  11994. * Gets wether the color grading texture contains BGR values.
  11995. */
  11996. get colorGradingBGR(): boolean;
  11997. /**
  11998. * Sets wether the color grading texture contains BGR values.
  11999. */
  12000. set colorGradingBGR(value: boolean);
  12001. /** @hidden */
  12002. _exposure: number;
  12003. /**
  12004. * Gets the Exposure used in the effect.
  12005. */
  12006. get exposure(): number;
  12007. /**
  12008. * Sets the Exposure used in the effect.
  12009. */
  12010. set exposure(value: number);
  12011. private _toneMappingEnabled;
  12012. /**
  12013. * Gets wether the tone mapping effect is enabled.
  12014. */
  12015. get toneMappingEnabled(): boolean;
  12016. /**
  12017. * Sets wether the tone mapping effect is enabled.
  12018. */
  12019. set toneMappingEnabled(value: boolean);
  12020. private _toneMappingType;
  12021. /**
  12022. * Gets the type of tone mapping effect.
  12023. */
  12024. get toneMappingType(): number;
  12025. /**
  12026. * Sets the type of tone mapping effect used in BabylonJS.
  12027. */
  12028. set toneMappingType(value: number);
  12029. protected _contrast: number;
  12030. /**
  12031. * Gets the contrast used in the effect.
  12032. */
  12033. get contrast(): number;
  12034. /**
  12035. * Sets the contrast used in the effect.
  12036. */
  12037. set contrast(value: number);
  12038. /**
  12039. * Vignette stretch size.
  12040. */
  12041. vignetteStretch: number;
  12042. /**
  12043. * Vignette centre X Offset.
  12044. */
  12045. vignetteCentreX: number;
  12046. /**
  12047. * Vignette centre Y Offset.
  12048. */
  12049. vignetteCentreY: number;
  12050. /**
  12051. * Vignette weight or intensity of the vignette effect.
  12052. */
  12053. vignetteWeight: number;
  12054. /**
  12055. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12056. * if vignetteEnabled is set to true.
  12057. */
  12058. vignetteColor: Color4;
  12059. /**
  12060. * Camera field of view used by the Vignette effect.
  12061. */
  12062. vignetteCameraFov: number;
  12063. private _vignetteBlendMode;
  12064. /**
  12065. * Gets the vignette blend mode allowing different kind of effect.
  12066. */
  12067. get vignetteBlendMode(): number;
  12068. /**
  12069. * Sets the vignette blend mode allowing different kind of effect.
  12070. */
  12071. set vignetteBlendMode(value: number);
  12072. private _vignetteEnabled;
  12073. /**
  12074. * Gets wether the vignette effect is enabled.
  12075. */
  12076. get vignetteEnabled(): boolean;
  12077. /**
  12078. * Sets wether the vignette effect is enabled.
  12079. */
  12080. set vignetteEnabled(value: boolean);
  12081. private _applyByPostProcess;
  12082. /**
  12083. * Gets wether the image processing is applied through a post process or not.
  12084. */
  12085. get applyByPostProcess(): boolean;
  12086. /**
  12087. * Sets wether the image processing is applied through a post process or not.
  12088. */
  12089. set applyByPostProcess(value: boolean);
  12090. private _isEnabled;
  12091. /**
  12092. * Gets wether the image processing is enabled or not.
  12093. */
  12094. get isEnabled(): boolean;
  12095. /**
  12096. * Sets wether the image processing is enabled or not.
  12097. */
  12098. set isEnabled(value: boolean);
  12099. /**
  12100. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12101. */
  12102. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12103. /**
  12104. * Method called each time the image processing information changes requires to recompile the effect.
  12105. */
  12106. protected _updateParameters(): void;
  12107. /**
  12108. * Gets the current class name.
  12109. * @return "ImageProcessingConfiguration"
  12110. */
  12111. getClassName(): string;
  12112. /**
  12113. * Prepare the list of uniforms associated with the Image Processing effects.
  12114. * @param uniforms The list of uniforms used in the effect
  12115. * @param defines the list of defines currently in use
  12116. */
  12117. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12118. /**
  12119. * Prepare the list of samplers associated with the Image Processing effects.
  12120. * @param samplersList The list of uniforms used in the effect
  12121. * @param defines the list of defines currently in use
  12122. */
  12123. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12124. /**
  12125. * Prepare the list of defines associated to the shader.
  12126. * @param defines the list of defines to complete
  12127. * @param forPostProcess Define if we are currently in post process mode or not
  12128. */
  12129. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12130. /**
  12131. * Returns true if all the image processing information are ready.
  12132. * @returns True if ready, otherwise, false
  12133. */
  12134. isReady(): boolean;
  12135. /**
  12136. * Binds the image processing to the shader.
  12137. * @param effect The effect to bind to
  12138. * @param overrideAspectRatio Override the aspect ratio of the effect
  12139. */
  12140. bind(effect: Effect, overrideAspectRatio?: number): void;
  12141. /**
  12142. * Clones the current image processing instance.
  12143. * @return The cloned image processing
  12144. */
  12145. clone(): ImageProcessingConfiguration;
  12146. /**
  12147. * Serializes the current image processing instance to a json representation.
  12148. * @return a JSON representation
  12149. */
  12150. serialize(): any;
  12151. /**
  12152. * Parses the image processing from a json representation.
  12153. * @param source the JSON source to parse
  12154. * @return The parsed image processing
  12155. */
  12156. static Parse(source: any): ImageProcessingConfiguration;
  12157. private static _VIGNETTEMODE_MULTIPLY;
  12158. private static _VIGNETTEMODE_OPAQUE;
  12159. /**
  12160. * Used to apply the vignette as a mix with the pixel color.
  12161. */
  12162. static get VIGNETTEMODE_MULTIPLY(): number;
  12163. /**
  12164. * Used to apply the vignette as a replacement of the pixel color.
  12165. */
  12166. static get VIGNETTEMODE_OPAQUE(): number;
  12167. }
  12168. }
  12169. declare module BABYLON {
  12170. /** @hidden */
  12171. export var postprocessVertexShader: {
  12172. name: string;
  12173. shader: string;
  12174. };
  12175. }
  12176. declare module BABYLON {
  12177. /**
  12178. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12179. */
  12180. export type RenderTargetTextureSize = number | {
  12181. width: number;
  12182. height: number;
  12183. layers?: number;
  12184. };
  12185. interface ThinEngine {
  12186. /**
  12187. * Creates a new render target texture
  12188. * @param size defines the size of the texture
  12189. * @param options defines the options used to create the texture
  12190. * @returns a new render target texture stored in an InternalTexture
  12191. */
  12192. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12193. /**
  12194. * Creates a depth stencil texture.
  12195. * This is only available in WebGL 2 or with the depth texture extension available.
  12196. * @param size The size of face edge in the texture.
  12197. * @param options The options defining the texture.
  12198. * @returns The texture
  12199. */
  12200. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12201. /** @hidden */
  12202. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12203. }
  12204. }
  12205. declare module BABYLON {
  12206. /**
  12207. * Defines the kind of connection point for node based material
  12208. */
  12209. export enum NodeMaterialBlockConnectionPointTypes {
  12210. /** Float */
  12211. Float = 1,
  12212. /** Int */
  12213. Int = 2,
  12214. /** Vector2 */
  12215. Vector2 = 4,
  12216. /** Vector3 */
  12217. Vector3 = 8,
  12218. /** Vector4 */
  12219. Vector4 = 16,
  12220. /** Color3 */
  12221. Color3 = 32,
  12222. /** Color4 */
  12223. Color4 = 64,
  12224. /** Matrix */
  12225. Matrix = 128,
  12226. /** Custom object */
  12227. Object = 256,
  12228. /** Detect type based on connection */
  12229. AutoDetect = 1024,
  12230. /** Output type that will be defined by input type */
  12231. BasedOnInput = 2048
  12232. }
  12233. }
  12234. declare module BABYLON {
  12235. /**
  12236. * Enum used to define the target of a block
  12237. */
  12238. export enum NodeMaterialBlockTargets {
  12239. /** Vertex shader */
  12240. Vertex = 1,
  12241. /** Fragment shader */
  12242. Fragment = 2,
  12243. /** Neutral */
  12244. Neutral = 4,
  12245. /** Vertex and Fragment */
  12246. VertexAndFragment = 3
  12247. }
  12248. }
  12249. declare module BABYLON {
  12250. /**
  12251. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12252. */
  12253. export enum NodeMaterialBlockConnectionPointMode {
  12254. /** Value is an uniform */
  12255. Uniform = 0,
  12256. /** Value is a mesh attribute */
  12257. Attribute = 1,
  12258. /** Value is a varying between vertex and fragment shaders */
  12259. Varying = 2,
  12260. /** Mode is undefined */
  12261. Undefined = 3
  12262. }
  12263. }
  12264. declare module BABYLON {
  12265. /**
  12266. * Enum used to define system values e.g. values automatically provided by the system
  12267. */
  12268. export enum NodeMaterialSystemValues {
  12269. /** World */
  12270. World = 1,
  12271. /** View */
  12272. View = 2,
  12273. /** Projection */
  12274. Projection = 3,
  12275. /** ViewProjection */
  12276. ViewProjection = 4,
  12277. /** WorldView */
  12278. WorldView = 5,
  12279. /** WorldViewProjection */
  12280. WorldViewProjection = 6,
  12281. /** CameraPosition */
  12282. CameraPosition = 7,
  12283. /** Fog Color */
  12284. FogColor = 8,
  12285. /** Delta time */
  12286. DeltaTime = 9
  12287. }
  12288. }
  12289. declare module BABYLON {
  12290. /**
  12291. * Represents a camera frustum
  12292. */
  12293. export class Frustum {
  12294. /**
  12295. * Gets the planes representing the frustum
  12296. * @param transform matrix to be applied to the returned planes
  12297. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12298. */
  12299. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12300. /**
  12301. * Gets the near frustum plane transformed by the transform matrix
  12302. * @param transform transformation matrix to be applied to the resulting frustum plane
  12303. * @param frustumPlane the resuling frustum plane
  12304. */
  12305. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12306. /**
  12307. * Gets the far frustum plane transformed by the transform matrix
  12308. * @param transform transformation matrix to be applied to the resulting frustum plane
  12309. * @param frustumPlane the resuling frustum plane
  12310. */
  12311. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12312. /**
  12313. * Gets the left frustum plane transformed by the transform matrix
  12314. * @param transform transformation matrix to be applied to the resulting frustum plane
  12315. * @param frustumPlane the resuling frustum plane
  12316. */
  12317. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12318. /**
  12319. * Gets the right frustum plane transformed by the transform matrix
  12320. * @param transform transformation matrix to be applied to the resulting frustum plane
  12321. * @param frustumPlane the resuling frustum plane
  12322. */
  12323. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12324. /**
  12325. * Gets the top frustum plane transformed by the transform matrix
  12326. * @param transform transformation matrix to be applied to the resulting frustum plane
  12327. * @param frustumPlane the resuling frustum plane
  12328. */
  12329. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12330. /**
  12331. * Gets the bottom frustum plane transformed by the transform matrix
  12332. * @param transform transformation matrix to be applied to the resulting frustum plane
  12333. * @param frustumPlane the resuling frustum plane
  12334. */
  12335. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12336. /**
  12337. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12338. * @param transform transformation matrix to be applied to the resulting frustum planes
  12339. * @param frustumPlanes the resuling frustum planes
  12340. */
  12341. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12342. }
  12343. }
  12344. declare module BABYLON {
  12345. /**
  12346. * Contains position and normal vectors for a vertex
  12347. */
  12348. export class PositionNormalVertex {
  12349. /** the position of the vertex (defaut: 0,0,0) */
  12350. position: Vector3;
  12351. /** the normal of the vertex (defaut: 0,1,0) */
  12352. normal: Vector3;
  12353. /**
  12354. * Creates a PositionNormalVertex
  12355. * @param position the position of the vertex (defaut: 0,0,0)
  12356. * @param normal the normal of the vertex (defaut: 0,1,0)
  12357. */
  12358. constructor(
  12359. /** the position of the vertex (defaut: 0,0,0) */
  12360. position?: Vector3,
  12361. /** the normal of the vertex (defaut: 0,1,0) */
  12362. normal?: Vector3);
  12363. /**
  12364. * Clones the PositionNormalVertex
  12365. * @returns the cloned PositionNormalVertex
  12366. */
  12367. clone(): PositionNormalVertex;
  12368. }
  12369. /**
  12370. * Contains position, normal and uv vectors for a vertex
  12371. */
  12372. export class PositionNormalTextureVertex {
  12373. /** the position of the vertex (defaut: 0,0,0) */
  12374. position: Vector3;
  12375. /** the normal of the vertex (defaut: 0,1,0) */
  12376. normal: Vector3;
  12377. /** the uv of the vertex (default: 0,0) */
  12378. uv: Vector2;
  12379. /**
  12380. * Creates a PositionNormalTextureVertex
  12381. * @param position the position of the vertex (defaut: 0,0,0)
  12382. * @param normal the normal of the vertex (defaut: 0,1,0)
  12383. * @param uv the uv of the vertex (default: 0,0)
  12384. */
  12385. constructor(
  12386. /** the position of the vertex (defaut: 0,0,0) */
  12387. position?: Vector3,
  12388. /** the normal of the vertex (defaut: 0,1,0) */
  12389. normal?: Vector3,
  12390. /** the uv of the vertex (default: 0,0) */
  12391. uv?: Vector2);
  12392. /**
  12393. * Clones the PositionNormalTextureVertex
  12394. * @returns the cloned PositionNormalTextureVertex
  12395. */
  12396. clone(): PositionNormalTextureVertex;
  12397. }
  12398. }
  12399. declare module BABYLON {
  12400. /**
  12401. * Enum defining the type of animations supported by InputBlock
  12402. */
  12403. export enum AnimatedInputBlockTypes {
  12404. /** No animation */
  12405. None = 0,
  12406. /** Time based animation. Will only work for floats */
  12407. Time = 1
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. /**
  12412. * Block used to expose an input value
  12413. */
  12414. export class InputBlock extends NodeMaterialBlock {
  12415. private _mode;
  12416. private _associatedVariableName;
  12417. private _storedValue;
  12418. private _valueCallback;
  12419. private _type;
  12420. private _animationType;
  12421. /** Gets or set a value used to limit the range of float values */
  12422. min: number;
  12423. /** Gets or set a value used to limit the range of float values */
  12424. max: number;
  12425. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12426. isBoolean: boolean;
  12427. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12428. matrixMode: number;
  12429. /** @hidden */
  12430. _systemValue: Nullable<NodeMaterialSystemValues>;
  12431. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12432. isConstant: boolean;
  12433. /** Gets or sets the group to use to display this block in the Inspector */
  12434. groupInInspector: string;
  12435. /** Gets an observable raised when the value is changed */
  12436. onValueChangedObservable: Observable<InputBlock>;
  12437. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12438. convertToGammaSpace: boolean;
  12439. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12440. convertToLinearSpace: boolean;
  12441. /**
  12442. * Gets or sets the connection point type (default is float)
  12443. */
  12444. get type(): NodeMaterialBlockConnectionPointTypes;
  12445. /**
  12446. * Creates a new InputBlock
  12447. * @param name defines the block name
  12448. * @param target defines the target of that block (Vertex by default)
  12449. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12450. */
  12451. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12452. /**
  12453. * Validates if a name is a reserve word.
  12454. * @param newName the new name to be given to the node.
  12455. * @returns false if the name is a reserve word, else true.
  12456. */
  12457. validateBlockName(newName: string): boolean;
  12458. /**
  12459. * Gets the output component
  12460. */
  12461. get output(): NodeMaterialConnectionPoint;
  12462. /**
  12463. * Set the source of this connection point to a vertex attribute
  12464. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12465. * @returns the current connection point
  12466. */
  12467. setAsAttribute(attributeName?: string): InputBlock;
  12468. /**
  12469. * Set the source of this connection point to a system value
  12470. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12471. * @returns the current connection point
  12472. */
  12473. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12474. /**
  12475. * Gets or sets the value of that point.
  12476. * Please note that this value will be ignored if valueCallback is defined
  12477. */
  12478. get value(): any;
  12479. set value(value: any);
  12480. /**
  12481. * Gets or sets a callback used to get the value of that point.
  12482. * Please note that setting this value will force the connection point to ignore the value property
  12483. */
  12484. get valueCallback(): () => any;
  12485. set valueCallback(value: () => any);
  12486. /**
  12487. * Gets or sets the associated variable name in the shader
  12488. */
  12489. get associatedVariableName(): string;
  12490. set associatedVariableName(value: string);
  12491. /** Gets or sets the type of animation applied to the input */
  12492. get animationType(): AnimatedInputBlockTypes;
  12493. set animationType(value: AnimatedInputBlockTypes);
  12494. /**
  12495. * Gets a boolean indicating that this connection point not defined yet
  12496. */
  12497. get isUndefined(): boolean;
  12498. /**
  12499. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12500. * In this case the connection point name must be the name of the uniform to use.
  12501. * Can only be set on inputs
  12502. */
  12503. get isUniform(): boolean;
  12504. set isUniform(value: boolean);
  12505. /**
  12506. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12507. * In this case the connection point name must be the name of the attribute to use
  12508. * Can only be set on inputs
  12509. */
  12510. get isAttribute(): boolean;
  12511. set isAttribute(value: boolean);
  12512. /**
  12513. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12514. * Can only be set on exit points
  12515. */
  12516. get isVarying(): boolean;
  12517. set isVarying(value: boolean);
  12518. /**
  12519. * Gets a boolean indicating that the current connection point is a system value
  12520. */
  12521. get isSystemValue(): boolean;
  12522. /**
  12523. * Gets or sets the current well known value or null if not defined as a system value
  12524. */
  12525. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12526. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12527. /**
  12528. * Gets the current class name
  12529. * @returns the class name
  12530. */
  12531. getClassName(): string;
  12532. /**
  12533. * Animate the input if animationType !== None
  12534. * @param scene defines the rendering scene
  12535. */
  12536. animate(scene: Scene): void;
  12537. private _emitDefine;
  12538. initialize(state: NodeMaterialBuildState): void;
  12539. /**
  12540. * Set the input block to its default value (based on its type)
  12541. */
  12542. setDefaultValue(): void;
  12543. private _emitConstant;
  12544. /** @hidden */
  12545. get _noContextSwitch(): boolean;
  12546. private _emit;
  12547. /** @hidden */
  12548. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12549. /** @hidden */
  12550. _transmit(effect: Effect, scene: Scene): void;
  12551. protected _buildBlock(state: NodeMaterialBuildState): void;
  12552. protected _dumpPropertiesCode(): string;
  12553. dispose(): void;
  12554. serialize(): any;
  12555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12556. }
  12557. }
  12558. declare module BABYLON {
  12559. /**
  12560. * Enum used to define the compatibility state between two connection points
  12561. */
  12562. export enum NodeMaterialConnectionPointCompatibilityStates {
  12563. /** Points are compatibles */
  12564. Compatible = 0,
  12565. /** Points are incompatible because of their types */
  12566. TypeIncompatible = 1,
  12567. /** Points are incompatible because of their targets (vertex vs fragment) */
  12568. TargetIncompatible = 2
  12569. }
  12570. /**
  12571. * Defines the direction of a connection point
  12572. */
  12573. export enum NodeMaterialConnectionPointDirection {
  12574. /** Input */
  12575. Input = 0,
  12576. /** Output */
  12577. Output = 1
  12578. }
  12579. /**
  12580. * Defines a connection point for a block
  12581. */
  12582. export class NodeMaterialConnectionPoint {
  12583. /**
  12584. * Checks if two types are equivalent
  12585. * @param type1 type 1 to check
  12586. * @param type2 type 2 to check
  12587. * @returns true if both types are equivalent, else false
  12588. */
  12589. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12590. /** @hidden */
  12591. _ownerBlock: NodeMaterialBlock;
  12592. /** @hidden */
  12593. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12594. private _endpoints;
  12595. private _associatedVariableName;
  12596. private _direction;
  12597. /** @hidden */
  12598. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12599. /** @hidden */
  12600. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12601. /** @hidden */
  12602. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12603. private _type;
  12604. /** @hidden */
  12605. _enforceAssociatedVariableName: boolean;
  12606. /** Gets the direction of the point */
  12607. get direction(): NodeMaterialConnectionPointDirection;
  12608. /** Indicates that this connection point needs dual validation before being connected to another point */
  12609. needDualDirectionValidation: boolean;
  12610. /**
  12611. * Gets or sets the additional types supported by this connection point
  12612. */
  12613. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12614. /**
  12615. * Gets or sets the additional types excluded by this connection point
  12616. */
  12617. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12618. /**
  12619. * Observable triggered when this point is connected
  12620. */
  12621. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12622. /**
  12623. * Gets or sets the associated variable name in the shader
  12624. */
  12625. get associatedVariableName(): string;
  12626. set associatedVariableName(value: string);
  12627. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12628. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12629. /**
  12630. * Gets or sets the connection point type (default is float)
  12631. */
  12632. get type(): NodeMaterialBlockConnectionPointTypes;
  12633. set type(value: NodeMaterialBlockConnectionPointTypes);
  12634. /**
  12635. * Gets or sets the connection point name
  12636. */
  12637. name: string;
  12638. /**
  12639. * Gets or sets the connection point name
  12640. */
  12641. displayName: string;
  12642. /**
  12643. * Gets or sets a boolean indicating that this connection point can be omitted
  12644. */
  12645. isOptional: boolean;
  12646. /**
  12647. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12648. */
  12649. isExposedOnFrame: boolean;
  12650. /**
  12651. * Gets or sets number indicating the position that the port is exposed to on a frame
  12652. */
  12653. exposedPortPosition: number;
  12654. /**
  12655. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12656. */
  12657. define: string;
  12658. /** @hidden */
  12659. _prioritizeVertex: boolean;
  12660. private _target;
  12661. /** Gets or sets the target of that connection point */
  12662. get target(): NodeMaterialBlockTargets;
  12663. set target(value: NodeMaterialBlockTargets);
  12664. /**
  12665. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12666. */
  12667. get isConnected(): boolean;
  12668. /**
  12669. * Gets a boolean indicating that the current point is connected to an input block
  12670. */
  12671. get isConnectedToInputBlock(): boolean;
  12672. /**
  12673. * Gets a the connected input block (if any)
  12674. */
  12675. get connectInputBlock(): Nullable<InputBlock>;
  12676. /** Get the other side of the connection (if any) */
  12677. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12678. /** Get the block that owns this connection point */
  12679. get ownerBlock(): NodeMaterialBlock;
  12680. /** Get the block connected on the other side of this connection (if any) */
  12681. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12682. /** Get the block connected on the endpoints of this connection (if any) */
  12683. get connectedBlocks(): Array<NodeMaterialBlock>;
  12684. /** Gets the list of connected endpoints */
  12685. get endpoints(): NodeMaterialConnectionPoint[];
  12686. /** Gets a boolean indicating if that output point is connected to at least one input */
  12687. get hasEndpoints(): boolean;
  12688. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12689. get isConnectedInVertexShader(): boolean;
  12690. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12691. get isConnectedInFragmentShader(): boolean;
  12692. /**
  12693. * Creates a block suitable to be used as an input for this input point.
  12694. * If null is returned, a block based on the point type will be created.
  12695. * @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
  12696. */
  12697. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12698. /**
  12699. * Creates a new connection point
  12700. * @param name defines the connection point name
  12701. * @param ownerBlock defines the block hosting this connection point
  12702. * @param direction defines the direction of the connection point
  12703. */
  12704. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12705. /**
  12706. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12707. * @returns the class name
  12708. */
  12709. getClassName(): string;
  12710. /**
  12711. * Gets a boolean indicating if the current point can be connected to another point
  12712. * @param connectionPoint defines the other connection point
  12713. * @returns a boolean
  12714. */
  12715. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12716. /**
  12717. * Gets a number indicating if the current point can be connected to another point
  12718. * @param connectionPoint defines the other connection point
  12719. * @returns a number defining the compatibility state
  12720. */
  12721. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12722. /**
  12723. * Connect this point to another connection point
  12724. * @param connectionPoint defines the other connection point
  12725. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12726. * @returns the current connection point
  12727. */
  12728. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12729. /**
  12730. * Disconnect this point from one of his endpoint
  12731. * @param endpoint defines the other connection point
  12732. * @returns the current connection point
  12733. */
  12734. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12735. /**
  12736. * Serializes this point in a JSON representation
  12737. * @param isInput defines if the connection point is an input (default is true)
  12738. * @returns the serialized point object
  12739. */
  12740. serialize(isInput?: boolean): any;
  12741. /**
  12742. * Release resources
  12743. */
  12744. dispose(): void;
  12745. }
  12746. }
  12747. declare module BABYLON {
  12748. /**
  12749. * Enum used to define the material modes
  12750. */
  12751. export enum NodeMaterialModes {
  12752. /** Regular material */
  12753. Material = 0,
  12754. /** For post process */
  12755. PostProcess = 1,
  12756. /** For particle system */
  12757. Particle = 2,
  12758. /** For procedural texture */
  12759. ProceduralTexture = 3
  12760. }
  12761. }
  12762. declare module BABYLON {
  12763. /** @hidden */
  12764. export var helperFunctions: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module BABYLON {
  12770. /**
  12771. * Block used to read a texture from a sampler
  12772. */
  12773. export class TextureBlock extends NodeMaterialBlock {
  12774. private _defineName;
  12775. private _linearDefineName;
  12776. private _gammaDefineName;
  12777. private _tempTextureRead;
  12778. private _samplerName;
  12779. private _transformedUVName;
  12780. private _textureTransformName;
  12781. private _textureInfoName;
  12782. private _mainUVName;
  12783. private _mainUVDefineName;
  12784. private _fragmentOnly;
  12785. /**
  12786. * Gets or sets the texture associated with the node
  12787. */
  12788. texture: Nullable<Texture>;
  12789. /**
  12790. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12791. */
  12792. convertToGammaSpace: boolean;
  12793. /**
  12794. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12795. */
  12796. convertToLinearSpace: boolean;
  12797. /**
  12798. * Create a new TextureBlock
  12799. * @param name defines the block name
  12800. */
  12801. constructor(name: string, fragmentOnly?: boolean);
  12802. /**
  12803. * Gets the current class name
  12804. * @returns the class name
  12805. */
  12806. getClassName(): string;
  12807. /**
  12808. * Gets the uv input component
  12809. */
  12810. get uv(): NodeMaterialConnectionPoint;
  12811. /**
  12812. * Gets the rgba output component
  12813. */
  12814. get rgba(): NodeMaterialConnectionPoint;
  12815. /**
  12816. * Gets the rgb output component
  12817. */
  12818. get rgb(): NodeMaterialConnectionPoint;
  12819. /**
  12820. * Gets the r output component
  12821. */
  12822. get r(): NodeMaterialConnectionPoint;
  12823. /**
  12824. * Gets the g output component
  12825. */
  12826. get g(): NodeMaterialConnectionPoint;
  12827. /**
  12828. * Gets the b output component
  12829. */
  12830. get b(): NodeMaterialConnectionPoint;
  12831. /**
  12832. * Gets the a output component
  12833. */
  12834. get a(): NodeMaterialConnectionPoint;
  12835. get target(): NodeMaterialBlockTargets;
  12836. autoConfigure(material: NodeMaterial): void;
  12837. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12839. isReady(): boolean;
  12840. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12841. private get _isMixed();
  12842. private _injectVertexCode;
  12843. private _writeTextureRead;
  12844. private _writeOutput;
  12845. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12846. protected _dumpPropertiesCode(): string;
  12847. serialize(): any;
  12848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12849. }
  12850. }
  12851. declare module BABYLON {
  12852. /** @hidden */
  12853. export var reflectionFunction: {
  12854. name: string;
  12855. shader: string;
  12856. };
  12857. }
  12858. declare module BABYLON {
  12859. /**
  12860. * Base block used to read a reflection texture from a sampler
  12861. */
  12862. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12863. /** @hidden */
  12864. _define3DName: string;
  12865. /** @hidden */
  12866. _defineCubicName: string;
  12867. /** @hidden */
  12868. _defineExplicitName: string;
  12869. /** @hidden */
  12870. _defineProjectionName: string;
  12871. /** @hidden */
  12872. _defineLocalCubicName: string;
  12873. /** @hidden */
  12874. _defineSphericalName: string;
  12875. /** @hidden */
  12876. _definePlanarName: string;
  12877. /** @hidden */
  12878. _defineEquirectangularName: string;
  12879. /** @hidden */
  12880. _defineMirroredEquirectangularFixedName: string;
  12881. /** @hidden */
  12882. _defineEquirectangularFixedName: string;
  12883. /** @hidden */
  12884. _defineSkyboxName: string;
  12885. /** @hidden */
  12886. _defineOppositeZ: string;
  12887. /** @hidden */
  12888. _cubeSamplerName: string;
  12889. /** @hidden */
  12890. _2DSamplerName: string;
  12891. protected _positionUVWName: string;
  12892. protected _directionWName: string;
  12893. protected _reflectionVectorName: string;
  12894. /** @hidden */
  12895. _reflectionCoordsName: string;
  12896. /** @hidden */
  12897. _reflectionMatrixName: string;
  12898. protected _reflectionColorName: string;
  12899. /**
  12900. * Gets or sets the texture associated with the node
  12901. */
  12902. texture: Nullable<BaseTexture>;
  12903. /**
  12904. * Create a new ReflectionTextureBaseBlock
  12905. * @param name defines the block name
  12906. */
  12907. constructor(name: string);
  12908. /**
  12909. * Gets the current class name
  12910. * @returns the class name
  12911. */
  12912. getClassName(): string;
  12913. /**
  12914. * Gets the world position input component
  12915. */
  12916. abstract get position(): NodeMaterialConnectionPoint;
  12917. /**
  12918. * Gets the world position input component
  12919. */
  12920. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12921. /**
  12922. * Gets the world normal input component
  12923. */
  12924. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12925. /**
  12926. * Gets the world input component
  12927. */
  12928. abstract get world(): NodeMaterialConnectionPoint;
  12929. /**
  12930. * Gets the camera (or eye) position component
  12931. */
  12932. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12933. /**
  12934. * Gets the view input component
  12935. */
  12936. abstract get view(): NodeMaterialConnectionPoint;
  12937. protected _getTexture(): Nullable<BaseTexture>;
  12938. autoConfigure(material: NodeMaterial): void;
  12939. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12940. isReady(): boolean;
  12941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12942. /**
  12943. * Gets the code to inject in the vertex shader
  12944. * @param state current state of the node material building
  12945. * @returns the shader code
  12946. */
  12947. handleVertexSide(state: NodeMaterialBuildState): string;
  12948. /**
  12949. * Handles the inits for the fragment code path
  12950. * @param state node material build state
  12951. */
  12952. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12953. /**
  12954. * Generates the reflection coords code for the fragment code path
  12955. * @param worldNormalVarName name of the world normal variable
  12956. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12957. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12958. * @returns the shader code
  12959. */
  12960. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12961. /**
  12962. * Generates the reflection color code for the fragment code path
  12963. * @param lodVarName name of the lod variable
  12964. * @param swizzleLookupTexture swizzle to use for the final color variable
  12965. * @returns the shader code
  12966. */
  12967. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12968. /**
  12969. * Generates the code corresponding to the connected output points
  12970. * @param state node material build state
  12971. * @param varName name of the variable to output
  12972. * @returns the shader code
  12973. */
  12974. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12975. protected _buildBlock(state: NodeMaterialBuildState): this;
  12976. protected _dumpPropertiesCode(): string;
  12977. serialize(): any;
  12978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12979. }
  12980. }
  12981. declare module BABYLON {
  12982. /**
  12983. * Defines a connection point to be used for points with a custom object type
  12984. */
  12985. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12986. private _blockType;
  12987. private _blockName;
  12988. private _nameForCheking?;
  12989. /**
  12990. * Creates a new connection point
  12991. * @param name defines the connection point name
  12992. * @param ownerBlock defines the block hosting this connection point
  12993. * @param direction defines the direction of the connection point
  12994. */
  12995. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12996. /**
  12997. * Gets a number indicating if the current point can be connected to another point
  12998. * @param connectionPoint defines the other connection point
  12999. * @returns a number defining the compatibility state
  13000. */
  13001. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13002. /**
  13003. * Creates a block suitable to be used as an input for this input point.
  13004. * If null is returned, a block based on the point type will be created.
  13005. * @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
  13006. */
  13007. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13008. }
  13009. }
  13010. declare module BABYLON {
  13011. /**
  13012. * Enum defining the type of properties that can be edited in the property pages in the NME
  13013. */
  13014. export enum PropertyTypeForEdition {
  13015. /** property is a boolean */
  13016. Boolean = 0,
  13017. /** property is a float */
  13018. Float = 1,
  13019. /** property is a Vector2 */
  13020. Vector2 = 2,
  13021. /** property is a list of values */
  13022. List = 3
  13023. }
  13024. /**
  13025. * Interface that defines an option in a variable of type list
  13026. */
  13027. export interface IEditablePropertyListOption {
  13028. /** label of the option */
  13029. "label": string;
  13030. /** value of the option */
  13031. "value": number;
  13032. }
  13033. /**
  13034. * Interface that defines the options available for an editable property
  13035. */
  13036. export interface IEditablePropertyOption {
  13037. /** min value */
  13038. "min"?: number;
  13039. /** max value */
  13040. "max"?: number;
  13041. /** notifiers: indicates which actions to take when the property is changed */
  13042. "notifiers"?: {
  13043. /** the material should be rebuilt */
  13044. "rebuild"?: boolean;
  13045. /** the preview should be updated */
  13046. "update"?: boolean;
  13047. };
  13048. /** list of the options for a variable of type list */
  13049. "options"?: IEditablePropertyListOption[];
  13050. }
  13051. /**
  13052. * Interface that describes an editable property
  13053. */
  13054. export interface IPropertyDescriptionForEdition {
  13055. /** name of the property */
  13056. "propertyName": string;
  13057. /** display name of the property */
  13058. "displayName": string;
  13059. /** type of the property */
  13060. "type": PropertyTypeForEdition;
  13061. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13062. "groupName": string;
  13063. /** options for the property */
  13064. "options": IEditablePropertyOption;
  13065. }
  13066. /**
  13067. * Decorator that flags a property in a node material block as being editable
  13068. */
  13069. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13070. }
  13071. declare module BABYLON {
  13072. /**
  13073. * Block used to implement the refraction part of the sub surface module of the PBR material
  13074. */
  13075. export class RefractionBlock extends NodeMaterialBlock {
  13076. /** @hidden */
  13077. _define3DName: string;
  13078. /** @hidden */
  13079. _refractionMatrixName: string;
  13080. /** @hidden */
  13081. _defineLODRefractionAlpha: string;
  13082. /** @hidden */
  13083. _defineLinearSpecularRefraction: string;
  13084. /** @hidden */
  13085. _defineOppositeZ: string;
  13086. /** @hidden */
  13087. _cubeSamplerName: string;
  13088. /** @hidden */
  13089. _2DSamplerName: string;
  13090. /** @hidden */
  13091. _vRefractionMicrosurfaceInfosName: string;
  13092. /** @hidden */
  13093. _vRefractionInfosName: string;
  13094. /** @hidden */
  13095. _vRefractionFilteringInfoName: string;
  13096. private _scene;
  13097. /**
  13098. * The properties below are set by the main PBR block prior to calling methods of this class.
  13099. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13100. * It's less burden on the user side in the editor part.
  13101. */
  13102. /** @hidden */
  13103. viewConnectionPoint: NodeMaterialConnectionPoint;
  13104. /** @hidden */
  13105. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13106. /**
  13107. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13108. * Materials half opaque for instance using refraction could benefit from this control.
  13109. */
  13110. linkRefractionWithTransparency: boolean;
  13111. /**
  13112. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13113. */
  13114. invertRefractionY: boolean;
  13115. /**
  13116. * Gets or sets the texture associated with the node
  13117. */
  13118. texture: Nullable<BaseTexture>;
  13119. /**
  13120. * Create a new RefractionBlock
  13121. * @param name defines the block name
  13122. */
  13123. constructor(name: string);
  13124. /**
  13125. * Gets the current class name
  13126. * @returns the class name
  13127. */
  13128. getClassName(): string;
  13129. /**
  13130. * Gets the intensity input component
  13131. */
  13132. get intensity(): NodeMaterialConnectionPoint;
  13133. /**
  13134. * Gets the tint at distance input component
  13135. */
  13136. get tintAtDistance(): NodeMaterialConnectionPoint;
  13137. /**
  13138. * Gets the view input component
  13139. */
  13140. get view(): NodeMaterialConnectionPoint;
  13141. /**
  13142. * Gets the refraction object output component
  13143. */
  13144. get refraction(): NodeMaterialConnectionPoint;
  13145. /**
  13146. * Returns true if the block has a texture
  13147. */
  13148. get hasTexture(): boolean;
  13149. protected _getTexture(): Nullable<BaseTexture>;
  13150. autoConfigure(material: NodeMaterial): void;
  13151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13152. isReady(): boolean;
  13153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13154. /**
  13155. * Gets the main code of the block (fragment side)
  13156. * @param state current state of the node material building
  13157. * @returns the shader code
  13158. */
  13159. getCode(state: NodeMaterialBuildState): string;
  13160. protected _buildBlock(state: NodeMaterialBuildState): this;
  13161. protected _dumpPropertiesCode(): string;
  13162. serialize(): any;
  13163. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13164. }
  13165. }
  13166. declare module BABYLON {
  13167. /**
  13168. * Base block used as input for post process
  13169. */
  13170. export class CurrentScreenBlock extends NodeMaterialBlock {
  13171. private _samplerName;
  13172. private _linearDefineName;
  13173. private _gammaDefineName;
  13174. private _mainUVName;
  13175. private _tempTextureRead;
  13176. /**
  13177. * Gets or sets the texture associated with the node
  13178. */
  13179. texture: Nullable<BaseTexture>;
  13180. /**
  13181. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13182. */
  13183. convertToGammaSpace: boolean;
  13184. /**
  13185. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13186. */
  13187. convertToLinearSpace: boolean;
  13188. /**
  13189. * Create a new CurrentScreenBlock
  13190. * @param name defines the block name
  13191. */
  13192. constructor(name: string);
  13193. /**
  13194. * Gets the current class name
  13195. * @returns the class name
  13196. */
  13197. getClassName(): string;
  13198. /**
  13199. * Gets the uv input component
  13200. */
  13201. get uv(): NodeMaterialConnectionPoint;
  13202. /**
  13203. * Gets the rgba output component
  13204. */
  13205. get rgba(): NodeMaterialConnectionPoint;
  13206. /**
  13207. * Gets the rgb output component
  13208. */
  13209. get rgb(): NodeMaterialConnectionPoint;
  13210. /**
  13211. * Gets the r output component
  13212. */
  13213. get r(): NodeMaterialConnectionPoint;
  13214. /**
  13215. * Gets the g output component
  13216. */
  13217. get g(): NodeMaterialConnectionPoint;
  13218. /**
  13219. * Gets the b output component
  13220. */
  13221. get b(): NodeMaterialConnectionPoint;
  13222. /**
  13223. * Gets the a output component
  13224. */
  13225. get a(): NodeMaterialConnectionPoint;
  13226. /**
  13227. * Initialize the block and prepare the context for build
  13228. * @param state defines the state that will be used for the build
  13229. */
  13230. initialize(state: NodeMaterialBuildState): void;
  13231. get target(): NodeMaterialBlockTargets;
  13232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13233. isReady(): boolean;
  13234. private _injectVertexCode;
  13235. private _writeTextureRead;
  13236. private _writeOutput;
  13237. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13238. serialize(): any;
  13239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13240. }
  13241. }
  13242. declare module BABYLON {
  13243. /**
  13244. * Base block used for the particle texture
  13245. */
  13246. export class ParticleTextureBlock extends NodeMaterialBlock {
  13247. private _samplerName;
  13248. private _linearDefineName;
  13249. private _gammaDefineName;
  13250. private _tempTextureRead;
  13251. /**
  13252. * Gets or sets the texture associated with the node
  13253. */
  13254. texture: Nullable<BaseTexture>;
  13255. /**
  13256. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13257. */
  13258. convertToGammaSpace: boolean;
  13259. /**
  13260. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13261. */
  13262. convertToLinearSpace: boolean;
  13263. /**
  13264. * Create a new ParticleTextureBlock
  13265. * @param name defines the block name
  13266. */
  13267. constructor(name: string);
  13268. /**
  13269. * Gets the current class name
  13270. * @returns the class name
  13271. */
  13272. getClassName(): string;
  13273. /**
  13274. * Gets the uv input component
  13275. */
  13276. get uv(): NodeMaterialConnectionPoint;
  13277. /**
  13278. * Gets the rgba output component
  13279. */
  13280. get rgba(): NodeMaterialConnectionPoint;
  13281. /**
  13282. * Gets the rgb output component
  13283. */
  13284. get rgb(): NodeMaterialConnectionPoint;
  13285. /**
  13286. * Gets the r output component
  13287. */
  13288. get r(): NodeMaterialConnectionPoint;
  13289. /**
  13290. * Gets the g output component
  13291. */
  13292. get g(): NodeMaterialConnectionPoint;
  13293. /**
  13294. * Gets the b output component
  13295. */
  13296. get b(): NodeMaterialConnectionPoint;
  13297. /**
  13298. * Gets the a output component
  13299. */
  13300. get a(): NodeMaterialConnectionPoint;
  13301. /**
  13302. * Initialize the block and prepare the context for build
  13303. * @param state defines the state that will be used for the build
  13304. */
  13305. initialize(state: NodeMaterialBuildState): void;
  13306. autoConfigure(material: NodeMaterial): void;
  13307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13308. isReady(): boolean;
  13309. private _writeOutput;
  13310. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13311. serialize(): any;
  13312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13313. }
  13314. }
  13315. declare module BABYLON {
  13316. /**
  13317. * Class used to store shared data between 2 NodeMaterialBuildState
  13318. */
  13319. export class NodeMaterialBuildStateSharedData {
  13320. /**
  13321. * Gets the list of emitted varyings
  13322. */
  13323. temps: string[];
  13324. /**
  13325. * Gets the list of emitted varyings
  13326. */
  13327. varyings: string[];
  13328. /**
  13329. * Gets the varying declaration string
  13330. */
  13331. varyingDeclaration: string;
  13332. /**
  13333. * Input blocks
  13334. */
  13335. inputBlocks: InputBlock[];
  13336. /**
  13337. * Input blocks
  13338. */
  13339. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13340. /**
  13341. * Bindable blocks (Blocks that need to set data to the effect)
  13342. */
  13343. bindableBlocks: NodeMaterialBlock[];
  13344. /**
  13345. * List of blocks that can provide a compilation fallback
  13346. */
  13347. blocksWithFallbacks: NodeMaterialBlock[];
  13348. /**
  13349. * List of blocks that can provide a define update
  13350. */
  13351. blocksWithDefines: NodeMaterialBlock[];
  13352. /**
  13353. * List of blocks that can provide a repeatable content
  13354. */
  13355. repeatableContentBlocks: NodeMaterialBlock[];
  13356. /**
  13357. * List of blocks that can provide a dynamic list of uniforms
  13358. */
  13359. dynamicUniformBlocks: NodeMaterialBlock[];
  13360. /**
  13361. * List of blocks that can block the isReady function for the material
  13362. */
  13363. blockingBlocks: NodeMaterialBlock[];
  13364. /**
  13365. * Gets the list of animated inputs
  13366. */
  13367. animatedInputs: InputBlock[];
  13368. /**
  13369. * Build Id used to avoid multiple recompilations
  13370. */
  13371. buildId: number;
  13372. /** List of emitted variables */
  13373. variableNames: {
  13374. [key: string]: number;
  13375. };
  13376. /** List of emitted defines */
  13377. defineNames: {
  13378. [key: string]: number;
  13379. };
  13380. /** Should emit comments? */
  13381. emitComments: boolean;
  13382. /** Emit build activity */
  13383. verbose: boolean;
  13384. /** Gets or sets the hosting scene */
  13385. scene: Scene;
  13386. /**
  13387. * Gets the compilation hints emitted at compilation time
  13388. */
  13389. hints: {
  13390. needWorldViewMatrix: boolean;
  13391. needWorldViewProjectionMatrix: boolean;
  13392. needAlphaBlending: boolean;
  13393. needAlphaTesting: boolean;
  13394. };
  13395. /**
  13396. * List of compilation checks
  13397. */
  13398. checks: {
  13399. emitVertex: boolean;
  13400. emitFragment: boolean;
  13401. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13402. };
  13403. /**
  13404. * Is vertex program allowed to be empty?
  13405. */
  13406. allowEmptyVertexProgram: boolean;
  13407. /** Creates a new shared data */
  13408. constructor();
  13409. /**
  13410. * Emits console errors and exceptions if there is a failing check
  13411. */
  13412. emitErrors(): void;
  13413. }
  13414. }
  13415. declare module BABYLON {
  13416. /**
  13417. * Class used to store node based material build state
  13418. */
  13419. export class NodeMaterialBuildState {
  13420. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13421. supportUniformBuffers: boolean;
  13422. /**
  13423. * Gets the list of emitted attributes
  13424. */
  13425. attributes: string[];
  13426. /**
  13427. * Gets the list of emitted uniforms
  13428. */
  13429. uniforms: string[];
  13430. /**
  13431. * Gets the list of emitted constants
  13432. */
  13433. constants: string[];
  13434. /**
  13435. * Gets the list of emitted samplers
  13436. */
  13437. samplers: string[];
  13438. /**
  13439. * Gets the list of emitted functions
  13440. */
  13441. functions: {
  13442. [key: string]: string;
  13443. };
  13444. /**
  13445. * Gets the list of emitted extensions
  13446. */
  13447. extensions: {
  13448. [key: string]: string;
  13449. };
  13450. /**
  13451. * Gets the target of the compilation state
  13452. */
  13453. target: NodeMaterialBlockTargets;
  13454. /**
  13455. * Gets the list of emitted counters
  13456. */
  13457. counters: {
  13458. [key: string]: number;
  13459. };
  13460. /**
  13461. * Shared data between multiple NodeMaterialBuildState instances
  13462. */
  13463. sharedData: NodeMaterialBuildStateSharedData;
  13464. /** @hidden */
  13465. _vertexState: NodeMaterialBuildState;
  13466. /** @hidden */
  13467. _attributeDeclaration: string;
  13468. /** @hidden */
  13469. _uniformDeclaration: string;
  13470. /** @hidden */
  13471. _constantDeclaration: string;
  13472. /** @hidden */
  13473. _samplerDeclaration: string;
  13474. /** @hidden */
  13475. _varyingTransfer: string;
  13476. /** @hidden */
  13477. _injectAtEnd: string;
  13478. private _repeatableContentAnchorIndex;
  13479. /** @hidden */
  13480. _builtCompilationString: string;
  13481. /**
  13482. * Gets the emitted compilation strings
  13483. */
  13484. compilationString: string;
  13485. /**
  13486. * Finalize the compilation strings
  13487. * @param state defines the current compilation state
  13488. */
  13489. finalize(state: NodeMaterialBuildState): void;
  13490. /** @hidden */
  13491. get _repeatableContentAnchor(): string;
  13492. /** @hidden */
  13493. _getFreeVariableName(prefix: string): string;
  13494. /** @hidden */
  13495. _getFreeDefineName(prefix: string): string;
  13496. /** @hidden */
  13497. _excludeVariableName(name: string): void;
  13498. /** @hidden */
  13499. _emit2DSampler(name: string): void;
  13500. /** @hidden */
  13501. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13502. /** @hidden */
  13503. _emitExtension(name: string, extension: string, define?: string): void;
  13504. /** @hidden */
  13505. _emitFunction(name: string, code: string, comments: string): void;
  13506. /** @hidden */
  13507. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13508. replaceStrings?: {
  13509. search: RegExp;
  13510. replace: string;
  13511. }[];
  13512. repeatKey?: string;
  13513. }): string;
  13514. /** @hidden */
  13515. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13516. repeatKey?: string;
  13517. removeAttributes?: boolean;
  13518. removeUniforms?: boolean;
  13519. removeVaryings?: boolean;
  13520. removeIfDef?: boolean;
  13521. replaceStrings?: {
  13522. search: RegExp;
  13523. replace: string;
  13524. }[];
  13525. }, storeKey?: string): void;
  13526. /** @hidden */
  13527. _registerTempVariable(name: string): boolean;
  13528. /** @hidden */
  13529. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13530. /** @hidden */
  13531. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13532. /** @hidden */
  13533. _emitFloat(value: number): string;
  13534. }
  13535. }
  13536. declare module BABYLON {
  13537. /**
  13538. * Helper class used to generate session unique ID
  13539. */
  13540. export class UniqueIdGenerator {
  13541. private static _UniqueIdCounter;
  13542. /**
  13543. * Gets an unique (relatively to the current scene) Id
  13544. */
  13545. static get UniqueId(): number;
  13546. }
  13547. }
  13548. declare module BABYLON {
  13549. /**
  13550. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13551. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13552. */
  13553. export class EffectFallbacks implements IEffectFallbacks {
  13554. private _defines;
  13555. private _currentRank;
  13556. private _maxRank;
  13557. private _mesh;
  13558. /**
  13559. * Removes the fallback from the bound mesh.
  13560. */
  13561. unBindMesh(): void;
  13562. /**
  13563. * Adds a fallback on the specified property.
  13564. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13565. * @param define The name of the define in the shader
  13566. */
  13567. addFallback(rank: number, define: string): void;
  13568. /**
  13569. * Sets the mesh to use CPU skinning when needing to fallback.
  13570. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13571. * @param mesh The mesh to use the fallbacks.
  13572. */
  13573. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13574. /**
  13575. * Checks to see if more fallbacks are still availible.
  13576. */
  13577. get hasMoreFallbacks(): boolean;
  13578. /**
  13579. * Removes the defines that should be removed when falling back.
  13580. * @param currentDefines defines the current define statements for the shader.
  13581. * @param effect defines the current effect we try to compile
  13582. * @returns The resulting defines with defines of the current rank removed.
  13583. */
  13584. reduce(currentDefines: string, effect: Effect): string;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Defines a block that can be used inside a node based material
  13590. */
  13591. export class NodeMaterialBlock {
  13592. private _buildId;
  13593. private _buildTarget;
  13594. private _target;
  13595. private _isFinalMerger;
  13596. private _isInput;
  13597. private _name;
  13598. protected _isUnique: boolean;
  13599. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13600. inputsAreExclusive: boolean;
  13601. /** @hidden */
  13602. _codeVariableName: string;
  13603. /** @hidden */
  13604. _inputs: NodeMaterialConnectionPoint[];
  13605. /** @hidden */
  13606. _outputs: NodeMaterialConnectionPoint[];
  13607. /** @hidden */
  13608. _preparationId: number;
  13609. /** @hidden */
  13610. readonly _originalTargetIsNeutral: boolean;
  13611. /**
  13612. * Gets the name of the block
  13613. */
  13614. get name(): string;
  13615. /**
  13616. * Sets the name of the block. Will check if the name is valid.
  13617. */
  13618. set name(newName: string);
  13619. /**
  13620. * Gets or sets the unique id of the node
  13621. */
  13622. uniqueId: number;
  13623. /**
  13624. * Gets or sets the comments associated with this block
  13625. */
  13626. comments: string;
  13627. /**
  13628. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13629. */
  13630. get isUnique(): boolean;
  13631. /**
  13632. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13633. */
  13634. get isFinalMerger(): boolean;
  13635. /**
  13636. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13637. */
  13638. get isInput(): boolean;
  13639. /**
  13640. * Gets or sets the build Id
  13641. */
  13642. get buildId(): number;
  13643. set buildId(value: number);
  13644. /**
  13645. * Gets or sets the target of the block
  13646. */
  13647. get target(): NodeMaterialBlockTargets;
  13648. set target(value: NodeMaterialBlockTargets);
  13649. /**
  13650. * Gets the list of input points
  13651. */
  13652. get inputs(): NodeMaterialConnectionPoint[];
  13653. /** Gets the list of output points */
  13654. get outputs(): NodeMaterialConnectionPoint[];
  13655. /**
  13656. * Find an input by its name
  13657. * @param name defines the name of the input to look for
  13658. * @returns the input or null if not found
  13659. */
  13660. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13661. /**
  13662. * Find an output by its name
  13663. * @param name defines the name of the outputto look for
  13664. * @returns the output or null if not found
  13665. */
  13666. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13667. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13668. visibleInInspector: boolean;
  13669. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13670. visibleOnFrame: boolean;
  13671. /**
  13672. * Creates a new NodeMaterialBlock
  13673. * @param name defines the block name
  13674. * @param target defines the target of that block (Vertex by default)
  13675. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13676. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13677. */
  13678. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13679. /**
  13680. * Initialize the block and prepare the context for build
  13681. * @param state defines the state that will be used for the build
  13682. */
  13683. initialize(state: NodeMaterialBuildState): void;
  13684. /**
  13685. * Bind data to effect. Will only be called for blocks with isBindable === true
  13686. * @param effect defines the effect to bind data to
  13687. * @param nodeMaterial defines the hosting NodeMaterial
  13688. * @param mesh defines the mesh that will be rendered
  13689. * @param subMesh defines the submesh that will be rendered
  13690. */
  13691. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13692. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13693. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13694. protected _writeFloat(value: number): string;
  13695. /**
  13696. * Gets the current class name e.g. "NodeMaterialBlock"
  13697. * @returns the class name
  13698. */
  13699. getClassName(): string;
  13700. /**
  13701. * Register a new input. Must be called inside a block constructor
  13702. * @param name defines the connection point name
  13703. * @param type defines the connection point type
  13704. * @param isOptional defines a boolean indicating that this input can be omitted
  13705. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13706. * @param point an already created connection point. If not provided, create a new one
  13707. * @returns the current block
  13708. */
  13709. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13710. /**
  13711. * Register a new output. Must be called inside a block constructor
  13712. * @param name defines the connection point name
  13713. * @param type defines the connection point type
  13714. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13715. * @param point an already created connection point. If not provided, create a new one
  13716. * @returns the current block
  13717. */
  13718. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13719. /**
  13720. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13721. * @param forOutput defines an optional connection point to check compatibility with
  13722. * @returns the first available input or null
  13723. */
  13724. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13725. /**
  13726. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13727. * @param forBlock defines an optional block to check compatibility with
  13728. * @returns the first available input or null
  13729. */
  13730. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13731. /**
  13732. * Gets the sibling of the given output
  13733. * @param current defines the current output
  13734. * @returns the next output in the list or null
  13735. */
  13736. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13737. /**
  13738. * Connect current block with another block
  13739. * @param other defines the block to connect with
  13740. * @param options define the various options to help pick the right connections
  13741. * @returns the current block
  13742. */
  13743. connectTo(other: NodeMaterialBlock, options?: {
  13744. input?: string;
  13745. output?: string;
  13746. outputSwizzle?: string;
  13747. }): this | undefined;
  13748. protected _buildBlock(state: NodeMaterialBuildState): void;
  13749. /**
  13750. * Add uniforms, samplers and uniform buffers at compilation time
  13751. * @param state defines the state to update
  13752. * @param nodeMaterial defines the node material requesting the update
  13753. * @param defines defines the material defines to update
  13754. * @param uniformBuffers defines the list of uniform buffer names
  13755. */
  13756. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13757. /**
  13758. * Add potential fallbacks if shader compilation fails
  13759. * @param mesh defines the mesh to be rendered
  13760. * @param fallbacks defines the current prioritized list of fallbacks
  13761. */
  13762. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13763. /**
  13764. * Initialize defines for shader compilation
  13765. * @param mesh defines the mesh to be rendered
  13766. * @param nodeMaterial defines the node material requesting the update
  13767. * @param defines defines the material defines to update
  13768. * @param useInstances specifies that instances should be used
  13769. */
  13770. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13771. /**
  13772. * Update defines for shader compilation
  13773. * @param mesh defines the mesh to be rendered
  13774. * @param nodeMaterial defines the node material requesting the update
  13775. * @param defines defines the material defines to update
  13776. * @param useInstances specifies that instances should be used
  13777. * @param subMesh defines which submesh to render
  13778. */
  13779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13780. /**
  13781. * Lets the block try to connect some inputs automatically
  13782. * @param material defines the hosting NodeMaterial
  13783. */
  13784. autoConfigure(material: NodeMaterial): void;
  13785. /**
  13786. * Function called when a block is declared as repeatable content generator
  13787. * @param vertexShaderState defines the current compilation state for the vertex shader
  13788. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13789. * @param mesh defines the mesh to be rendered
  13790. * @param defines defines the material defines to update
  13791. */
  13792. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13793. /**
  13794. * Checks if the block is ready
  13795. * @param mesh defines the mesh to be rendered
  13796. * @param nodeMaterial defines the node material requesting the update
  13797. * @param defines defines the material defines to update
  13798. * @param useInstances specifies that instances should be used
  13799. * @returns true if the block is ready
  13800. */
  13801. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13802. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13803. private _processBuild;
  13804. /**
  13805. * Validates the new name for the block node.
  13806. * @param newName the new name to be given to the node.
  13807. * @returns false if the name is a reserve word, else true.
  13808. */
  13809. validateBlockName(newName: string): boolean;
  13810. /**
  13811. * Compile the current node and generate the shader code
  13812. * @param state defines the current compilation state (uniforms, samplers, current string)
  13813. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13814. * @returns true if already built
  13815. */
  13816. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13817. protected _inputRename(name: string): string;
  13818. protected _outputRename(name: string): string;
  13819. protected _dumpPropertiesCode(): string;
  13820. /** @hidden */
  13821. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13822. /** @hidden */
  13823. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13824. /**
  13825. * Clone the current block to a new identical block
  13826. * @param scene defines the hosting scene
  13827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13828. * @returns a copy of the current block
  13829. */
  13830. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13831. /**
  13832. * Serializes this block in a JSON representation
  13833. * @returns the serialized block object
  13834. */
  13835. serialize(): any;
  13836. /** @hidden */
  13837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13838. private _deserializePortDisplayNamesAndExposedOnFrame;
  13839. /**
  13840. * Release resources
  13841. */
  13842. dispose(): void;
  13843. }
  13844. }
  13845. declare module BABYLON {
  13846. /**
  13847. * Base class of materials working in push mode in babylon JS
  13848. * @hidden
  13849. */
  13850. export class PushMaterial extends Material {
  13851. protected _activeEffect: Effect;
  13852. protected _normalMatrix: Matrix;
  13853. constructor(name: string, scene: Scene);
  13854. getEffect(): Effect;
  13855. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13856. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13857. /**
  13858. * Binds the given world matrix to the active effect
  13859. *
  13860. * @param world the matrix to bind
  13861. */
  13862. bindOnlyWorldMatrix(world: Matrix): void;
  13863. /**
  13864. * Binds the given normal matrix to the active effect
  13865. *
  13866. * @param normalMatrix the matrix to bind
  13867. */
  13868. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13869. bind(world: Matrix, mesh?: Mesh): void;
  13870. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13871. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13872. }
  13873. }
  13874. declare module BABYLON {
  13875. /**
  13876. * Root class for all node material optimizers
  13877. */
  13878. export class NodeMaterialOptimizer {
  13879. /**
  13880. * Function used to optimize a NodeMaterial graph
  13881. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13882. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13883. */
  13884. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13890. */
  13891. export class TransformBlock extends NodeMaterialBlock {
  13892. /**
  13893. * Defines the value to use to complement W value to transform it to a Vector4
  13894. */
  13895. complementW: number;
  13896. /**
  13897. * Defines the value to use to complement z value to transform it to a Vector4
  13898. */
  13899. complementZ: number;
  13900. /**
  13901. * Creates a new TransformBlock
  13902. * @param name defines the block name
  13903. */
  13904. constructor(name: string);
  13905. /**
  13906. * Gets the current class name
  13907. * @returns the class name
  13908. */
  13909. getClassName(): string;
  13910. /**
  13911. * Gets the vector input
  13912. */
  13913. get vector(): NodeMaterialConnectionPoint;
  13914. /**
  13915. * Gets the output component
  13916. */
  13917. get output(): NodeMaterialConnectionPoint;
  13918. /**
  13919. * Gets the xyz output component
  13920. */
  13921. get xyz(): NodeMaterialConnectionPoint;
  13922. /**
  13923. * Gets the matrix transform input
  13924. */
  13925. get transform(): NodeMaterialConnectionPoint;
  13926. protected _buildBlock(state: NodeMaterialBuildState): this;
  13927. /**
  13928. * Update defines for shader compilation
  13929. * @param mesh defines the mesh to be rendered
  13930. * @param nodeMaterial defines the node material requesting the update
  13931. * @param defines defines the material defines to update
  13932. * @param useInstances specifies that instances should be used
  13933. * @param subMesh defines which submesh to render
  13934. */
  13935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13936. serialize(): any;
  13937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13938. protected _dumpPropertiesCode(): string;
  13939. }
  13940. }
  13941. declare module BABYLON {
  13942. /**
  13943. * Block used to output the vertex position
  13944. */
  13945. export class VertexOutputBlock extends NodeMaterialBlock {
  13946. /**
  13947. * Creates a new VertexOutputBlock
  13948. * @param name defines the block name
  13949. */
  13950. constructor(name: string);
  13951. /**
  13952. * Gets the current class name
  13953. * @returns the class name
  13954. */
  13955. getClassName(): string;
  13956. /**
  13957. * Gets the vector input component
  13958. */
  13959. get vector(): NodeMaterialConnectionPoint;
  13960. protected _buildBlock(state: NodeMaterialBuildState): this;
  13961. }
  13962. }
  13963. declare module BABYLON {
  13964. /**
  13965. * Block used to output the final color
  13966. */
  13967. export class FragmentOutputBlock extends NodeMaterialBlock {
  13968. /**
  13969. * Create a new FragmentOutputBlock
  13970. * @param name defines the block name
  13971. */
  13972. constructor(name: string);
  13973. /**
  13974. * Gets the current class name
  13975. * @returns the class name
  13976. */
  13977. getClassName(): string;
  13978. /**
  13979. * Gets the rgba input component
  13980. */
  13981. get rgba(): NodeMaterialConnectionPoint;
  13982. /**
  13983. * Gets the rgb input component
  13984. */
  13985. get rgb(): NodeMaterialConnectionPoint;
  13986. /**
  13987. * Gets the a input component
  13988. */
  13989. get a(): NodeMaterialConnectionPoint;
  13990. protected _buildBlock(state: NodeMaterialBuildState): this;
  13991. }
  13992. }
  13993. declare module BABYLON {
  13994. /**
  13995. * Block used for the particle ramp gradient section
  13996. */
  13997. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13998. /**
  13999. * Create a new ParticleRampGradientBlock
  14000. * @param name defines the block name
  14001. */
  14002. constructor(name: string);
  14003. /**
  14004. * Gets the current class name
  14005. * @returns the class name
  14006. */
  14007. getClassName(): string;
  14008. /**
  14009. * Gets the color input component
  14010. */
  14011. get color(): NodeMaterialConnectionPoint;
  14012. /**
  14013. * Gets the rampColor output component
  14014. */
  14015. get rampColor(): NodeMaterialConnectionPoint;
  14016. /**
  14017. * Initialize the block and prepare the context for build
  14018. * @param state defines the state that will be used for the build
  14019. */
  14020. initialize(state: NodeMaterialBuildState): void;
  14021. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. /**
  14026. * Block used for the particle blend multiply section
  14027. */
  14028. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14029. /**
  14030. * Create a new ParticleBlendMultiplyBlock
  14031. * @param name defines the block name
  14032. */
  14033. constructor(name: string);
  14034. /**
  14035. * Gets the current class name
  14036. * @returns the class name
  14037. */
  14038. getClassName(): string;
  14039. /**
  14040. * Gets the color input component
  14041. */
  14042. get color(): NodeMaterialConnectionPoint;
  14043. /**
  14044. * Gets the alphaTexture input component
  14045. */
  14046. get alphaTexture(): NodeMaterialConnectionPoint;
  14047. /**
  14048. * Gets the alphaColor input component
  14049. */
  14050. get alphaColor(): NodeMaterialConnectionPoint;
  14051. /**
  14052. * Gets the blendColor output component
  14053. */
  14054. get blendColor(): NodeMaterialConnectionPoint;
  14055. /**
  14056. * Initialize the block and prepare the context for build
  14057. * @param state defines the state that will be used for the build
  14058. */
  14059. initialize(state: NodeMaterialBuildState): void;
  14060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14061. }
  14062. }
  14063. declare module BABYLON {
  14064. /**
  14065. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14066. */
  14067. export class VectorMergerBlock extends NodeMaterialBlock {
  14068. /**
  14069. * Create a new VectorMergerBlock
  14070. * @param name defines the block name
  14071. */
  14072. constructor(name: string);
  14073. /**
  14074. * Gets the current class name
  14075. * @returns the class name
  14076. */
  14077. getClassName(): string;
  14078. /**
  14079. * Gets the xyz component (input)
  14080. */
  14081. get xyzIn(): NodeMaterialConnectionPoint;
  14082. /**
  14083. * Gets the xy component (input)
  14084. */
  14085. get xyIn(): NodeMaterialConnectionPoint;
  14086. /**
  14087. * Gets the x component (input)
  14088. */
  14089. get x(): NodeMaterialConnectionPoint;
  14090. /**
  14091. * Gets the y component (input)
  14092. */
  14093. get y(): NodeMaterialConnectionPoint;
  14094. /**
  14095. * Gets the z component (input)
  14096. */
  14097. get z(): NodeMaterialConnectionPoint;
  14098. /**
  14099. * Gets the w component (input)
  14100. */
  14101. get w(): NodeMaterialConnectionPoint;
  14102. /**
  14103. * Gets the xyzw component (output)
  14104. */
  14105. get xyzw(): NodeMaterialConnectionPoint;
  14106. /**
  14107. * Gets the xyz component (output)
  14108. */
  14109. get xyzOut(): NodeMaterialConnectionPoint;
  14110. /**
  14111. * Gets the xy component (output)
  14112. */
  14113. get xyOut(): NodeMaterialConnectionPoint;
  14114. /**
  14115. * Gets the xy component (output)
  14116. * @deprecated Please use xyOut instead.
  14117. */
  14118. get xy(): NodeMaterialConnectionPoint;
  14119. /**
  14120. * Gets the xyz component (output)
  14121. * @deprecated Please use xyzOut instead.
  14122. */
  14123. get xyz(): NodeMaterialConnectionPoint;
  14124. protected _buildBlock(state: NodeMaterialBuildState): this;
  14125. }
  14126. }
  14127. declare module BABYLON {
  14128. /**
  14129. * Block used to remap a float from a range to a new one
  14130. */
  14131. export class RemapBlock extends NodeMaterialBlock {
  14132. /**
  14133. * Gets or sets the source range
  14134. */
  14135. sourceRange: Vector2;
  14136. /**
  14137. * Gets or sets the target range
  14138. */
  14139. targetRange: Vector2;
  14140. /**
  14141. * Creates a new RemapBlock
  14142. * @param name defines the block name
  14143. */
  14144. constructor(name: string);
  14145. /**
  14146. * Gets the current class name
  14147. * @returns the class name
  14148. */
  14149. getClassName(): string;
  14150. /**
  14151. * Gets the input component
  14152. */
  14153. get input(): NodeMaterialConnectionPoint;
  14154. /**
  14155. * Gets the source min input component
  14156. */
  14157. get sourceMin(): NodeMaterialConnectionPoint;
  14158. /**
  14159. * Gets the source max input component
  14160. */
  14161. get sourceMax(): NodeMaterialConnectionPoint;
  14162. /**
  14163. * Gets the target min input component
  14164. */
  14165. get targetMin(): NodeMaterialConnectionPoint;
  14166. /**
  14167. * Gets the target max input component
  14168. */
  14169. get targetMax(): NodeMaterialConnectionPoint;
  14170. /**
  14171. * Gets the output component
  14172. */
  14173. get output(): NodeMaterialConnectionPoint;
  14174. protected _buildBlock(state: NodeMaterialBuildState): this;
  14175. protected _dumpPropertiesCode(): string;
  14176. serialize(): any;
  14177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14178. }
  14179. }
  14180. declare module BABYLON {
  14181. /**
  14182. * Block used to multiply 2 values
  14183. */
  14184. export class MultiplyBlock extends NodeMaterialBlock {
  14185. /**
  14186. * Creates a new MultiplyBlock
  14187. * @param name defines the block name
  14188. */
  14189. constructor(name: string);
  14190. /**
  14191. * Gets the current class name
  14192. * @returns the class name
  14193. */
  14194. getClassName(): string;
  14195. /**
  14196. * Gets the left operand input component
  14197. */
  14198. get left(): NodeMaterialConnectionPoint;
  14199. /**
  14200. * Gets the right operand input component
  14201. */
  14202. get right(): NodeMaterialConnectionPoint;
  14203. /**
  14204. * Gets the output component
  14205. */
  14206. get output(): NodeMaterialConnectionPoint;
  14207. protected _buildBlock(state: NodeMaterialBuildState): this;
  14208. }
  14209. }
  14210. declare module BABYLON {
  14211. /** Interface used by value gradients (color, factor, ...) */
  14212. export interface IValueGradient {
  14213. /**
  14214. * Gets or sets the gradient value (between 0 and 1)
  14215. */
  14216. gradient: number;
  14217. }
  14218. /** Class used to store color4 gradient */
  14219. export class ColorGradient implements IValueGradient {
  14220. /**
  14221. * Gets or sets the gradient value (between 0 and 1)
  14222. */
  14223. gradient: number;
  14224. /**
  14225. * Gets or sets first associated color
  14226. */
  14227. color1: Color4;
  14228. /**
  14229. * Gets or sets second associated color
  14230. */
  14231. color2?: Color4 | undefined;
  14232. /**
  14233. * Creates a new color4 gradient
  14234. * @param gradient gets or sets the gradient value (between 0 and 1)
  14235. * @param color1 gets or sets first associated color
  14236. * @param color2 gets or sets first second color
  14237. */
  14238. constructor(
  14239. /**
  14240. * Gets or sets the gradient value (between 0 and 1)
  14241. */
  14242. gradient: number,
  14243. /**
  14244. * Gets or sets first associated color
  14245. */
  14246. color1: Color4,
  14247. /**
  14248. * Gets or sets second associated color
  14249. */
  14250. color2?: Color4 | undefined);
  14251. /**
  14252. * Will get a color picked randomly between color1 and color2.
  14253. * If color2 is undefined then color1 will be used
  14254. * @param result defines the target Color4 to store the result in
  14255. */
  14256. getColorToRef(result: Color4): void;
  14257. }
  14258. /** Class used to store color 3 gradient */
  14259. export class Color3Gradient implements IValueGradient {
  14260. /**
  14261. * Gets or sets the gradient value (between 0 and 1)
  14262. */
  14263. gradient: number;
  14264. /**
  14265. * Gets or sets the associated color
  14266. */
  14267. color: Color3;
  14268. /**
  14269. * Creates a new color3 gradient
  14270. * @param gradient gets or sets the gradient value (between 0 and 1)
  14271. * @param color gets or sets associated color
  14272. */
  14273. constructor(
  14274. /**
  14275. * Gets or sets the gradient value (between 0 and 1)
  14276. */
  14277. gradient: number,
  14278. /**
  14279. * Gets or sets the associated color
  14280. */
  14281. color: Color3);
  14282. }
  14283. /** Class used to store factor gradient */
  14284. export class FactorGradient implements IValueGradient {
  14285. /**
  14286. * Gets or sets the gradient value (between 0 and 1)
  14287. */
  14288. gradient: number;
  14289. /**
  14290. * Gets or sets first associated factor
  14291. */
  14292. factor1: number;
  14293. /**
  14294. * Gets or sets second associated factor
  14295. */
  14296. factor2?: number | undefined;
  14297. /**
  14298. * Creates a new factor gradient
  14299. * @param gradient gets or sets the gradient value (between 0 and 1)
  14300. * @param factor1 gets or sets first associated factor
  14301. * @param factor2 gets or sets second associated factor
  14302. */
  14303. constructor(
  14304. /**
  14305. * Gets or sets the gradient value (between 0 and 1)
  14306. */
  14307. gradient: number,
  14308. /**
  14309. * Gets or sets first associated factor
  14310. */
  14311. factor1: number,
  14312. /**
  14313. * Gets or sets second associated factor
  14314. */
  14315. factor2?: number | undefined);
  14316. /**
  14317. * Will get a number picked randomly between factor1 and factor2.
  14318. * If factor2 is undefined then factor1 will be used
  14319. * @returns the picked number
  14320. */
  14321. getFactor(): number;
  14322. }
  14323. /**
  14324. * Helper used to simplify some generic gradient tasks
  14325. */
  14326. export class GradientHelper {
  14327. /**
  14328. * Gets the current gradient from an array of IValueGradient
  14329. * @param ratio defines the current ratio to get
  14330. * @param gradients defines the array of IValueGradient
  14331. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14332. */
  14333. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14334. }
  14335. }
  14336. declare module BABYLON {
  14337. interface ThinEngine {
  14338. /**
  14339. * Creates a raw texture
  14340. * @param data defines the data to store in the texture
  14341. * @param width defines the width of the texture
  14342. * @param height defines the height of the texture
  14343. * @param format defines the format of the data
  14344. * @param generateMipMaps defines if the engine should generate the mip levels
  14345. * @param invertY defines if data must be stored with Y axis inverted
  14346. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14347. * @param compression defines the compression used (null by default)
  14348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14349. * @returns the raw texture inside an InternalTexture
  14350. */
  14351. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14352. /**
  14353. * Update a raw texture
  14354. * @param texture defines the texture to update
  14355. * @param data defines the data to store in the texture
  14356. * @param format defines the format of the data
  14357. * @param invertY defines if data must be stored with Y axis inverted
  14358. */
  14359. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14360. /**
  14361. * Update a raw texture
  14362. * @param texture defines the texture to update
  14363. * @param data defines the data to store in the texture
  14364. * @param format defines the format of the data
  14365. * @param invertY defines if data must be stored with Y axis inverted
  14366. * @param compression defines the compression used (null by default)
  14367. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14368. */
  14369. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14370. /**
  14371. * Creates a new raw cube texture
  14372. * @param data defines the array of data to use to create each face
  14373. * @param size defines the size of the textures
  14374. * @param format defines the format of the data
  14375. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14376. * @param generateMipMaps defines if the engine should generate the mip levels
  14377. * @param invertY defines if data must be stored with Y axis inverted
  14378. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14379. * @param compression defines the compression used (null by default)
  14380. * @returns the cube texture as an InternalTexture
  14381. */
  14382. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14383. /**
  14384. * Update a raw cube texture
  14385. * @param texture defines the texture to udpdate
  14386. * @param data defines the data to store
  14387. * @param format defines the data format
  14388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14389. * @param invertY defines if data must be stored with Y axis inverted
  14390. */
  14391. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14392. /**
  14393. * Update a raw cube texture
  14394. * @param texture defines the texture to udpdate
  14395. * @param data defines the data to store
  14396. * @param format defines the data format
  14397. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14398. * @param invertY defines if data must be stored with Y axis inverted
  14399. * @param compression defines the compression used (null by default)
  14400. */
  14401. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14402. /**
  14403. * Update a raw cube texture
  14404. * @param texture defines the texture to udpdate
  14405. * @param data defines the data to store
  14406. * @param format defines the data format
  14407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14408. * @param invertY defines if data must be stored with Y axis inverted
  14409. * @param compression defines the compression used (null by default)
  14410. * @param level defines which level of the texture to update
  14411. */
  14412. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14413. /**
  14414. * Creates a new raw cube texture from a specified url
  14415. * @param url defines the url where the data is located
  14416. * @param scene defines the current scene
  14417. * @param size defines the size of the textures
  14418. * @param format defines the format of the data
  14419. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14420. * @param noMipmap defines if the engine should avoid generating the mip levels
  14421. * @param callback defines a callback used to extract texture data from loaded data
  14422. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14423. * @param onLoad defines a callback called when texture is loaded
  14424. * @param onError defines a callback called if there is an error
  14425. * @returns the cube texture as an InternalTexture
  14426. */
  14427. 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;
  14428. /**
  14429. * Creates a new raw cube texture from a specified url
  14430. * @param url defines the url where the data is located
  14431. * @param scene defines the current scene
  14432. * @param size defines the size of the textures
  14433. * @param format defines the format of the data
  14434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14435. * @param noMipmap defines if the engine should avoid generating the mip levels
  14436. * @param callback defines a callback used to extract texture data from loaded data
  14437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14438. * @param onLoad defines a callback called when texture is loaded
  14439. * @param onError defines a callback called if there is an error
  14440. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14441. * @param invertY defines if data must be stored with Y axis inverted
  14442. * @returns the cube texture as an InternalTexture
  14443. */
  14444. 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;
  14445. /**
  14446. * Creates a new raw 3D texture
  14447. * @param data defines the data used to create the texture
  14448. * @param width defines the width of the texture
  14449. * @param height defines the height of the texture
  14450. * @param depth defines the depth of the texture
  14451. * @param format defines the format of the texture
  14452. * @param generateMipMaps defines if the engine must generate mip levels
  14453. * @param invertY defines if data must be stored with Y axis inverted
  14454. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14455. * @param compression defines the compressed used (can be null)
  14456. * @param textureType defines the compressed used (can be null)
  14457. * @returns a new raw 3D texture (stored in an InternalTexture)
  14458. */
  14459. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14460. /**
  14461. * Update a raw 3D texture
  14462. * @param texture defines the texture to update
  14463. * @param data defines the data to store
  14464. * @param format defines the data format
  14465. * @param invertY defines if data must be stored with Y axis inverted
  14466. */
  14467. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14468. /**
  14469. * Update a raw 3D texture
  14470. * @param texture defines the texture to update
  14471. * @param data defines the data to store
  14472. * @param format defines the data format
  14473. * @param invertY defines if data must be stored with Y axis inverted
  14474. * @param compression defines the used compression (can be null)
  14475. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14476. */
  14477. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14478. /**
  14479. * Creates a new raw 2D array texture
  14480. * @param data defines the data used to create the texture
  14481. * @param width defines the width of the texture
  14482. * @param height defines the height of the texture
  14483. * @param depth defines the number of layers of the texture
  14484. * @param format defines the format of the texture
  14485. * @param generateMipMaps defines if the engine must generate mip levels
  14486. * @param invertY defines if data must be stored with Y axis inverted
  14487. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14488. * @param compression defines the compressed used (can be null)
  14489. * @param textureType defines the compressed used (can be null)
  14490. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14491. */
  14492. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14493. /**
  14494. * Update a raw 2D array texture
  14495. * @param texture defines the texture to update
  14496. * @param data defines the data to store
  14497. * @param format defines the data format
  14498. * @param invertY defines if data must be stored with Y axis inverted
  14499. */
  14500. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14501. /**
  14502. * Update a raw 2D array texture
  14503. * @param texture defines the texture to update
  14504. * @param data defines the data to store
  14505. * @param format defines the data format
  14506. * @param invertY defines if data must be stored with Y axis inverted
  14507. * @param compression defines the used compression (can be null)
  14508. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14509. */
  14510. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. /**
  14515. * Raw texture can help creating a texture directly from an array of data.
  14516. * This can be super useful if you either get the data from an uncompressed source or
  14517. * if you wish to create your texture pixel by pixel.
  14518. */
  14519. export class RawTexture extends Texture {
  14520. /**
  14521. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14522. */
  14523. format: number;
  14524. /**
  14525. * Instantiates a new RawTexture.
  14526. * Raw texture can help creating a texture directly from an array of data.
  14527. * This can be super useful if you either get the data from an uncompressed source or
  14528. * if you wish to create your texture pixel by pixel.
  14529. * @param data define the array of data to use to create the texture
  14530. * @param width define the width of the texture
  14531. * @param height define the height of the texture
  14532. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14533. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14534. * @param generateMipMaps define whether mip maps should be generated or not
  14535. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14536. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14537. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14538. */
  14539. constructor(data: ArrayBufferView, width: number, height: number,
  14540. /**
  14541. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14542. */
  14543. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14544. /**
  14545. * Updates the texture underlying data.
  14546. * @param data Define the new data of the texture
  14547. */
  14548. update(data: ArrayBufferView): void;
  14549. /**
  14550. * Creates a luminance texture from some data.
  14551. * @param data Define the texture data
  14552. * @param width Define the width of the texture
  14553. * @param height Define the height of the texture
  14554. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14558. * @returns the luminance texture
  14559. */
  14560. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14561. /**
  14562. * Creates a luminance alpha texture from some data.
  14563. * @param data Define the texture data
  14564. * @param width Define the width of the texture
  14565. * @param height Define the height of the texture
  14566. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14567. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14570. * @returns the luminance alpha texture
  14571. */
  14572. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14573. /**
  14574. * Creates an alpha texture from some data.
  14575. * @param data Define the texture data
  14576. * @param width Define the width of the texture
  14577. * @param height Define the height of the texture
  14578. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14582. * @returns the alpha texture
  14583. */
  14584. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14585. /**
  14586. * Creates a RGB texture from some data.
  14587. * @param data Define the texture data
  14588. * @param width Define the width of the texture
  14589. * @param height Define the height of the texture
  14590. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14595. * @returns the RGB alpha texture
  14596. */
  14597. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14598. /**
  14599. * Creates a RGBA texture from some data.
  14600. * @param data Define the texture data
  14601. * @param width Define the width of the texture
  14602. * @param height Define the height of the texture
  14603. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14608. * @returns the RGBA texture
  14609. */
  14610. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14611. /**
  14612. * Creates a R texture from some data.
  14613. * @param data Define the texture data
  14614. * @param width Define the width of the texture
  14615. * @param height Define the height of the texture
  14616. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14620. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14621. * @returns the R texture
  14622. */
  14623. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14624. }
  14625. }
  14626. declare module BABYLON {
  14627. interface ThinEngine {
  14628. /**
  14629. * Update a dynamic index buffer
  14630. * @param indexBuffer defines the target index buffer
  14631. * @param indices defines the data to update
  14632. * @param offset defines the offset in the target index buffer where update should start
  14633. */
  14634. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14635. /**
  14636. * Updates a dynamic vertex buffer.
  14637. * @param vertexBuffer the vertex buffer to update
  14638. * @param data the data used to update the vertex buffer
  14639. * @param byteOffset the byte offset of the data
  14640. * @param byteLength the byte length of the data
  14641. */
  14642. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14643. }
  14644. }
  14645. declare module BABYLON {
  14646. interface AbstractScene {
  14647. /**
  14648. * The list of procedural textures added to the scene
  14649. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14650. */
  14651. proceduralTextures: Array<ProceduralTexture>;
  14652. }
  14653. /**
  14654. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14655. * in a given scene.
  14656. */
  14657. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14658. /**
  14659. * The component name helpfull to identify the component in the list of scene components.
  14660. */
  14661. readonly name: string;
  14662. /**
  14663. * The scene the component belongs to.
  14664. */
  14665. scene: Scene;
  14666. /**
  14667. * Creates a new instance of the component for the given scene
  14668. * @param scene Defines the scene to register the component in
  14669. */
  14670. constructor(scene: Scene);
  14671. /**
  14672. * Registers the component in a given scene
  14673. */
  14674. register(): void;
  14675. /**
  14676. * Rebuilds the elements related to this component in case of
  14677. * context lost for instance.
  14678. */
  14679. rebuild(): void;
  14680. /**
  14681. * Disposes the component and the associated ressources.
  14682. */
  14683. dispose(): void;
  14684. private _beforeClear;
  14685. }
  14686. }
  14687. declare module BABYLON {
  14688. interface ThinEngine {
  14689. /**
  14690. * Creates a new render target cube texture
  14691. * @param size defines the size of the texture
  14692. * @param options defines the options used to create the texture
  14693. * @returns a new render target cube texture stored in an InternalTexture
  14694. */
  14695. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14696. }
  14697. }
  14698. declare module BABYLON {
  14699. /** @hidden */
  14700. export var proceduralVertexShader: {
  14701. name: string;
  14702. shader: string;
  14703. };
  14704. }
  14705. declare module BABYLON {
  14706. /**
  14707. * 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.
  14708. * This is the base class of any Procedural texture and contains most of the shareable code.
  14709. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14710. */
  14711. export class ProceduralTexture extends Texture {
  14712. /**
  14713. * Define if the texture is enabled or not (disabled texture will not render)
  14714. */
  14715. isEnabled: boolean;
  14716. /**
  14717. * Define if the texture must be cleared before rendering (default is true)
  14718. */
  14719. autoClear: boolean;
  14720. /**
  14721. * Callback called when the texture is generated
  14722. */
  14723. onGenerated: () => void;
  14724. /**
  14725. * Event raised when the texture is generated
  14726. */
  14727. onGeneratedObservable: Observable<ProceduralTexture>;
  14728. /**
  14729. * Event raised before the texture is generated
  14730. */
  14731. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14732. /**
  14733. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14734. */
  14735. nodeMaterialSource: Nullable<NodeMaterial>;
  14736. /** @hidden */
  14737. _generateMipMaps: boolean;
  14738. /** @hidden **/
  14739. _effect: Effect;
  14740. /** @hidden */
  14741. _textures: {
  14742. [key: string]: Texture;
  14743. };
  14744. /** @hidden */
  14745. protected _fallbackTexture: Nullable<Texture>;
  14746. private _size;
  14747. private _textureType;
  14748. private _currentRefreshId;
  14749. private _frameId;
  14750. private _refreshRate;
  14751. private _vertexBuffers;
  14752. private _indexBuffer;
  14753. private _uniforms;
  14754. private _samplers;
  14755. private _fragment;
  14756. private _floats;
  14757. private _ints;
  14758. private _floatsArrays;
  14759. private _colors3;
  14760. private _colors4;
  14761. private _vectors2;
  14762. private _vectors3;
  14763. private _matrices;
  14764. private _fallbackTextureUsed;
  14765. private _fullEngine;
  14766. private _cachedDefines;
  14767. private _contentUpdateId;
  14768. private _contentData;
  14769. /**
  14770. * Instantiates a new procedural texture.
  14771. * 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.
  14772. * This is the base class of any Procedural texture and contains most of the shareable code.
  14773. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14774. * @param name Define the name of the texture
  14775. * @param size Define the size of the texture to create
  14776. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14777. * @param scene Define the scene the texture belongs to
  14778. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14779. * @param generateMipMaps Define if the texture should creates mip maps or not
  14780. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14781. * @param textureType The FBO internal texture type
  14782. */
  14783. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14784. /**
  14785. * The effect that is created when initializing the post process.
  14786. * @returns The created effect corresponding the the postprocess.
  14787. */
  14788. getEffect(): Effect;
  14789. /**
  14790. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14791. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14792. */
  14793. getContent(): Nullable<Promise<ArrayBufferView>>;
  14794. private _createIndexBuffer;
  14795. /** @hidden */
  14796. _rebuild(): void;
  14797. /**
  14798. * Resets the texture in order to recreate its associated resources.
  14799. * This can be called in case of context loss
  14800. */
  14801. reset(): void;
  14802. protected _getDefines(): string;
  14803. /**
  14804. * Is the texture ready to be used ? (rendered at least once)
  14805. * @returns true if ready, otherwise, false.
  14806. */
  14807. isReady(): boolean;
  14808. /**
  14809. * Resets the refresh counter of the texture and start bak from scratch.
  14810. * Could be useful to regenerate the texture if it is setup to render only once.
  14811. */
  14812. resetRefreshCounter(): void;
  14813. /**
  14814. * Set the fragment shader to use in order to render the texture.
  14815. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14816. */
  14817. setFragment(fragment: any): void;
  14818. /**
  14819. * Define the refresh rate of the texture or the rendering frequency.
  14820. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14821. */
  14822. get refreshRate(): number;
  14823. set refreshRate(value: number);
  14824. /** @hidden */
  14825. _shouldRender(): boolean;
  14826. /**
  14827. * Get the size the texture is rendering at.
  14828. * @returns the size (on cube texture it is always squared)
  14829. */
  14830. getRenderSize(): RenderTargetTextureSize;
  14831. /**
  14832. * Resize the texture to new value.
  14833. * @param size Define the new size the texture should have
  14834. * @param generateMipMaps Define whether the new texture should create mip maps
  14835. */
  14836. resize(size: number, generateMipMaps: boolean): void;
  14837. private _checkUniform;
  14838. /**
  14839. * Set a texture in the shader program used to render.
  14840. * @param name Define the name of the uniform samplers as defined in the shader
  14841. * @param texture Define the texture to bind to this sampler
  14842. * @return the texture itself allowing "fluent" like uniform updates
  14843. */
  14844. setTexture(name: string, texture: Texture): ProceduralTexture;
  14845. /**
  14846. * Set a float in the shader.
  14847. * @param name Define the name of the uniform as defined in the shader
  14848. * @param value Define the value to give to the uniform
  14849. * @return the texture itself allowing "fluent" like uniform updates
  14850. */
  14851. setFloat(name: string, value: number): ProceduralTexture;
  14852. /**
  14853. * Set a int in the shader.
  14854. * @param name Define the name of the uniform as defined in the shader
  14855. * @param value Define the value to give to the uniform
  14856. * @return the texture itself allowing "fluent" like uniform updates
  14857. */
  14858. setInt(name: string, value: number): ProceduralTexture;
  14859. /**
  14860. * Set an array of floats in the shader.
  14861. * @param name Define the name of the uniform as defined in the shader
  14862. * @param value Define the value to give to the uniform
  14863. * @return the texture itself allowing "fluent" like uniform updates
  14864. */
  14865. setFloats(name: string, value: number[]): ProceduralTexture;
  14866. /**
  14867. * Set a vec3 in the shader from a Color3.
  14868. * @param name Define the name of the uniform as defined in the shader
  14869. * @param value Define the value to give to the uniform
  14870. * @return the texture itself allowing "fluent" like uniform updates
  14871. */
  14872. setColor3(name: string, value: Color3): ProceduralTexture;
  14873. /**
  14874. * Set a vec4 in the shader from a Color4.
  14875. * @param name Define the name of the uniform as defined in the shader
  14876. * @param value Define the value to give to the uniform
  14877. * @return the texture itself allowing "fluent" like uniform updates
  14878. */
  14879. setColor4(name: string, value: Color4): ProceduralTexture;
  14880. /**
  14881. * Set a vec2 in the shader from a Vector2.
  14882. * @param name Define the name of the uniform as defined in the shader
  14883. * @param value Define the value to give to the uniform
  14884. * @return the texture itself allowing "fluent" like uniform updates
  14885. */
  14886. setVector2(name: string, value: Vector2): ProceduralTexture;
  14887. /**
  14888. * Set a vec3 in the shader from a Vector3.
  14889. * @param name Define the name of the uniform as defined in the shader
  14890. * @param value Define the value to give to the uniform
  14891. * @return the texture itself allowing "fluent" like uniform updates
  14892. */
  14893. setVector3(name: string, value: Vector3): ProceduralTexture;
  14894. /**
  14895. * Set a mat4 in the shader from a MAtrix.
  14896. * @param name Define the name of the uniform as defined in the shader
  14897. * @param value Define the value to give to the uniform
  14898. * @return the texture itself allowing "fluent" like uniform updates
  14899. */
  14900. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14901. /**
  14902. * Render the texture to its associated render target.
  14903. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14904. */
  14905. render(useCameraPostProcess?: boolean): void;
  14906. /**
  14907. * Clone the texture.
  14908. * @returns the cloned texture
  14909. */
  14910. clone(): ProceduralTexture;
  14911. /**
  14912. * Dispose the texture and release its asoociated resources.
  14913. */
  14914. dispose(): void;
  14915. }
  14916. }
  14917. declare module BABYLON {
  14918. /**
  14919. * This represents the base class for particle system in Babylon.
  14920. * 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.
  14921. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14922. * @example https://doc.babylonjs.com/babylon101/particles
  14923. */
  14924. export class BaseParticleSystem {
  14925. /**
  14926. * Source color is added to the destination color without alpha affecting the result
  14927. */
  14928. static BLENDMODE_ONEONE: number;
  14929. /**
  14930. * Blend current color and particle color using particle’s alpha
  14931. */
  14932. static BLENDMODE_STANDARD: number;
  14933. /**
  14934. * Add current color and particle color multiplied by particle’s alpha
  14935. */
  14936. static BLENDMODE_ADD: number;
  14937. /**
  14938. * Multiply current color with particle color
  14939. */
  14940. static BLENDMODE_MULTIPLY: number;
  14941. /**
  14942. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14943. */
  14944. static BLENDMODE_MULTIPLYADD: number;
  14945. /**
  14946. * List of animations used by the particle system.
  14947. */
  14948. animations: Animation[];
  14949. /**
  14950. * Gets or sets the unique id of the particle system
  14951. */
  14952. uniqueId: number;
  14953. /**
  14954. * The id of the Particle system.
  14955. */
  14956. id: string;
  14957. /**
  14958. * The friendly name of the Particle system.
  14959. */
  14960. name: string;
  14961. /**
  14962. * Snippet ID if the particle system was created from the snippet server
  14963. */
  14964. snippetId: string;
  14965. /**
  14966. * The rendering group used by the Particle system to chose when to render.
  14967. */
  14968. renderingGroupId: number;
  14969. /**
  14970. * The emitter represents the Mesh or position we are attaching the particle system to.
  14971. */
  14972. emitter: Nullable<AbstractMesh | Vector3>;
  14973. /**
  14974. * The maximum number of particles to emit per frame
  14975. */
  14976. emitRate: number;
  14977. /**
  14978. * If you want to launch only a few particles at once, that can be done, as well.
  14979. */
  14980. manualEmitCount: number;
  14981. /**
  14982. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14983. */
  14984. updateSpeed: number;
  14985. /**
  14986. * The amount of time the particle system is running (depends of the overall update speed).
  14987. */
  14988. targetStopDuration: number;
  14989. /**
  14990. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14991. */
  14992. disposeOnStop: boolean;
  14993. /**
  14994. * Minimum power of emitting particles.
  14995. */
  14996. minEmitPower: number;
  14997. /**
  14998. * Maximum power of emitting particles.
  14999. */
  15000. maxEmitPower: number;
  15001. /**
  15002. * Minimum life time of emitting particles.
  15003. */
  15004. minLifeTime: number;
  15005. /**
  15006. * Maximum life time of emitting particles.
  15007. */
  15008. maxLifeTime: number;
  15009. /**
  15010. * Minimum Size of emitting particles.
  15011. */
  15012. minSize: number;
  15013. /**
  15014. * Maximum Size of emitting particles.
  15015. */
  15016. maxSize: number;
  15017. /**
  15018. * Minimum scale of emitting particles on X axis.
  15019. */
  15020. minScaleX: number;
  15021. /**
  15022. * Maximum scale of emitting particles on X axis.
  15023. */
  15024. maxScaleX: number;
  15025. /**
  15026. * Minimum scale of emitting particles on Y axis.
  15027. */
  15028. minScaleY: number;
  15029. /**
  15030. * Maximum scale of emitting particles on Y axis.
  15031. */
  15032. maxScaleY: number;
  15033. /**
  15034. * Gets or sets the minimal initial rotation in radians.
  15035. */
  15036. minInitialRotation: number;
  15037. /**
  15038. * Gets or sets the maximal initial rotation in radians.
  15039. */
  15040. maxInitialRotation: number;
  15041. /**
  15042. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15043. */
  15044. minAngularSpeed: number;
  15045. /**
  15046. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15047. */
  15048. maxAngularSpeed: number;
  15049. /**
  15050. * The texture used to render each particle. (this can be a spritesheet)
  15051. */
  15052. particleTexture: Nullable<BaseTexture>;
  15053. /**
  15054. * The layer mask we are rendering the particles through.
  15055. */
  15056. layerMask: number;
  15057. /**
  15058. * This can help using your own shader to render the particle system.
  15059. * The according effect will be created
  15060. */
  15061. customShader: any;
  15062. /**
  15063. * By default particle system starts as soon as they are created. This prevents the
  15064. * automatic start to happen and let you decide when to start emitting particles.
  15065. */
  15066. preventAutoStart: boolean;
  15067. private _noiseTexture;
  15068. /**
  15069. * Gets or sets a texture used to add random noise to particle positions
  15070. */
  15071. get noiseTexture(): Nullable<ProceduralTexture>;
  15072. set noiseTexture(value: Nullable<ProceduralTexture>);
  15073. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15074. noiseStrength: Vector3;
  15075. /**
  15076. * Callback triggered when the particle animation is ending.
  15077. */
  15078. onAnimationEnd: Nullable<() => void>;
  15079. /**
  15080. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15081. */
  15082. blendMode: number;
  15083. /**
  15084. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15085. * to override the particles.
  15086. */
  15087. forceDepthWrite: boolean;
  15088. /** 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 */
  15089. preWarmCycles: number;
  15090. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15091. preWarmStepOffset: number;
  15092. /**
  15093. * 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)
  15094. */
  15095. spriteCellChangeSpeed: number;
  15096. /**
  15097. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15098. */
  15099. startSpriteCellID: number;
  15100. /**
  15101. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15102. */
  15103. endSpriteCellID: number;
  15104. /**
  15105. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15106. */
  15107. spriteCellWidth: number;
  15108. /**
  15109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15110. */
  15111. spriteCellHeight: number;
  15112. /**
  15113. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15114. */
  15115. spriteRandomStartCell: boolean;
  15116. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15117. translationPivot: Vector2;
  15118. /** @hidden */
  15119. protected _isAnimationSheetEnabled: boolean;
  15120. /**
  15121. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15122. */
  15123. beginAnimationOnStart: boolean;
  15124. /**
  15125. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15126. */
  15127. beginAnimationFrom: number;
  15128. /**
  15129. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15130. */
  15131. beginAnimationTo: number;
  15132. /**
  15133. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15134. */
  15135. beginAnimationLoop: boolean;
  15136. /**
  15137. * Gets or sets a world offset applied to all particles
  15138. */
  15139. worldOffset: Vector3;
  15140. /**
  15141. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15142. */
  15143. get isAnimationSheetEnabled(): boolean;
  15144. set isAnimationSheetEnabled(value: boolean);
  15145. /**
  15146. * Get hosting scene
  15147. * @returns the scene
  15148. */
  15149. getScene(): Nullable<Scene>;
  15150. /**
  15151. * You can use gravity if you want to give an orientation to your particles.
  15152. */
  15153. gravity: Vector3;
  15154. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15155. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15156. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15157. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15158. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15159. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15160. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15161. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15162. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15163. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15164. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15165. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15166. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15167. /**
  15168. * Defines the delay in milliseconds before starting the system (0 by default)
  15169. */
  15170. startDelay: number;
  15171. /**
  15172. * Gets the current list of drag gradients.
  15173. * You must use addDragGradient and removeDragGradient to udpate this list
  15174. * @returns the list of drag gradients
  15175. */
  15176. getDragGradients(): Nullable<Array<FactorGradient>>;
  15177. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15178. limitVelocityDamping: number;
  15179. /**
  15180. * Gets the current list of limit velocity gradients.
  15181. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15182. * @returns the list of limit velocity gradients
  15183. */
  15184. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15185. /**
  15186. * Gets the current list of color gradients.
  15187. * You must use addColorGradient and removeColorGradient to udpate this list
  15188. * @returns the list of color gradients
  15189. */
  15190. getColorGradients(): Nullable<Array<ColorGradient>>;
  15191. /**
  15192. * Gets the current list of size gradients.
  15193. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15194. * @returns the list of size gradients
  15195. */
  15196. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15197. /**
  15198. * Gets the current list of color remap gradients.
  15199. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15200. * @returns the list of color remap gradients
  15201. */
  15202. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15203. /**
  15204. * Gets the current list of alpha remap gradients.
  15205. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15206. * @returns the list of alpha remap gradients
  15207. */
  15208. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15209. /**
  15210. * Gets the current list of life time gradients.
  15211. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15212. * @returns the list of life time gradients
  15213. */
  15214. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15215. /**
  15216. * Gets the current list of angular speed gradients.
  15217. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15218. * @returns the list of angular speed gradients
  15219. */
  15220. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15221. /**
  15222. * Gets the current list of velocity gradients.
  15223. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15224. * @returns the list of velocity gradients
  15225. */
  15226. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15227. /**
  15228. * Gets the current list of start size gradients.
  15229. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15230. * @returns the list of start size gradients
  15231. */
  15232. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15233. /**
  15234. * Gets the current list of emit rate gradients.
  15235. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15236. * @returns the list of emit rate gradients
  15237. */
  15238. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15239. /**
  15240. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15242. */
  15243. get direction1(): Vector3;
  15244. set direction1(value: Vector3);
  15245. /**
  15246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15248. */
  15249. get direction2(): Vector3;
  15250. set direction2(value: Vector3);
  15251. /**
  15252. * 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.
  15253. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15254. */
  15255. get minEmitBox(): Vector3;
  15256. set minEmitBox(value: Vector3);
  15257. /**
  15258. * 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.
  15259. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15260. */
  15261. get maxEmitBox(): Vector3;
  15262. set maxEmitBox(value: Vector3);
  15263. /**
  15264. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15265. */
  15266. color1: Color4;
  15267. /**
  15268. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15269. */
  15270. color2: Color4;
  15271. /**
  15272. * Color the particle will have at the end of its lifetime
  15273. */
  15274. colorDead: Color4;
  15275. /**
  15276. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15277. */
  15278. textureMask: Color4;
  15279. /**
  15280. * The particle emitter type defines the emitter used by the particle system.
  15281. * It can be for example box, sphere, or cone...
  15282. */
  15283. particleEmitterType: IParticleEmitterType;
  15284. /** @hidden */
  15285. _isSubEmitter: boolean;
  15286. /**
  15287. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15288. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15289. */
  15290. billboardMode: number;
  15291. protected _isBillboardBased: boolean;
  15292. /**
  15293. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15294. */
  15295. get isBillboardBased(): boolean;
  15296. set isBillboardBased(value: boolean);
  15297. /**
  15298. * The scene the particle system belongs to.
  15299. */
  15300. protected _scene: Nullable<Scene>;
  15301. /**
  15302. * The engine the particle system belongs to.
  15303. */
  15304. protected _engine: ThinEngine;
  15305. /**
  15306. * Local cache of defines for image processing.
  15307. */
  15308. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15309. /**
  15310. * Default configuration related to image processing available in the standard Material.
  15311. */
  15312. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15313. /**
  15314. * Gets the image processing configuration used either in this material.
  15315. */
  15316. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15317. /**
  15318. * Sets the Default image processing configuration used either in the this material.
  15319. *
  15320. * If sets to null, the scene one is in use.
  15321. */
  15322. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15323. /**
  15324. * Attaches a new image processing configuration to the Standard Material.
  15325. * @param configuration
  15326. */
  15327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15328. /** @hidden */
  15329. protected _reset(): void;
  15330. /** @hidden */
  15331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15332. /**
  15333. * Instantiates a particle system.
  15334. * 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.
  15335. * @param name The name of the particle system
  15336. */
  15337. constructor(name: string);
  15338. /**
  15339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15342. * @returns the emitter
  15343. */
  15344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15345. /**
  15346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15347. * @param radius The radius of the hemisphere to emit from
  15348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15349. * @returns the emitter
  15350. */
  15351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15352. /**
  15353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15354. * @param radius The radius of the sphere to emit from
  15355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15356. * @returns the emitter
  15357. */
  15358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15359. /**
  15360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15361. * @param radius The radius of the sphere to emit from
  15362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15364. * @returns the emitter
  15365. */
  15366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15367. /**
  15368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15369. * @param radius The radius of the emission cylinder
  15370. * @param height The height of the emission cylinder
  15371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15373. * @returns the emitter
  15374. */
  15375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15376. /**
  15377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15378. * @param radius The radius of the cylinder to emit from
  15379. * @param height The height of the emission cylinder
  15380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15383. * @returns the emitter
  15384. */
  15385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15386. /**
  15387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15388. * @param radius The radius of the cone to emit from
  15389. * @param angle The base angle of the cone
  15390. * @returns the emitter
  15391. */
  15392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15393. /**
  15394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15399. * @returns the emitter
  15400. */
  15401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15402. }
  15403. }
  15404. declare module BABYLON {
  15405. /**
  15406. * Type of sub emitter
  15407. */
  15408. export enum SubEmitterType {
  15409. /**
  15410. * Attached to the particle over it's lifetime
  15411. */
  15412. ATTACHED = 0,
  15413. /**
  15414. * Created when the particle dies
  15415. */
  15416. END = 1
  15417. }
  15418. /**
  15419. * Sub emitter class used to emit particles from an existing particle
  15420. */
  15421. export class SubEmitter {
  15422. /**
  15423. * the particle system to be used by the sub emitter
  15424. */
  15425. particleSystem: ParticleSystem;
  15426. /**
  15427. * Type of the submitter (Default: END)
  15428. */
  15429. type: SubEmitterType;
  15430. /**
  15431. * 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)
  15432. * Note: This only is supported when using an emitter of type Mesh
  15433. */
  15434. inheritDirection: boolean;
  15435. /**
  15436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15437. */
  15438. inheritedVelocityAmount: number;
  15439. /**
  15440. * Creates a sub emitter
  15441. * @param particleSystem the particle system to be used by the sub emitter
  15442. */
  15443. constructor(
  15444. /**
  15445. * the particle system to be used by the sub emitter
  15446. */
  15447. particleSystem: ParticleSystem);
  15448. /**
  15449. * Clones the sub emitter
  15450. * @returns the cloned sub emitter
  15451. */
  15452. clone(): SubEmitter;
  15453. /**
  15454. * Serialize current object to a JSON object
  15455. * @returns the serialized object
  15456. */
  15457. serialize(): any;
  15458. /** @hidden */
  15459. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15460. /**
  15461. * Creates a new SubEmitter from a serialized JSON version
  15462. * @param serializationObject defines the JSON object to read from
  15463. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15464. * @param rootUrl defines the rootUrl for data loading
  15465. * @returns a new SubEmitter
  15466. */
  15467. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15468. /** Release associated resources */
  15469. dispose(): void;
  15470. }
  15471. }
  15472. declare module BABYLON {
  15473. /** @hidden */
  15474. export var clipPlaneFragmentDeclaration: {
  15475. name: string;
  15476. shader: string;
  15477. };
  15478. }
  15479. declare module BABYLON {
  15480. /** @hidden */
  15481. export var imageProcessingDeclaration: {
  15482. name: string;
  15483. shader: string;
  15484. };
  15485. }
  15486. declare module BABYLON {
  15487. /** @hidden */
  15488. export var imageProcessingFunctions: {
  15489. name: string;
  15490. shader: string;
  15491. };
  15492. }
  15493. declare module BABYLON {
  15494. /** @hidden */
  15495. export var clipPlaneFragment: {
  15496. name: string;
  15497. shader: string;
  15498. };
  15499. }
  15500. declare module BABYLON {
  15501. /** @hidden */
  15502. export var particlesPixelShader: {
  15503. name: string;
  15504. shader: string;
  15505. };
  15506. }
  15507. declare module BABYLON {
  15508. /** @hidden */
  15509. export var clipPlaneVertexDeclaration: {
  15510. name: string;
  15511. shader: string;
  15512. };
  15513. }
  15514. declare module BABYLON {
  15515. /** @hidden */
  15516. export var clipPlaneVertex: {
  15517. name: string;
  15518. shader: string;
  15519. };
  15520. }
  15521. declare module BABYLON {
  15522. /** @hidden */
  15523. export var particlesVertexShader: {
  15524. name: string;
  15525. shader: string;
  15526. };
  15527. }
  15528. declare module BABYLON {
  15529. /**
  15530. * Interface used to define entities containing multiple clip planes
  15531. */
  15532. export interface IClipPlanesHolder {
  15533. /**
  15534. * Gets or sets the active clipplane 1
  15535. */
  15536. clipPlane: Nullable<Plane>;
  15537. /**
  15538. * Gets or sets the active clipplane 2
  15539. */
  15540. clipPlane2: Nullable<Plane>;
  15541. /**
  15542. * Gets or sets the active clipplane 3
  15543. */
  15544. clipPlane3: Nullable<Plane>;
  15545. /**
  15546. * Gets or sets the active clipplane 4
  15547. */
  15548. clipPlane4: Nullable<Plane>;
  15549. /**
  15550. * Gets or sets the active clipplane 5
  15551. */
  15552. clipPlane5: Nullable<Plane>;
  15553. /**
  15554. * Gets or sets the active clipplane 6
  15555. */
  15556. clipPlane6: Nullable<Plane>;
  15557. }
  15558. }
  15559. declare module BABYLON {
  15560. /**
  15561. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15562. *
  15563. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15564. *
  15565. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15566. */
  15567. export class ThinMaterialHelper {
  15568. /**
  15569. * Binds the clip plane information from the holder to the effect.
  15570. * @param effect The effect we are binding the data to
  15571. * @param holder The entity containing the clip plane information
  15572. */
  15573. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15574. }
  15575. }
  15576. declare module BABYLON {
  15577. interface ThinEngine {
  15578. /**
  15579. * Sets alpha constants used by some alpha blending modes
  15580. * @param r defines the red component
  15581. * @param g defines the green component
  15582. * @param b defines the blue component
  15583. * @param a defines the alpha component
  15584. */
  15585. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15586. /**
  15587. * Sets the current alpha mode
  15588. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15589. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15590. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15591. */
  15592. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15593. /**
  15594. * Gets the current alpha mode
  15595. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15596. * @returns the current alpha mode
  15597. */
  15598. getAlphaMode(): number;
  15599. /**
  15600. * Sets the current alpha equation
  15601. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15602. */
  15603. setAlphaEquation(equation: number): void;
  15604. /**
  15605. * Gets the current alpha equation.
  15606. * @returns the current alpha equation
  15607. */
  15608. getAlphaEquation(): number;
  15609. }
  15610. }
  15611. declare module BABYLON {
  15612. /**
  15613. * This represents a particle system in Babylon.
  15614. * 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.
  15615. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15616. * @example https://doc.babylonjs.com/babylon101/particles
  15617. */
  15618. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15619. /**
  15620. * Billboard mode will only apply to Y axis
  15621. */
  15622. static readonly BILLBOARDMODE_Y: number;
  15623. /**
  15624. * Billboard mode will apply to all axes
  15625. */
  15626. static readonly BILLBOARDMODE_ALL: number;
  15627. /**
  15628. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15629. */
  15630. static readonly BILLBOARDMODE_STRETCHED: number;
  15631. /**
  15632. * This function can be defined to provide custom update for active particles.
  15633. * This function will be called instead of regular update (age, position, color, etc.).
  15634. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15635. */
  15636. updateFunction: (particles: Particle[]) => void;
  15637. private _emitterWorldMatrix;
  15638. /**
  15639. * This function can be defined to specify initial direction for every new particle.
  15640. * It by default use the emitterType defined function
  15641. */
  15642. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15643. /**
  15644. * This function can be defined to specify initial position for every new particle.
  15645. * It by default use the emitterType defined function
  15646. */
  15647. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15648. /**
  15649. * @hidden
  15650. */
  15651. _inheritedVelocityOffset: Vector3;
  15652. /**
  15653. * An event triggered when the system is disposed
  15654. */
  15655. onDisposeObservable: Observable<IParticleSystem>;
  15656. /**
  15657. * An event triggered when the system is stopped
  15658. */
  15659. onStoppedObservable: Observable<IParticleSystem>;
  15660. private _onDisposeObserver;
  15661. /**
  15662. * Sets a callback that will be triggered when the system is disposed
  15663. */
  15664. set onDispose(callback: () => void);
  15665. private _particles;
  15666. private _epsilon;
  15667. private _capacity;
  15668. private _stockParticles;
  15669. private _newPartsExcess;
  15670. private _vertexData;
  15671. private _vertexBuffer;
  15672. private _vertexBuffers;
  15673. private _spriteBuffer;
  15674. private _indexBuffer;
  15675. private _effect;
  15676. private _customEffect;
  15677. private _cachedDefines;
  15678. private _scaledColorStep;
  15679. private _colorDiff;
  15680. private _scaledDirection;
  15681. private _scaledGravity;
  15682. private _currentRenderId;
  15683. private _alive;
  15684. private _useInstancing;
  15685. private _vertexArrayObject;
  15686. private _started;
  15687. private _stopped;
  15688. private _actualFrame;
  15689. private _scaledUpdateSpeed;
  15690. private _vertexBufferSize;
  15691. /** @hidden */
  15692. _currentEmitRateGradient: Nullable<FactorGradient>;
  15693. /** @hidden */
  15694. _currentEmitRate1: number;
  15695. /** @hidden */
  15696. _currentEmitRate2: number;
  15697. /** @hidden */
  15698. _currentStartSizeGradient: Nullable<FactorGradient>;
  15699. /** @hidden */
  15700. _currentStartSize1: number;
  15701. /** @hidden */
  15702. _currentStartSize2: number;
  15703. private readonly _rawTextureWidth;
  15704. private _rampGradientsTexture;
  15705. private _useRampGradients;
  15706. /** Gets or sets a matrix to use to compute projection */
  15707. defaultProjectionMatrix: Matrix;
  15708. /** Gets or sets a matrix to use to compute view */
  15709. defaultViewMatrix: Matrix;
  15710. /** Gets or sets a boolean indicating that ramp gradients must be used
  15711. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15712. */
  15713. get useRampGradients(): boolean;
  15714. set useRampGradients(value: boolean);
  15715. /**
  15716. * 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.
  15717. * 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: [])
  15718. */
  15719. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15720. private _subEmitters;
  15721. /**
  15722. * @hidden
  15723. * If the particle systems emitter should be disposed when the particle system is disposed
  15724. */
  15725. _disposeEmitterOnDispose: boolean;
  15726. /**
  15727. * The current active Sub-systems, this property is used by the root particle system only.
  15728. */
  15729. activeSubSystems: Array<ParticleSystem>;
  15730. /**
  15731. * Specifies if the particles are updated in emitter local space or world space
  15732. */
  15733. isLocal: boolean;
  15734. private _rootParticleSystem;
  15735. /**
  15736. * Gets the current list of active particles
  15737. */
  15738. get particles(): Particle[];
  15739. /**
  15740. * Gets the number of particles active at the same time.
  15741. * @returns The number of active particles.
  15742. */
  15743. getActiveCount(): number;
  15744. /**
  15745. * Returns the string "ParticleSystem"
  15746. * @returns a string containing the class name
  15747. */
  15748. getClassName(): string;
  15749. /**
  15750. * Gets a boolean indicating that the system is stopping
  15751. * @returns true if the system is currently stopping
  15752. */
  15753. isStopping(): boolean;
  15754. /**
  15755. * Gets the custom effect used to render the particles
  15756. * @param blendMode Blend mode for which the effect should be retrieved
  15757. * @returns The effect
  15758. */
  15759. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15760. /**
  15761. * Sets the custom effect used to render the particles
  15762. * @param effect The effect to set
  15763. * @param blendMode Blend mode for which the effect should be set
  15764. */
  15765. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15766. /** @hidden */
  15767. private _onBeforeDrawParticlesObservable;
  15768. /**
  15769. * Observable that will be called just before the particles are drawn
  15770. */
  15771. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15772. /**
  15773. * Gets the name of the particle vertex shader
  15774. */
  15775. get vertexShaderName(): string;
  15776. /**
  15777. * Instantiates a particle system.
  15778. * 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.
  15779. * @param name The name of the particle system
  15780. * @param capacity The max number of particles alive at the same time
  15781. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15782. * @param customEffect a custom effect used to change the way particles are rendered by default
  15783. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15784. * @param epsilon Offset used to render the particles
  15785. */
  15786. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15787. private _addFactorGradient;
  15788. private _removeFactorGradient;
  15789. /**
  15790. * Adds a new life time gradient
  15791. * @param gradient defines the gradient to use (between 0 and 1)
  15792. * @param factor defines the life time factor to affect to the specified gradient
  15793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15794. * @returns the current particle system
  15795. */
  15796. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15797. /**
  15798. * Remove a specific life time gradient
  15799. * @param gradient defines the gradient to remove
  15800. * @returns the current particle system
  15801. */
  15802. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15803. /**
  15804. * Adds a new size gradient
  15805. * @param gradient defines the gradient to use (between 0 and 1)
  15806. * @param factor defines the size factor to affect to the specified gradient
  15807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15808. * @returns the current particle system
  15809. */
  15810. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15811. /**
  15812. * Remove a specific size gradient
  15813. * @param gradient defines the gradient to remove
  15814. * @returns the current particle system
  15815. */
  15816. removeSizeGradient(gradient: number): IParticleSystem;
  15817. /**
  15818. * Adds a new color remap gradient
  15819. * @param gradient defines the gradient to use (between 0 and 1)
  15820. * @param min defines the color remap minimal range
  15821. * @param max defines the color remap maximal range
  15822. * @returns the current particle system
  15823. */
  15824. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15825. /**
  15826. * Remove a specific color remap gradient
  15827. * @param gradient defines the gradient to remove
  15828. * @returns the current particle system
  15829. */
  15830. removeColorRemapGradient(gradient: number): IParticleSystem;
  15831. /**
  15832. * Adds a new alpha remap gradient
  15833. * @param gradient defines the gradient to use (between 0 and 1)
  15834. * @param min defines the alpha remap minimal range
  15835. * @param max defines the alpha remap maximal range
  15836. * @returns the current particle system
  15837. */
  15838. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15839. /**
  15840. * Remove a specific alpha remap gradient
  15841. * @param gradient defines the gradient to remove
  15842. * @returns the current particle system
  15843. */
  15844. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15845. /**
  15846. * Adds a new angular speed gradient
  15847. * @param gradient defines the gradient to use (between 0 and 1)
  15848. * @param factor defines the angular speed to affect to the specified gradient
  15849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15850. * @returns the current particle system
  15851. */
  15852. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15853. /**
  15854. * Remove a specific angular speed gradient
  15855. * @param gradient defines the gradient to remove
  15856. * @returns the current particle system
  15857. */
  15858. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15859. /**
  15860. * Adds a new velocity gradient
  15861. * @param gradient defines the gradient to use (between 0 and 1)
  15862. * @param factor defines the velocity to affect to the specified gradient
  15863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15864. * @returns the current particle system
  15865. */
  15866. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15867. /**
  15868. * Remove a specific velocity gradient
  15869. * @param gradient defines the gradient to remove
  15870. * @returns the current particle system
  15871. */
  15872. removeVelocityGradient(gradient: number): IParticleSystem;
  15873. /**
  15874. * Adds a new limit velocity gradient
  15875. * @param gradient defines the gradient to use (between 0 and 1)
  15876. * @param factor defines the limit velocity value to affect to the specified gradient
  15877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15878. * @returns the current particle system
  15879. */
  15880. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15881. /**
  15882. * Remove a specific limit velocity gradient
  15883. * @param gradient defines the gradient to remove
  15884. * @returns the current particle system
  15885. */
  15886. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15887. /**
  15888. * Adds a new drag gradient
  15889. * @param gradient defines the gradient to use (between 0 and 1)
  15890. * @param factor defines the drag value to affect to the specified gradient
  15891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15892. * @returns the current particle system
  15893. */
  15894. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15895. /**
  15896. * Remove a specific drag gradient
  15897. * @param gradient defines the gradient to remove
  15898. * @returns the current particle system
  15899. */
  15900. removeDragGradient(gradient: number): IParticleSystem;
  15901. /**
  15902. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15903. * @param gradient defines the gradient to use (between 0 and 1)
  15904. * @param factor defines the emit rate value to affect to the specified gradient
  15905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15906. * @returns the current particle system
  15907. */
  15908. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15909. /**
  15910. * Remove a specific emit rate gradient
  15911. * @param gradient defines the gradient to remove
  15912. * @returns the current particle system
  15913. */
  15914. removeEmitRateGradient(gradient: number): IParticleSystem;
  15915. /**
  15916. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15917. * @param gradient defines the gradient to use (between 0 and 1)
  15918. * @param factor defines the start size value to affect to the specified gradient
  15919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15920. * @returns the current particle system
  15921. */
  15922. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15923. /**
  15924. * Remove a specific start size gradient
  15925. * @param gradient defines the gradient to remove
  15926. * @returns the current particle system
  15927. */
  15928. removeStartSizeGradient(gradient: number): IParticleSystem;
  15929. private _createRampGradientTexture;
  15930. /**
  15931. * Gets the current list of ramp gradients.
  15932. * You must use addRampGradient and removeRampGradient to udpate this list
  15933. * @returns the list of ramp gradients
  15934. */
  15935. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15936. /** Force the system to rebuild all gradients that need to be resync */
  15937. forceRefreshGradients(): void;
  15938. private _syncRampGradientTexture;
  15939. /**
  15940. * Adds a new ramp gradient used to remap particle colors
  15941. * @param gradient defines the gradient to use (between 0 and 1)
  15942. * @param color defines the color to affect to the specified gradient
  15943. * @returns the current particle system
  15944. */
  15945. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15946. /**
  15947. * Remove a specific ramp gradient
  15948. * @param gradient defines the gradient to remove
  15949. * @returns the current particle system
  15950. */
  15951. removeRampGradient(gradient: number): ParticleSystem;
  15952. /**
  15953. * Adds a new color gradient
  15954. * @param gradient defines the gradient to use (between 0 and 1)
  15955. * @param color1 defines the color to affect to the specified gradient
  15956. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15957. * @returns this particle system
  15958. */
  15959. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15960. /**
  15961. * Remove a specific color gradient
  15962. * @param gradient defines the gradient to remove
  15963. * @returns this particle system
  15964. */
  15965. removeColorGradient(gradient: number): IParticleSystem;
  15966. private _fetchR;
  15967. protected _reset(): void;
  15968. private _resetEffect;
  15969. private _createVertexBuffers;
  15970. private _createIndexBuffer;
  15971. /**
  15972. * Gets the maximum number of particles active at the same time.
  15973. * @returns The max number of active particles.
  15974. */
  15975. getCapacity(): number;
  15976. /**
  15977. * Gets whether there are still active particles in the system.
  15978. * @returns True if it is alive, otherwise false.
  15979. */
  15980. isAlive(): boolean;
  15981. /**
  15982. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15983. * @returns True if it has been started, otherwise false.
  15984. */
  15985. isStarted(): boolean;
  15986. private _prepareSubEmitterInternalArray;
  15987. /**
  15988. * Starts the particle system and begins to emit
  15989. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15990. */
  15991. start(delay?: number): void;
  15992. /**
  15993. * Stops the particle system.
  15994. * @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.
  15995. */
  15996. stop(stopSubEmitters?: boolean): void;
  15997. /**
  15998. * Remove all active particles
  15999. */
  16000. reset(): void;
  16001. /**
  16002. * @hidden (for internal use only)
  16003. */
  16004. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16005. /**
  16006. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16007. * Its lifetime will start back at 0.
  16008. */
  16009. recycleParticle: (particle: Particle) => void;
  16010. private _stopSubEmitters;
  16011. private _createParticle;
  16012. private _removeFromRoot;
  16013. private _emitFromParticle;
  16014. private _update;
  16015. /** @hidden */
  16016. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16017. /** @hidden */
  16018. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16019. /**
  16020. * Fill the defines array according to the current settings of the particle system
  16021. * @param defines Array to be updated
  16022. * @param blendMode blend mode to take into account when updating the array
  16023. */
  16024. fillDefines(defines: Array<string>, blendMode: number): void;
  16025. /**
  16026. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16027. * @param uniforms Uniforms array to fill
  16028. * @param attributes Attributes array to fill
  16029. * @param samplers Samplers array to fill
  16030. */
  16031. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16032. /** @hidden */
  16033. private _getEffect;
  16034. /**
  16035. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16036. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16037. */
  16038. animate(preWarmOnly?: boolean): void;
  16039. private _appendParticleVertices;
  16040. /**
  16041. * Rebuilds the particle system.
  16042. */
  16043. rebuild(): void;
  16044. /**
  16045. * Is this system ready to be used/rendered
  16046. * @return true if the system is ready
  16047. */
  16048. isReady(): boolean;
  16049. private _render;
  16050. /**
  16051. * Renders the particle system in its current state.
  16052. * @returns the current number of particles
  16053. */
  16054. render(): number;
  16055. /**
  16056. * Disposes the particle system and free the associated resources
  16057. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16058. */
  16059. dispose(disposeTexture?: boolean): void;
  16060. /**
  16061. * Clones the particle system.
  16062. * @param name The name of the cloned object
  16063. * @param newEmitter The new emitter to use
  16064. * @returns the cloned particle system
  16065. */
  16066. clone(name: string, newEmitter: any): ParticleSystem;
  16067. /**
  16068. * Serializes the particle system to a JSON object
  16069. * @param serializeTexture defines if the texture must be serialized as well
  16070. * @returns the JSON object
  16071. */
  16072. serialize(serializeTexture?: boolean): any;
  16073. /** @hidden */
  16074. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16075. /** @hidden */
  16076. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16077. /**
  16078. * Parses a JSON object to create a particle system.
  16079. * @param parsedParticleSystem The JSON object to parse
  16080. * @param sceneOrEngine The scene or the engine to create the particle system in
  16081. * @param rootUrl The root url to use to load external dependencies like texture
  16082. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16083. * @returns the Parsed particle system
  16084. */
  16085. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16086. }
  16087. }
  16088. declare module BABYLON {
  16089. /**
  16090. * A particle represents one of the element emitted by a particle system.
  16091. * This is mainly define by its coordinates, direction, velocity and age.
  16092. */
  16093. export class Particle {
  16094. /**
  16095. * The particle system the particle belongs to.
  16096. */
  16097. particleSystem: ParticleSystem;
  16098. private static _Count;
  16099. /**
  16100. * Unique ID of the particle
  16101. */
  16102. id: number;
  16103. /**
  16104. * The world position of the particle in the scene.
  16105. */
  16106. position: Vector3;
  16107. /**
  16108. * The world direction of the particle in the scene.
  16109. */
  16110. direction: Vector3;
  16111. /**
  16112. * The color of the particle.
  16113. */
  16114. color: Color4;
  16115. /**
  16116. * The color change of the particle per step.
  16117. */
  16118. colorStep: Color4;
  16119. /**
  16120. * Defines how long will the life of the particle be.
  16121. */
  16122. lifeTime: number;
  16123. /**
  16124. * The current age of the particle.
  16125. */
  16126. age: number;
  16127. /**
  16128. * The current size of the particle.
  16129. */
  16130. size: number;
  16131. /**
  16132. * The current scale of the particle.
  16133. */
  16134. scale: Vector2;
  16135. /**
  16136. * The current angle of the particle.
  16137. */
  16138. angle: number;
  16139. /**
  16140. * Defines how fast is the angle changing.
  16141. */
  16142. angularSpeed: number;
  16143. /**
  16144. * Defines the cell index used by the particle to be rendered from a sprite.
  16145. */
  16146. cellIndex: number;
  16147. /**
  16148. * The information required to support color remapping
  16149. */
  16150. remapData: Vector4;
  16151. /** @hidden */
  16152. _randomCellOffset?: number;
  16153. /** @hidden */
  16154. _initialDirection: Nullable<Vector3>;
  16155. /** @hidden */
  16156. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16157. /** @hidden */
  16158. _initialStartSpriteCellID: number;
  16159. /** @hidden */
  16160. _initialEndSpriteCellID: number;
  16161. /** @hidden */
  16162. _currentColorGradient: Nullable<ColorGradient>;
  16163. /** @hidden */
  16164. _currentColor1: Color4;
  16165. /** @hidden */
  16166. _currentColor2: Color4;
  16167. /** @hidden */
  16168. _currentSizeGradient: Nullable<FactorGradient>;
  16169. /** @hidden */
  16170. _currentSize1: number;
  16171. /** @hidden */
  16172. _currentSize2: number;
  16173. /** @hidden */
  16174. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16175. /** @hidden */
  16176. _currentAngularSpeed1: number;
  16177. /** @hidden */
  16178. _currentAngularSpeed2: number;
  16179. /** @hidden */
  16180. _currentVelocityGradient: Nullable<FactorGradient>;
  16181. /** @hidden */
  16182. _currentVelocity1: number;
  16183. /** @hidden */
  16184. _currentVelocity2: number;
  16185. /** @hidden */
  16186. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16187. /** @hidden */
  16188. _currentLimitVelocity1: number;
  16189. /** @hidden */
  16190. _currentLimitVelocity2: number;
  16191. /** @hidden */
  16192. _currentDragGradient: Nullable<FactorGradient>;
  16193. /** @hidden */
  16194. _currentDrag1: number;
  16195. /** @hidden */
  16196. _currentDrag2: number;
  16197. /** @hidden */
  16198. _randomNoiseCoordinates1: Vector3;
  16199. /** @hidden */
  16200. _randomNoiseCoordinates2: Vector3;
  16201. /** @hidden */
  16202. _localPosition?: Vector3;
  16203. /**
  16204. * Creates a new instance Particle
  16205. * @param particleSystem the particle system the particle belongs to
  16206. */
  16207. constructor(
  16208. /**
  16209. * The particle system the particle belongs to.
  16210. */
  16211. particleSystem: ParticleSystem);
  16212. private updateCellInfoFromSystem;
  16213. /**
  16214. * Defines how the sprite cell index is updated for the particle
  16215. */
  16216. updateCellIndex(): void;
  16217. /** @hidden */
  16218. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16219. /** @hidden */
  16220. _inheritParticleInfoToSubEmitters(): void;
  16221. /** @hidden */
  16222. _reset(): void;
  16223. /**
  16224. * Copy the properties of particle to another one.
  16225. * @param other the particle to copy the information to.
  16226. */
  16227. copyTo(other: Particle): void;
  16228. }
  16229. }
  16230. declare module BABYLON {
  16231. /**
  16232. * Particle emitter represents a volume emitting particles.
  16233. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16234. */
  16235. export interface IParticleEmitterType {
  16236. /**
  16237. * Called by the particle System when the direction is computed for the created particle.
  16238. * @param worldMatrix is the world matrix of the particle system
  16239. * @param directionToUpdate is the direction vector to update with the result
  16240. * @param particle is the particle we are computed the direction for
  16241. * @param isLocal defines if the direction should be set in local space
  16242. */
  16243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16244. /**
  16245. * Called by the particle System when the position is computed for the created particle.
  16246. * @param worldMatrix is the world matrix of the particle system
  16247. * @param positionToUpdate is the position vector to update with the result
  16248. * @param particle is the particle we are computed the position for
  16249. * @param isLocal defines if the position should be set in local space
  16250. */
  16251. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16252. /**
  16253. * Clones the current emitter and returns a copy of it
  16254. * @returns the new emitter
  16255. */
  16256. clone(): IParticleEmitterType;
  16257. /**
  16258. * Called by the GPUParticleSystem to setup the update shader
  16259. * @param effect defines the update shader
  16260. */
  16261. applyToShader(effect: Effect): void;
  16262. /**
  16263. * Returns a string to use to update the GPU particles update shader
  16264. * @returns the effect defines string
  16265. */
  16266. getEffectDefines(): string;
  16267. /**
  16268. * Returns a string representing the class name
  16269. * @returns a string containing the class name
  16270. */
  16271. getClassName(): string;
  16272. /**
  16273. * Serializes the particle system to a JSON object.
  16274. * @returns the JSON object
  16275. */
  16276. serialize(): any;
  16277. /**
  16278. * Parse properties from a JSON object
  16279. * @param serializationObject defines the JSON object
  16280. * @param scene defines the hosting scene
  16281. */
  16282. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16283. }
  16284. }
  16285. declare module BABYLON {
  16286. /**
  16287. * Particle emitter emitting particles from the inside of a box.
  16288. * It emits the particles randomly between 2 given directions.
  16289. */
  16290. export class BoxParticleEmitter implements IParticleEmitterType {
  16291. /**
  16292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16293. */
  16294. direction1: Vector3;
  16295. /**
  16296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16297. */
  16298. direction2: Vector3;
  16299. /**
  16300. * 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.
  16301. */
  16302. minEmitBox: Vector3;
  16303. /**
  16304. * 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.
  16305. */
  16306. maxEmitBox: Vector3;
  16307. /**
  16308. * Creates a new instance BoxParticleEmitter
  16309. */
  16310. constructor();
  16311. /**
  16312. * Called by the particle System when the direction is computed for the created particle.
  16313. * @param worldMatrix is the world matrix of the particle system
  16314. * @param directionToUpdate is the direction vector to update with the result
  16315. * @param particle is the particle we are computed the direction for
  16316. * @param isLocal defines if the direction should be set in local space
  16317. */
  16318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16319. /**
  16320. * Called by the particle System when the position is computed for the created particle.
  16321. * @param worldMatrix is the world matrix of the particle system
  16322. * @param positionToUpdate is the position vector to update with the result
  16323. * @param particle is the particle we are computed the position for
  16324. * @param isLocal defines if the position should be set in local space
  16325. */
  16326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16327. /**
  16328. * Clones the current emitter and returns a copy of it
  16329. * @returns the new emitter
  16330. */
  16331. clone(): BoxParticleEmitter;
  16332. /**
  16333. * Called by the GPUParticleSystem to setup the update shader
  16334. * @param effect defines the update shader
  16335. */
  16336. applyToShader(effect: Effect): void;
  16337. /**
  16338. * Returns a string to use to update the GPU particles update shader
  16339. * @returns a string containng the defines string
  16340. */
  16341. getEffectDefines(): string;
  16342. /**
  16343. * Returns the string "BoxParticleEmitter"
  16344. * @returns a string containing the class name
  16345. */
  16346. getClassName(): string;
  16347. /**
  16348. * Serializes the particle system to a JSON object.
  16349. * @returns the JSON object
  16350. */
  16351. serialize(): any;
  16352. /**
  16353. * Parse properties from a JSON object
  16354. * @param serializationObject defines the JSON object
  16355. */
  16356. parse(serializationObject: any): void;
  16357. }
  16358. }
  16359. declare module BABYLON {
  16360. /**
  16361. * Particle emitter emitting particles from the inside of a cone.
  16362. * It emits the particles alongside the cone volume from the base to the particle.
  16363. * The emission direction might be randomized.
  16364. */
  16365. export class ConeParticleEmitter implements IParticleEmitterType {
  16366. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16367. directionRandomizer: number;
  16368. private _radius;
  16369. private _angle;
  16370. private _height;
  16371. /**
  16372. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16373. */
  16374. radiusRange: number;
  16375. /**
  16376. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16377. */
  16378. heightRange: number;
  16379. /**
  16380. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16381. */
  16382. emitFromSpawnPointOnly: boolean;
  16383. /**
  16384. * Gets or sets the radius of the emission cone
  16385. */
  16386. get radius(): number;
  16387. set radius(value: number);
  16388. /**
  16389. * Gets or sets the angle of the emission cone
  16390. */
  16391. get angle(): number;
  16392. set angle(value: number);
  16393. private _buildHeight;
  16394. /**
  16395. * Creates a new instance ConeParticleEmitter
  16396. * @param radius the radius of the emission cone (1 by default)
  16397. * @param angle the cone base angle (PI by default)
  16398. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16399. */
  16400. constructor(radius?: number, angle?: number,
  16401. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16402. directionRandomizer?: number);
  16403. /**
  16404. * Called by the particle System when the direction is computed for the created particle.
  16405. * @param worldMatrix is the world matrix of the particle system
  16406. * @param directionToUpdate is the direction vector to update with the result
  16407. * @param particle is the particle we are computed the direction for
  16408. * @param isLocal defines if the direction should be set in local space
  16409. */
  16410. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16411. /**
  16412. * Called by the particle System when the position is computed for the created particle.
  16413. * @param worldMatrix is the world matrix of the particle system
  16414. * @param positionToUpdate is the position vector to update with the result
  16415. * @param particle is the particle we are computed the position for
  16416. * @param isLocal defines if the position should be set in local space
  16417. */
  16418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16419. /**
  16420. * Clones the current emitter and returns a copy of it
  16421. * @returns the new emitter
  16422. */
  16423. clone(): ConeParticleEmitter;
  16424. /**
  16425. * Called by the GPUParticleSystem to setup the update shader
  16426. * @param effect defines the update shader
  16427. */
  16428. applyToShader(effect: Effect): void;
  16429. /**
  16430. * Returns a string to use to update the GPU particles update shader
  16431. * @returns a string containng the defines string
  16432. */
  16433. getEffectDefines(): string;
  16434. /**
  16435. * Returns the string "ConeParticleEmitter"
  16436. * @returns a string containing the class name
  16437. */
  16438. getClassName(): string;
  16439. /**
  16440. * Serializes the particle system to a JSON object.
  16441. * @returns the JSON object
  16442. */
  16443. serialize(): any;
  16444. /**
  16445. * Parse properties from a JSON object
  16446. * @param serializationObject defines the JSON object
  16447. */
  16448. parse(serializationObject: any): void;
  16449. }
  16450. }
  16451. declare module BABYLON {
  16452. /**
  16453. * Particle emitter emitting particles from the inside of a cylinder.
  16454. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16455. */
  16456. export class CylinderParticleEmitter implements IParticleEmitterType {
  16457. /**
  16458. * The radius of the emission cylinder.
  16459. */
  16460. radius: number;
  16461. /**
  16462. * The height of the emission cylinder.
  16463. */
  16464. height: number;
  16465. /**
  16466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16467. */
  16468. radiusRange: number;
  16469. /**
  16470. * How much to randomize the particle direction [0-1].
  16471. */
  16472. directionRandomizer: number;
  16473. /**
  16474. * Creates a new instance CylinderParticleEmitter
  16475. * @param radius the radius of the emission cylinder (1 by default)
  16476. * @param height the height of the emission cylinder (1 by default)
  16477. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16478. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16479. */
  16480. constructor(
  16481. /**
  16482. * The radius of the emission cylinder.
  16483. */
  16484. radius?: number,
  16485. /**
  16486. * The height of the emission cylinder.
  16487. */
  16488. height?: number,
  16489. /**
  16490. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16491. */
  16492. radiusRange?: number,
  16493. /**
  16494. * How much to randomize the particle direction [0-1].
  16495. */
  16496. directionRandomizer?: number);
  16497. /**
  16498. * Called by the particle System when the direction is computed for the created particle.
  16499. * @param worldMatrix is the world matrix of the particle system
  16500. * @param directionToUpdate is the direction vector to update with the result
  16501. * @param particle is the particle we are computed the direction for
  16502. * @param isLocal defines if the direction should be set in local space
  16503. */
  16504. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16505. /**
  16506. * Called by the particle System when the position is computed for the created particle.
  16507. * @param worldMatrix is the world matrix of the particle system
  16508. * @param positionToUpdate is the position vector to update with the result
  16509. * @param particle is the particle we are computed the position for
  16510. * @param isLocal defines if the position should be set in local space
  16511. */
  16512. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16513. /**
  16514. * Clones the current emitter and returns a copy of it
  16515. * @returns the new emitter
  16516. */
  16517. clone(): CylinderParticleEmitter;
  16518. /**
  16519. * Called by the GPUParticleSystem to setup the update shader
  16520. * @param effect defines the update shader
  16521. */
  16522. applyToShader(effect: Effect): void;
  16523. /**
  16524. * Returns a string to use to update the GPU particles update shader
  16525. * @returns a string containng the defines string
  16526. */
  16527. getEffectDefines(): string;
  16528. /**
  16529. * Returns the string "CylinderParticleEmitter"
  16530. * @returns a string containing the class name
  16531. */
  16532. getClassName(): string;
  16533. /**
  16534. * Serializes the particle system to a JSON object.
  16535. * @returns the JSON object
  16536. */
  16537. serialize(): any;
  16538. /**
  16539. * Parse properties from a JSON object
  16540. * @param serializationObject defines the JSON object
  16541. */
  16542. parse(serializationObject: any): void;
  16543. }
  16544. /**
  16545. * Particle emitter emitting particles from the inside of a cylinder.
  16546. * It emits the particles randomly between two vectors.
  16547. */
  16548. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16549. /**
  16550. * The min limit of the emission direction.
  16551. */
  16552. direction1: Vector3;
  16553. /**
  16554. * The max limit of the emission direction.
  16555. */
  16556. direction2: Vector3;
  16557. /**
  16558. * Creates a new instance CylinderDirectedParticleEmitter
  16559. * @param radius the radius of the emission cylinder (1 by default)
  16560. * @param height the height of the emission cylinder (1 by default)
  16561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16562. * @param direction1 the min limit of the emission direction (up vector by default)
  16563. * @param direction2 the max limit of the emission direction (up vector by default)
  16564. */
  16565. constructor(radius?: number, height?: number, radiusRange?: number,
  16566. /**
  16567. * The min limit of the emission direction.
  16568. */
  16569. direction1?: Vector3,
  16570. /**
  16571. * The max limit of the emission direction.
  16572. */
  16573. direction2?: Vector3);
  16574. /**
  16575. * Called by the particle System when the direction is computed for the created particle.
  16576. * @param worldMatrix is the world matrix of the particle system
  16577. * @param directionToUpdate is the direction vector to update with the result
  16578. * @param particle is the particle we are computed the direction for
  16579. */
  16580. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16581. /**
  16582. * Clones the current emitter and returns a copy of it
  16583. * @returns the new emitter
  16584. */
  16585. clone(): CylinderDirectedParticleEmitter;
  16586. /**
  16587. * Called by the GPUParticleSystem to setup the update shader
  16588. * @param effect defines the update shader
  16589. */
  16590. applyToShader(effect: Effect): void;
  16591. /**
  16592. * Returns a string to use to update the GPU particles update shader
  16593. * @returns a string containng the defines string
  16594. */
  16595. getEffectDefines(): string;
  16596. /**
  16597. * Returns the string "CylinderDirectedParticleEmitter"
  16598. * @returns a string containing the class name
  16599. */
  16600. getClassName(): string;
  16601. /**
  16602. * Serializes the particle system to a JSON object.
  16603. * @returns the JSON object
  16604. */
  16605. serialize(): any;
  16606. /**
  16607. * Parse properties from a JSON object
  16608. * @param serializationObject defines the JSON object
  16609. */
  16610. parse(serializationObject: any): void;
  16611. }
  16612. }
  16613. declare module BABYLON {
  16614. /**
  16615. * Particle emitter emitting particles from the inside of a hemisphere.
  16616. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16617. */
  16618. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16619. /**
  16620. * The radius of the emission hemisphere.
  16621. */
  16622. radius: number;
  16623. /**
  16624. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16625. */
  16626. radiusRange: number;
  16627. /**
  16628. * How much to randomize the particle direction [0-1].
  16629. */
  16630. directionRandomizer: number;
  16631. /**
  16632. * Creates a new instance HemisphericParticleEmitter
  16633. * @param radius the radius of the emission hemisphere (1 by default)
  16634. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16635. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16636. */
  16637. constructor(
  16638. /**
  16639. * The radius of the emission hemisphere.
  16640. */
  16641. radius?: number,
  16642. /**
  16643. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16644. */
  16645. radiusRange?: number,
  16646. /**
  16647. * How much to randomize the particle direction [0-1].
  16648. */
  16649. directionRandomizer?: number);
  16650. /**
  16651. * Called by the particle System when the direction is computed for the created particle.
  16652. * @param worldMatrix is the world matrix of the particle system
  16653. * @param directionToUpdate is the direction vector to update with the result
  16654. * @param particle is the particle we are computed the direction for
  16655. * @param isLocal defines if the direction should be set in local space
  16656. */
  16657. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16658. /**
  16659. * Called by the particle System when the position is computed for the created particle.
  16660. * @param worldMatrix is the world matrix of the particle system
  16661. * @param positionToUpdate is the position vector to update with the result
  16662. * @param particle is the particle we are computed the position for
  16663. * @param isLocal defines if the position should be set in local space
  16664. */
  16665. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16666. /**
  16667. * Clones the current emitter and returns a copy of it
  16668. * @returns the new emitter
  16669. */
  16670. clone(): HemisphericParticleEmitter;
  16671. /**
  16672. * Called by the GPUParticleSystem to setup the update shader
  16673. * @param effect defines the update shader
  16674. */
  16675. applyToShader(effect: Effect): void;
  16676. /**
  16677. * Returns a string to use to update the GPU particles update shader
  16678. * @returns a string containng the defines string
  16679. */
  16680. getEffectDefines(): string;
  16681. /**
  16682. * Returns the string "HemisphericParticleEmitter"
  16683. * @returns a string containing the class name
  16684. */
  16685. getClassName(): string;
  16686. /**
  16687. * Serializes the particle system to a JSON object.
  16688. * @returns the JSON object
  16689. */
  16690. serialize(): any;
  16691. /**
  16692. * Parse properties from a JSON object
  16693. * @param serializationObject defines the JSON object
  16694. */
  16695. parse(serializationObject: any): void;
  16696. }
  16697. }
  16698. declare module BABYLON {
  16699. /**
  16700. * Particle emitter emitting particles from a point.
  16701. * It emits the particles randomly between 2 given directions.
  16702. */
  16703. export class PointParticleEmitter implements IParticleEmitterType {
  16704. /**
  16705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16706. */
  16707. direction1: Vector3;
  16708. /**
  16709. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16710. */
  16711. direction2: Vector3;
  16712. /**
  16713. * Creates a new instance PointParticleEmitter
  16714. */
  16715. constructor();
  16716. /**
  16717. * Called by the particle System when the direction is computed for the created particle.
  16718. * @param worldMatrix is the world matrix of the particle system
  16719. * @param directionToUpdate is the direction vector to update with the result
  16720. * @param particle is the particle we are computed the direction for
  16721. * @param isLocal defines if the direction should be set in local space
  16722. */
  16723. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16724. /**
  16725. * Called by the particle System when the position is computed for the created particle.
  16726. * @param worldMatrix is the world matrix of the particle system
  16727. * @param positionToUpdate is the position vector to update with the result
  16728. * @param particle is the particle we are computed the position for
  16729. * @param isLocal defines if the position should be set in local space
  16730. */
  16731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16732. /**
  16733. * Clones the current emitter and returns a copy of it
  16734. * @returns the new emitter
  16735. */
  16736. clone(): PointParticleEmitter;
  16737. /**
  16738. * Called by the GPUParticleSystem to setup the update shader
  16739. * @param effect defines the update shader
  16740. */
  16741. applyToShader(effect: Effect): void;
  16742. /**
  16743. * Returns a string to use to update the GPU particles update shader
  16744. * @returns a string containng the defines string
  16745. */
  16746. getEffectDefines(): string;
  16747. /**
  16748. * Returns the string "PointParticleEmitter"
  16749. * @returns a string containing the class name
  16750. */
  16751. getClassName(): string;
  16752. /**
  16753. * Serializes the particle system to a JSON object.
  16754. * @returns the JSON object
  16755. */
  16756. serialize(): any;
  16757. /**
  16758. * Parse properties from a JSON object
  16759. * @param serializationObject defines the JSON object
  16760. */
  16761. parse(serializationObject: any): void;
  16762. }
  16763. }
  16764. declare module BABYLON {
  16765. /**
  16766. * Particle emitter emitting particles from the inside of a sphere.
  16767. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16768. */
  16769. export class SphereParticleEmitter implements IParticleEmitterType {
  16770. /**
  16771. * The radius of the emission sphere.
  16772. */
  16773. radius: number;
  16774. /**
  16775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16776. */
  16777. radiusRange: number;
  16778. /**
  16779. * How much to randomize the particle direction [0-1].
  16780. */
  16781. directionRandomizer: number;
  16782. /**
  16783. * Creates a new instance SphereParticleEmitter
  16784. * @param radius the radius of the emission sphere (1 by default)
  16785. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16786. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16787. */
  16788. constructor(
  16789. /**
  16790. * The radius of the emission sphere.
  16791. */
  16792. radius?: number,
  16793. /**
  16794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16795. */
  16796. radiusRange?: number,
  16797. /**
  16798. * How much to randomize the particle direction [0-1].
  16799. */
  16800. directionRandomizer?: number);
  16801. /**
  16802. * Called by the particle System when the direction is computed for the created particle.
  16803. * @param worldMatrix is the world matrix of the particle system
  16804. * @param directionToUpdate is the direction vector to update with the result
  16805. * @param particle is the particle we are computed the direction for
  16806. * @param isLocal defines if the direction should be set in local space
  16807. */
  16808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16809. /**
  16810. * Called by the particle System when the position is computed for the created particle.
  16811. * @param worldMatrix is the world matrix of the particle system
  16812. * @param positionToUpdate is the position vector to update with the result
  16813. * @param particle is the particle we are computed the position for
  16814. * @param isLocal defines if the position should be set in local space
  16815. */
  16816. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16817. /**
  16818. * Clones the current emitter and returns a copy of it
  16819. * @returns the new emitter
  16820. */
  16821. clone(): SphereParticleEmitter;
  16822. /**
  16823. * Called by the GPUParticleSystem to setup the update shader
  16824. * @param effect defines the update shader
  16825. */
  16826. applyToShader(effect: Effect): void;
  16827. /**
  16828. * Returns a string to use to update the GPU particles update shader
  16829. * @returns a string containng the defines string
  16830. */
  16831. getEffectDefines(): string;
  16832. /**
  16833. * Returns the string "SphereParticleEmitter"
  16834. * @returns a string containing the class name
  16835. */
  16836. getClassName(): string;
  16837. /**
  16838. * Serializes the particle system to a JSON object.
  16839. * @returns the JSON object
  16840. */
  16841. serialize(): any;
  16842. /**
  16843. * Parse properties from a JSON object
  16844. * @param serializationObject defines the JSON object
  16845. */
  16846. parse(serializationObject: any): void;
  16847. }
  16848. /**
  16849. * Particle emitter emitting particles from the inside of a sphere.
  16850. * It emits the particles randomly between two vectors.
  16851. */
  16852. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16853. /**
  16854. * The min limit of the emission direction.
  16855. */
  16856. direction1: Vector3;
  16857. /**
  16858. * The max limit of the emission direction.
  16859. */
  16860. direction2: Vector3;
  16861. /**
  16862. * Creates a new instance SphereDirectedParticleEmitter
  16863. * @param radius the radius of the emission sphere (1 by default)
  16864. * @param direction1 the min limit of the emission direction (up vector by default)
  16865. * @param direction2 the max limit of the emission direction (up vector by default)
  16866. */
  16867. constructor(radius?: number,
  16868. /**
  16869. * The min limit of the emission direction.
  16870. */
  16871. direction1?: Vector3,
  16872. /**
  16873. * The max limit of the emission direction.
  16874. */
  16875. direction2?: Vector3);
  16876. /**
  16877. * Called by the particle System when the direction is computed for the created particle.
  16878. * @param worldMatrix is the world matrix of the particle system
  16879. * @param directionToUpdate is the direction vector to update with the result
  16880. * @param particle is the particle we are computed the direction for
  16881. */
  16882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16883. /**
  16884. * Clones the current emitter and returns a copy of it
  16885. * @returns the new emitter
  16886. */
  16887. clone(): SphereDirectedParticleEmitter;
  16888. /**
  16889. * Called by the GPUParticleSystem to setup the update shader
  16890. * @param effect defines the update shader
  16891. */
  16892. applyToShader(effect: Effect): void;
  16893. /**
  16894. * Returns a string to use to update the GPU particles update shader
  16895. * @returns a string containng the defines string
  16896. */
  16897. getEffectDefines(): string;
  16898. /**
  16899. * Returns the string "SphereDirectedParticleEmitter"
  16900. * @returns a string containing the class name
  16901. */
  16902. getClassName(): string;
  16903. /**
  16904. * Serializes the particle system to a JSON object.
  16905. * @returns the JSON object
  16906. */
  16907. serialize(): any;
  16908. /**
  16909. * Parse properties from a JSON object
  16910. * @param serializationObject defines the JSON object
  16911. */
  16912. parse(serializationObject: any): void;
  16913. }
  16914. }
  16915. declare module BABYLON {
  16916. /**
  16917. * Particle emitter emitting particles from a custom list of positions.
  16918. */
  16919. export class CustomParticleEmitter implements IParticleEmitterType {
  16920. /**
  16921. * Gets or sets the position generator that will create the inital position of each particle.
  16922. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16923. */
  16924. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16925. /**
  16926. * Gets or sets the destination generator that will create the final destination of each particle.
  16927. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16928. */
  16929. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16930. /**
  16931. * Creates a new instance CustomParticleEmitter
  16932. */
  16933. constructor();
  16934. /**
  16935. * Called by the particle System when the direction is computed for the created particle.
  16936. * @param worldMatrix is the world matrix of the particle system
  16937. * @param directionToUpdate is the direction vector to update with the result
  16938. * @param particle is the particle we are computed the direction for
  16939. * @param isLocal defines if the direction should be set in local space
  16940. */
  16941. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16942. /**
  16943. * Called by the particle System when the position is computed for the created particle.
  16944. * @param worldMatrix is the world matrix of the particle system
  16945. * @param positionToUpdate is the position vector to update with the result
  16946. * @param particle is the particle we are computed the position for
  16947. * @param isLocal defines if the position should be set in local space
  16948. */
  16949. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16950. /**
  16951. * Clones the current emitter and returns a copy of it
  16952. * @returns the new emitter
  16953. */
  16954. clone(): CustomParticleEmitter;
  16955. /**
  16956. * Called by the GPUParticleSystem to setup the update shader
  16957. * @param effect defines the update shader
  16958. */
  16959. applyToShader(effect: Effect): void;
  16960. /**
  16961. * Returns a string to use to update the GPU particles update shader
  16962. * @returns a string containng the defines string
  16963. */
  16964. getEffectDefines(): string;
  16965. /**
  16966. * Returns the string "PointParticleEmitter"
  16967. * @returns a string containing the class name
  16968. */
  16969. getClassName(): string;
  16970. /**
  16971. * Serializes the particle system to a JSON object.
  16972. * @returns the JSON object
  16973. */
  16974. serialize(): any;
  16975. /**
  16976. * Parse properties from a JSON object
  16977. * @param serializationObject defines the JSON object
  16978. */
  16979. parse(serializationObject: any): void;
  16980. }
  16981. }
  16982. declare module BABYLON {
  16983. /**
  16984. * Particle emitter emitting particles from the inside of a box.
  16985. * It emits the particles randomly between 2 given directions.
  16986. */
  16987. export class MeshParticleEmitter implements IParticleEmitterType {
  16988. private _indices;
  16989. private _positions;
  16990. private _normals;
  16991. private _storedNormal;
  16992. private _mesh;
  16993. /**
  16994. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16995. */
  16996. direction1: Vector3;
  16997. /**
  16998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16999. */
  17000. direction2: Vector3;
  17001. /**
  17002. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17003. */
  17004. useMeshNormalsForDirection: boolean;
  17005. /** Defines the mesh to use as source */
  17006. get mesh(): Nullable<AbstractMesh>;
  17007. set mesh(value: Nullable<AbstractMesh>);
  17008. /**
  17009. * Creates a new instance MeshParticleEmitter
  17010. * @param mesh defines the mesh to use as source
  17011. */
  17012. constructor(mesh?: Nullable<AbstractMesh>);
  17013. /**
  17014. * Called by the particle System when the direction is computed for the created particle.
  17015. * @param worldMatrix is the world matrix of the particle system
  17016. * @param directionToUpdate is the direction vector to update with the result
  17017. * @param particle is the particle we are computed the direction for
  17018. * @param isLocal defines if the direction should be set in local space
  17019. */
  17020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17021. /**
  17022. * Called by the particle System when the position is computed for the created particle.
  17023. * @param worldMatrix is the world matrix of the particle system
  17024. * @param positionToUpdate is the position vector to update with the result
  17025. * @param particle is the particle we are computed the position for
  17026. * @param isLocal defines if the position should be set in local space
  17027. */
  17028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17029. /**
  17030. * Clones the current emitter and returns a copy of it
  17031. * @returns the new emitter
  17032. */
  17033. clone(): MeshParticleEmitter;
  17034. /**
  17035. * Called by the GPUParticleSystem to setup the update shader
  17036. * @param effect defines the update shader
  17037. */
  17038. applyToShader(effect: Effect): void;
  17039. /**
  17040. * Returns a string to use to update the GPU particles update shader
  17041. * @returns a string containng the defines string
  17042. */
  17043. getEffectDefines(): string;
  17044. /**
  17045. * Returns the string "BoxParticleEmitter"
  17046. * @returns a string containing the class name
  17047. */
  17048. getClassName(): string;
  17049. /**
  17050. * Serializes the particle system to a JSON object.
  17051. * @returns the JSON object
  17052. */
  17053. serialize(): any;
  17054. /**
  17055. * Parse properties from a JSON object
  17056. * @param serializationObject defines the JSON object
  17057. * @param scene defines the hosting scene
  17058. */
  17059. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17060. }
  17061. }
  17062. declare module BABYLON {
  17063. /**
  17064. * Interface representing a particle system in Babylon.js.
  17065. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17066. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17067. */
  17068. export interface IParticleSystem {
  17069. /**
  17070. * List of animations used by the particle system.
  17071. */
  17072. animations: Animation[];
  17073. /**
  17074. * The id of the Particle system.
  17075. */
  17076. id: string;
  17077. /**
  17078. * The name of the Particle system.
  17079. */
  17080. name: string;
  17081. /**
  17082. * The emitter represents the Mesh or position we are attaching the particle system to.
  17083. */
  17084. emitter: Nullable<AbstractMesh | Vector3>;
  17085. /**
  17086. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17087. */
  17088. isBillboardBased: boolean;
  17089. /**
  17090. * The rendering group used by the Particle system to chose when to render.
  17091. */
  17092. renderingGroupId: number;
  17093. /**
  17094. * The layer mask we are rendering the particles through.
  17095. */
  17096. layerMask: number;
  17097. /**
  17098. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17099. */
  17100. updateSpeed: number;
  17101. /**
  17102. * The amount of time the particle system is running (depends of the overall update speed).
  17103. */
  17104. targetStopDuration: number;
  17105. /**
  17106. * The texture used to render each particle. (this can be a spritesheet)
  17107. */
  17108. particleTexture: Nullable<BaseTexture>;
  17109. /**
  17110. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17111. */
  17112. blendMode: number;
  17113. /**
  17114. * Minimum life time of emitting particles.
  17115. */
  17116. minLifeTime: number;
  17117. /**
  17118. * Maximum life time of emitting particles.
  17119. */
  17120. maxLifeTime: number;
  17121. /**
  17122. * Minimum Size of emitting particles.
  17123. */
  17124. minSize: number;
  17125. /**
  17126. * Maximum Size of emitting particles.
  17127. */
  17128. maxSize: number;
  17129. /**
  17130. * Minimum scale of emitting particles on X axis.
  17131. */
  17132. minScaleX: number;
  17133. /**
  17134. * Maximum scale of emitting particles on X axis.
  17135. */
  17136. maxScaleX: number;
  17137. /**
  17138. * Minimum scale of emitting particles on Y axis.
  17139. */
  17140. minScaleY: number;
  17141. /**
  17142. * Maximum scale of emitting particles on Y axis.
  17143. */
  17144. maxScaleY: number;
  17145. /**
  17146. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17147. */
  17148. color1: Color4;
  17149. /**
  17150. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17151. */
  17152. color2: Color4;
  17153. /**
  17154. * Color the particle will have at the end of its lifetime.
  17155. */
  17156. colorDead: Color4;
  17157. /**
  17158. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17159. */
  17160. emitRate: number;
  17161. /**
  17162. * You can use gravity if you want to give an orientation to your particles.
  17163. */
  17164. gravity: Vector3;
  17165. /**
  17166. * Minimum power of emitting particles.
  17167. */
  17168. minEmitPower: number;
  17169. /**
  17170. * Maximum power of emitting particles.
  17171. */
  17172. maxEmitPower: number;
  17173. /**
  17174. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17175. */
  17176. minAngularSpeed: number;
  17177. /**
  17178. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17179. */
  17180. maxAngularSpeed: number;
  17181. /**
  17182. * Gets or sets the minimal initial rotation in radians.
  17183. */
  17184. minInitialRotation: number;
  17185. /**
  17186. * Gets or sets the maximal initial rotation in radians.
  17187. */
  17188. maxInitialRotation: number;
  17189. /**
  17190. * The particle emitter type defines the emitter used by the particle system.
  17191. * It can be for example box, sphere, or cone...
  17192. */
  17193. particleEmitterType: Nullable<IParticleEmitterType>;
  17194. /**
  17195. * Defines the delay in milliseconds before starting the system (0 by default)
  17196. */
  17197. startDelay: number;
  17198. /**
  17199. * 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
  17200. */
  17201. preWarmCycles: number;
  17202. /**
  17203. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17204. */
  17205. preWarmStepOffset: number;
  17206. /**
  17207. * 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)
  17208. */
  17209. spriteCellChangeSpeed: number;
  17210. /**
  17211. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17212. */
  17213. startSpriteCellID: number;
  17214. /**
  17215. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17216. */
  17217. endSpriteCellID: number;
  17218. /**
  17219. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17220. */
  17221. spriteCellWidth: number;
  17222. /**
  17223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17224. */
  17225. spriteCellHeight: number;
  17226. /**
  17227. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17228. */
  17229. spriteRandomStartCell: boolean;
  17230. /**
  17231. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17232. */
  17233. isAnimationSheetEnabled: boolean;
  17234. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17235. translationPivot: Vector2;
  17236. /**
  17237. * Gets or sets a texture used to add random noise to particle positions
  17238. */
  17239. noiseTexture: Nullable<BaseTexture>;
  17240. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17241. noiseStrength: Vector3;
  17242. /**
  17243. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17244. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17245. */
  17246. billboardMode: number;
  17247. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17248. limitVelocityDamping: number;
  17249. /**
  17250. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17251. */
  17252. beginAnimationOnStart: boolean;
  17253. /**
  17254. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17255. */
  17256. beginAnimationFrom: number;
  17257. /**
  17258. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17259. */
  17260. beginAnimationTo: number;
  17261. /**
  17262. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17263. */
  17264. beginAnimationLoop: boolean;
  17265. /**
  17266. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17267. */
  17268. disposeOnStop: boolean;
  17269. /**
  17270. * Specifies if the particles are updated in emitter local space or world space
  17271. */
  17272. isLocal: boolean;
  17273. /** Snippet ID if the particle system was created from the snippet server */
  17274. snippetId: string;
  17275. /** Gets or sets a matrix to use to compute projection */
  17276. defaultProjectionMatrix: Matrix;
  17277. /**
  17278. * Gets the maximum number of particles active at the same time.
  17279. * @returns The max number of active particles.
  17280. */
  17281. getCapacity(): number;
  17282. /**
  17283. * Gets the number of particles active at the same time.
  17284. * @returns The number of active particles.
  17285. */
  17286. getActiveCount(): number;
  17287. /**
  17288. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17289. * @returns True if it has been started, otherwise false.
  17290. */
  17291. isStarted(): boolean;
  17292. /**
  17293. * Animates the particle system for this frame.
  17294. */
  17295. animate(): void;
  17296. /**
  17297. * Renders the particle system in its current state.
  17298. * @returns the current number of particles
  17299. */
  17300. render(): number;
  17301. /**
  17302. * Dispose the particle system and frees its associated resources.
  17303. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17304. */
  17305. dispose(disposeTexture?: boolean): void;
  17306. /**
  17307. * An event triggered when the system is disposed
  17308. */
  17309. onDisposeObservable: Observable<IParticleSystem>;
  17310. /**
  17311. * An event triggered when the system is stopped
  17312. */
  17313. onStoppedObservable: Observable<IParticleSystem>;
  17314. /**
  17315. * Clones the particle system.
  17316. * @param name The name of the cloned object
  17317. * @param newEmitter The new emitter to use
  17318. * @returns the cloned particle system
  17319. */
  17320. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17321. /**
  17322. * Serializes the particle system to a JSON object
  17323. * @param serializeTexture defines if the texture must be serialized as well
  17324. * @returns the JSON object
  17325. */
  17326. serialize(serializeTexture: boolean): any;
  17327. /**
  17328. * Rebuild the particle system
  17329. */
  17330. rebuild(): void;
  17331. /** Force the system to rebuild all gradients that need to be resync */
  17332. forceRefreshGradients(): void;
  17333. /**
  17334. * Starts the particle system and begins to emit
  17335. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17336. */
  17337. start(delay?: number): void;
  17338. /**
  17339. * Stops the particle system.
  17340. */
  17341. stop(): void;
  17342. /**
  17343. * Remove all active particles
  17344. */
  17345. reset(): void;
  17346. /**
  17347. * Gets a boolean indicating that the system is stopping
  17348. * @returns true if the system is currently stopping
  17349. */
  17350. isStopping(): boolean;
  17351. /**
  17352. * Is this system ready to be used/rendered
  17353. * @return true if the system is ready
  17354. */
  17355. isReady(): boolean;
  17356. /**
  17357. * Returns the string "ParticleSystem"
  17358. * @returns a string containing the class name
  17359. */
  17360. getClassName(): string;
  17361. /**
  17362. * Gets the custom effect used to render the particles
  17363. * @param blendMode Blend mode for which the effect should be retrieved
  17364. * @returns The effect
  17365. */
  17366. getCustomEffect(blendMode: number): Nullable<Effect>;
  17367. /**
  17368. * Sets the custom effect used to render the particles
  17369. * @param effect The effect to set
  17370. * @param blendMode Blend mode for which the effect should be set
  17371. */
  17372. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17373. /**
  17374. * Fill the defines array according to the current settings of the particle system
  17375. * @param defines Array to be updated
  17376. * @param blendMode blend mode to take into account when updating the array
  17377. */
  17378. fillDefines(defines: Array<string>, blendMode: number): void;
  17379. /**
  17380. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17381. * @param uniforms Uniforms array to fill
  17382. * @param attributes Attributes array to fill
  17383. * @param samplers Samplers array to fill
  17384. */
  17385. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17386. /**
  17387. * Observable that will be called just before the particles are drawn
  17388. */
  17389. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17390. /**
  17391. * Gets the name of the particle vertex shader
  17392. */
  17393. vertexShaderName: string;
  17394. /**
  17395. * Adds a new color gradient
  17396. * @param gradient defines the gradient to use (between 0 and 1)
  17397. * @param color1 defines the color to affect to the specified gradient
  17398. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17399. * @returns the current particle system
  17400. */
  17401. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17402. /**
  17403. * Remove a specific color gradient
  17404. * @param gradient defines the gradient to remove
  17405. * @returns the current particle system
  17406. */
  17407. removeColorGradient(gradient: number): IParticleSystem;
  17408. /**
  17409. * Adds a new size gradient
  17410. * @param gradient defines the gradient to use (between 0 and 1)
  17411. * @param factor defines the size factor to affect to the specified gradient
  17412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17413. * @returns the current particle system
  17414. */
  17415. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17416. /**
  17417. * Remove a specific size gradient
  17418. * @param gradient defines the gradient to remove
  17419. * @returns the current particle system
  17420. */
  17421. removeSizeGradient(gradient: number): IParticleSystem;
  17422. /**
  17423. * Gets the current list of color gradients.
  17424. * You must use addColorGradient and removeColorGradient to udpate this list
  17425. * @returns the list of color gradients
  17426. */
  17427. getColorGradients(): Nullable<Array<ColorGradient>>;
  17428. /**
  17429. * Gets the current list of size gradients.
  17430. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17431. * @returns the list of size gradients
  17432. */
  17433. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17434. /**
  17435. * Gets the current list of angular speed gradients.
  17436. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17437. * @returns the list of angular speed gradients
  17438. */
  17439. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17440. /**
  17441. * Adds a new angular speed gradient
  17442. * @param gradient defines the gradient to use (between 0 and 1)
  17443. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17448. /**
  17449. * Remove a specific angular speed gradient
  17450. * @param gradient defines the gradient to remove
  17451. * @returns the current particle system
  17452. */
  17453. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17454. /**
  17455. * Gets the current list of velocity gradients.
  17456. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17457. * @returns the list of velocity gradients
  17458. */
  17459. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Adds a new velocity gradient
  17462. * @param gradient defines the gradient to use (between 0 and 1)
  17463. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17468. /**
  17469. * Remove a specific velocity gradient
  17470. * @param gradient defines the gradient to remove
  17471. * @returns the current particle system
  17472. */
  17473. removeVelocityGradient(gradient: number): IParticleSystem;
  17474. /**
  17475. * Gets the current list of limit velocity gradients.
  17476. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17477. * @returns the list of limit velocity gradients
  17478. */
  17479. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17480. /**
  17481. * Adds a new limit velocity gradient
  17482. * @param gradient defines the gradient to use (between 0 and 1)
  17483. * @param factor defines the limit velocity 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17488. /**
  17489. * Remove a specific limit velocity gradient
  17490. * @param gradient defines the gradient to remove
  17491. * @returns the current particle system
  17492. */
  17493. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17494. /**
  17495. * Adds a new drag gradient
  17496. * @param gradient defines the gradient to use (between 0 and 1)
  17497. * @param factor defines the drag to affect to the specified gradient
  17498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17499. * @returns the current particle system
  17500. */
  17501. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17502. /**
  17503. * Remove a specific drag gradient
  17504. * @param gradient defines the gradient to remove
  17505. * @returns the current particle system
  17506. */
  17507. removeDragGradient(gradient: number): IParticleSystem;
  17508. /**
  17509. * Gets the current list of drag gradients.
  17510. * You must use addDragGradient and removeDragGradient to udpate this list
  17511. * @returns the list of drag gradients
  17512. */
  17513. getDragGradients(): Nullable<Array<FactorGradient>>;
  17514. /**
  17515. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param factor defines the emit rate to affect to the specified gradient
  17518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17519. * @returns the current particle system
  17520. */
  17521. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17522. /**
  17523. * Remove a specific emit rate gradient
  17524. * @param gradient defines the gradient to remove
  17525. * @returns the current particle system
  17526. */
  17527. removeEmitRateGradient(gradient: number): IParticleSystem;
  17528. /**
  17529. * Gets the current list of emit rate gradients.
  17530. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17531. * @returns the list of emit rate gradients
  17532. */
  17533. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17534. /**
  17535. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17536. * @param gradient defines the gradient to use (between 0 and 1)
  17537. * @param factor defines the start size to affect to the specified gradient
  17538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17539. * @returns the current particle system
  17540. */
  17541. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17542. /**
  17543. * Remove a specific start size gradient
  17544. * @param gradient defines the gradient to remove
  17545. * @returns the current particle system
  17546. */
  17547. removeStartSizeGradient(gradient: number): IParticleSystem;
  17548. /**
  17549. * Gets the current list of start size gradients.
  17550. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17551. * @returns the list of start size gradients
  17552. */
  17553. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17554. /**
  17555. * Adds a new life time gradient
  17556. * @param gradient defines the gradient to use (between 0 and 1)
  17557. * @param factor defines the life time factor to affect to the specified gradient
  17558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17559. * @returns the current particle system
  17560. */
  17561. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17562. /**
  17563. * Remove a specific life time gradient
  17564. * @param gradient defines the gradient to remove
  17565. * @returns the current particle system
  17566. */
  17567. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17568. /**
  17569. * Gets the current list of life time gradients.
  17570. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17571. * @returns the list of life time gradients
  17572. */
  17573. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17574. /**
  17575. * Gets the current list of color gradients.
  17576. * You must use addColorGradient and removeColorGradient to udpate this list
  17577. * @returns the list of color gradients
  17578. */
  17579. getColorGradients(): Nullable<Array<ColorGradient>>;
  17580. /**
  17581. * Adds a new ramp gradient used to remap particle colors
  17582. * @param gradient defines the gradient to use (between 0 and 1)
  17583. * @param color defines the color to affect to the specified gradient
  17584. * @returns the current particle system
  17585. */
  17586. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17587. /**
  17588. * Gets the current list of ramp gradients.
  17589. * You must use addRampGradient and removeRampGradient to udpate this list
  17590. * @returns the list of ramp gradients
  17591. */
  17592. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17593. /** Gets or sets a boolean indicating that ramp gradients must be used
  17594. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17595. */
  17596. useRampGradients: boolean;
  17597. /**
  17598. * Adds a new color remap gradient
  17599. * @param gradient defines the gradient to use (between 0 and 1)
  17600. * @param min defines the color remap minimal range
  17601. * @param max defines the color remap maximal range
  17602. * @returns the current particle system
  17603. */
  17604. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17605. /**
  17606. * Gets the current list of color remap gradients.
  17607. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17608. * @returns the list of color remap gradients
  17609. */
  17610. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17611. /**
  17612. * Adds a new alpha remap gradient
  17613. * @param gradient defines the gradient to use (between 0 and 1)
  17614. * @param min defines the alpha remap minimal range
  17615. * @param max defines the alpha remap maximal range
  17616. * @returns the current particle system
  17617. */
  17618. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17619. /**
  17620. * Gets the current list of alpha remap gradients.
  17621. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17622. * @returns the list of alpha remap gradients
  17623. */
  17624. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17625. /**
  17626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17629. * @returns the emitter
  17630. */
  17631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17632. /**
  17633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17634. * @param radius The radius of the hemisphere to emit from
  17635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17636. * @returns the emitter
  17637. */
  17638. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17639. /**
  17640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17641. * @param radius The radius of the sphere to emit from
  17642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17643. * @returns the emitter
  17644. */
  17645. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17646. /**
  17647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17648. * @param radius The radius of the sphere to emit from
  17649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17651. * @returns the emitter
  17652. */
  17653. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17654. /**
  17655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17656. * @param radius The radius of the emission cylinder
  17657. * @param height The height of the emission cylinder
  17658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17660. * @returns the emitter
  17661. */
  17662. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17663. /**
  17664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17665. * @param radius The radius of the cylinder to emit from
  17666. * @param height The height of the emission cylinder
  17667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17670. * @returns the emitter
  17671. */
  17672. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17673. /**
  17674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17675. * @param radius The radius of the cone to emit from
  17676. * @param angle The base angle of the cone
  17677. * @returns the emitter
  17678. */
  17679. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17680. /**
  17681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17686. * @returns the emitter
  17687. */
  17688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17689. /**
  17690. * Get hosting scene
  17691. * @returns the scene
  17692. */
  17693. getScene(): Nullable<Scene>;
  17694. }
  17695. }
  17696. declare module BABYLON {
  17697. /**
  17698. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17699. */
  17700. export class ColorSplitterBlock extends NodeMaterialBlock {
  17701. /**
  17702. * Create a new ColorSplitterBlock
  17703. * @param name defines the block name
  17704. */
  17705. constructor(name: string);
  17706. /**
  17707. * Gets the current class name
  17708. * @returns the class name
  17709. */
  17710. getClassName(): string;
  17711. /**
  17712. * Gets the rgba component (input)
  17713. */
  17714. get rgba(): NodeMaterialConnectionPoint;
  17715. /**
  17716. * Gets the rgb component (input)
  17717. */
  17718. get rgbIn(): NodeMaterialConnectionPoint;
  17719. /**
  17720. * Gets the rgb component (output)
  17721. */
  17722. get rgbOut(): NodeMaterialConnectionPoint;
  17723. /**
  17724. * Gets the r component (output)
  17725. */
  17726. get r(): NodeMaterialConnectionPoint;
  17727. /**
  17728. * Gets the g component (output)
  17729. */
  17730. get g(): NodeMaterialConnectionPoint;
  17731. /**
  17732. * Gets the b component (output)
  17733. */
  17734. get b(): NodeMaterialConnectionPoint;
  17735. /**
  17736. * Gets the a component (output)
  17737. */
  17738. get a(): NodeMaterialConnectionPoint;
  17739. protected _inputRename(name: string): string;
  17740. protected _outputRename(name: string): string;
  17741. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17742. }
  17743. }
  17744. declare module BABYLON {
  17745. /**
  17746. * Operations supported by the Trigonometry block
  17747. */
  17748. export enum TrigonometryBlockOperations {
  17749. /** Cos */
  17750. Cos = 0,
  17751. /** Sin */
  17752. Sin = 1,
  17753. /** Abs */
  17754. Abs = 2,
  17755. /** Exp */
  17756. Exp = 3,
  17757. /** Exp2 */
  17758. Exp2 = 4,
  17759. /** Round */
  17760. Round = 5,
  17761. /** Floor */
  17762. Floor = 6,
  17763. /** Ceiling */
  17764. Ceiling = 7,
  17765. /** Square root */
  17766. Sqrt = 8,
  17767. /** Log */
  17768. Log = 9,
  17769. /** Tangent */
  17770. Tan = 10,
  17771. /** Arc tangent */
  17772. ArcTan = 11,
  17773. /** Arc cosinus */
  17774. ArcCos = 12,
  17775. /** Arc sinus */
  17776. ArcSin = 13,
  17777. /** Fraction */
  17778. Fract = 14,
  17779. /** Sign */
  17780. Sign = 15,
  17781. /** To radians (from degrees) */
  17782. Radians = 16,
  17783. /** To degrees (from radians) */
  17784. Degrees = 17
  17785. }
  17786. /**
  17787. * Block used to apply trigonometry operation to floats
  17788. */
  17789. export class TrigonometryBlock extends NodeMaterialBlock {
  17790. /**
  17791. * Gets or sets the operation applied by the block
  17792. */
  17793. operation: TrigonometryBlockOperations;
  17794. /**
  17795. * Creates a new TrigonometryBlock
  17796. * @param name defines the block name
  17797. */
  17798. constructor(name: string);
  17799. /**
  17800. * Gets the current class name
  17801. * @returns the class name
  17802. */
  17803. getClassName(): string;
  17804. /**
  17805. * Gets the input component
  17806. */
  17807. get input(): NodeMaterialConnectionPoint;
  17808. /**
  17809. * Gets the output component
  17810. */
  17811. get output(): NodeMaterialConnectionPoint;
  17812. protected _buildBlock(state: NodeMaterialBuildState): this;
  17813. serialize(): any;
  17814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17815. protected _dumpPropertiesCode(): string;
  17816. }
  17817. }
  17818. declare module BABYLON {
  17819. /**
  17820. * Interface used to configure the node material editor
  17821. */
  17822. export interface INodeMaterialEditorOptions {
  17823. /** Define the URl to load node editor script */
  17824. editorURL?: string;
  17825. }
  17826. /** @hidden */
  17827. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17828. NORMAL: boolean;
  17829. TANGENT: boolean;
  17830. UV1: boolean;
  17831. /** BONES */
  17832. NUM_BONE_INFLUENCERS: number;
  17833. BonesPerMesh: number;
  17834. BONETEXTURE: boolean;
  17835. /** MORPH TARGETS */
  17836. MORPHTARGETS: boolean;
  17837. MORPHTARGETS_NORMAL: boolean;
  17838. MORPHTARGETS_TANGENT: boolean;
  17839. MORPHTARGETS_UV: boolean;
  17840. NUM_MORPH_INFLUENCERS: number;
  17841. /** IMAGE PROCESSING */
  17842. IMAGEPROCESSING: boolean;
  17843. VIGNETTE: boolean;
  17844. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17845. VIGNETTEBLENDMODEOPAQUE: boolean;
  17846. TONEMAPPING: boolean;
  17847. TONEMAPPING_ACES: boolean;
  17848. CONTRAST: boolean;
  17849. EXPOSURE: boolean;
  17850. COLORCURVES: boolean;
  17851. COLORGRADING: boolean;
  17852. COLORGRADING3D: boolean;
  17853. SAMPLER3DGREENDEPTH: boolean;
  17854. SAMPLER3DBGRMAP: boolean;
  17855. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17856. /** MISC. */
  17857. BUMPDIRECTUV: number;
  17858. constructor();
  17859. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17860. }
  17861. /**
  17862. * Class used to configure NodeMaterial
  17863. */
  17864. export interface INodeMaterialOptions {
  17865. /**
  17866. * Defines if blocks should emit comments
  17867. */
  17868. emitComments: boolean;
  17869. }
  17870. /**
  17871. * Class used to create a node based material built by assembling shader blocks
  17872. */
  17873. export class NodeMaterial extends PushMaterial {
  17874. private static _BuildIdGenerator;
  17875. private _options;
  17876. private _vertexCompilationState;
  17877. private _fragmentCompilationState;
  17878. private _sharedData;
  17879. private _buildId;
  17880. private _buildWasSuccessful;
  17881. private _cachedWorldViewMatrix;
  17882. private _cachedWorldViewProjectionMatrix;
  17883. private _optimizers;
  17884. private _animationFrame;
  17885. /** Define the Url to load node editor script */
  17886. static EditorURL: string;
  17887. /** Define the Url to load snippets */
  17888. static SnippetUrl: string;
  17889. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17890. static IgnoreTexturesAtLoadTime: boolean;
  17891. private BJSNODEMATERIALEDITOR;
  17892. /** Get the inspector from bundle or global */
  17893. private _getGlobalNodeMaterialEditor;
  17894. /**
  17895. * Snippet ID if the material was created from the snippet server
  17896. */
  17897. snippetId: string;
  17898. /**
  17899. * Gets or sets data used by visual editor
  17900. * @see https://nme.babylonjs.com
  17901. */
  17902. editorData: any;
  17903. /**
  17904. * 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)
  17905. */
  17906. ignoreAlpha: boolean;
  17907. /**
  17908. * Defines the maximum number of lights that can be used in the material
  17909. */
  17910. maxSimultaneousLights: number;
  17911. /**
  17912. * Observable raised when the material is built
  17913. */
  17914. onBuildObservable: Observable<NodeMaterial>;
  17915. /**
  17916. * Gets or sets the root nodes of the material vertex shader
  17917. */
  17918. _vertexOutputNodes: NodeMaterialBlock[];
  17919. /**
  17920. * Gets or sets the root nodes of the material fragment (pixel) shader
  17921. */
  17922. _fragmentOutputNodes: NodeMaterialBlock[];
  17923. /** Gets or sets options to control the node material overall behavior */
  17924. get options(): INodeMaterialOptions;
  17925. set options(options: INodeMaterialOptions);
  17926. /**
  17927. * Default configuration related to image processing available in the standard Material.
  17928. */
  17929. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17930. /**
  17931. * Gets the image processing configuration used either in this material.
  17932. */
  17933. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17934. /**
  17935. * Sets the Default image processing configuration used either in the this material.
  17936. *
  17937. * If sets to null, the scene one is in use.
  17938. */
  17939. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17940. /**
  17941. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17942. */
  17943. attachedBlocks: NodeMaterialBlock[];
  17944. /**
  17945. * Specifies the mode of the node material
  17946. * @hidden
  17947. */
  17948. _mode: NodeMaterialModes;
  17949. /**
  17950. * Gets the mode property
  17951. */
  17952. get mode(): NodeMaterialModes;
  17953. /**
  17954. * A free comment about the material
  17955. */
  17956. comment: string;
  17957. /**
  17958. * Create a new node based material
  17959. * @param name defines the material name
  17960. * @param scene defines the hosting scene
  17961. * @param options defines creation option
  17962. */
  17963. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17964. /**
  17965. * Gets the current class name of the material e.g. "NodeMaterial"
  17966. * @returns the class name
  17967. */
  17968. getClassName(): string;
  17969. /**
  17970. * Keep track of the image processing observer to allow dispose and replace.
  17971. */
  17972. private _imageProcessingObserver;
  17973. /**
  17974. * Attaches a new image processing configuration to the Standard Material.
  17975. * @param configuration
  17976. */
  17977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17978. /**
  17979. * Get a block by its name
  17980. * @param name defines the name of the block to retrieve
  17981. * @returns the required block or null if not found
  17982. */
  17983. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17984. /**
  17985. * Get a block by its name
  17986. * @param predicate defines the predicate used to find the good candidate
  17987. * @returns the required block or null if not found
  17988. */
  17989. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17990. /**
  17991. * Get an input block by its name
  17992. * @param predicate defines the predicate used to find the good candidate
  17993. * @returns the required input block or null if not found
  17994. */
  17995. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17996. /**
  17997. * Gets the list of input blocks attached to this material
  17998. * @returns an array of InputBlocks
  17999. */
  18000. getInputBlocks(): InputBlock[];
  18001. /**
  18002. * Adds a new optimizer to the list of optimizers
  18003. * @param optimizer defines the optimizers to add
  18004. * @returns the current material
  18005. */
  18006. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18007. /**
  18008. * Remove an optimizer from the list of optimizers
  18009. * @param optimizer defines the optimizers to remove
  18010. * @returns the current material
  18011. */
  18012. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18013. /**
  18014. * Add a new block to the list of output nodes
  18015. * @param node defines the node to add
  18016. * @returns the current material
  18017. */
  18018. addOutputNode(node: NodeMaterialBlock): this;
  18019. /**
  18020. * Remove a block from the list of root nodes
  18021. * @param node defines the node to remove
  18022. * @returns the current material
  18023. */
  18024. removeOutputNode(node: NodeMaterialBlock): this;
  18025. private _addVertexOutputNode;
  18026. private _removeVertexOutputNode;
  18027. private _addFragmentOutputNode;
  18028. private _removeFragmentOutputNode;
  18029. /**
  18030. * Specifies if the material will require alpha blending
  18031. * @returns a boolean specifying if alpha blending is needed
  18032. */
  18033. needAlphaBlending(): boolean;
  18034. /**
  18035. * Specifies if this material should be rendered in alpha test mode
  18036. * @returns a boolean specifying if an alpha test is needed.
  18037. */
  18038. needAlphaTesting(): boolean;
  18039. private _initializeBlock;
  18040. private _resetDualBlocks;
  18041. /**
  18042. * Remove a block from the current node material
  18043. * @param block defines the block to remove
  18044. */
  18045. removeBlock(block: NodeMaterialBlock): void;
  18046. /**
  18047. * Build the material and generates the inner effect
  18048. * @param verbose defines if the build should log activity
  18049. */
  18050. build(verbose?: boolean): void;
  18051. /**
  18052. * Runs an otpimization phase to try to improve the shader code
  18053. */
  18054. optimize(): void;
  18055. private _prepareDefinesForAttributes;
  18056. /**
  18057. * Create a post process from the material
  18058. * @param camera The camera to apply the render pass to.
  18059. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18061. * @param engine The engine which the post process will be applied. (default: current engine)
  18062. * @param reusable If the post process can be reused on the same frame. (default: false)
  18063. * @param textureType Type of textures used when performing the post process. (default: 0)
  18064. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18065. * @returns the post process created
  18066. */
  18067. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18068. /**
  18069. * Create the post process effect from the material
  18070. * @param postProcess The post process to create the effect for
  18071. */
  18072. createEffectForPostProcess(postProcess: PostProcess): void;
  18073. private _createEffectForPostProcess;
  18074. /**
  18075. * Create a new procedural texture based on this node material
  18076. * @param size defines the size of the texture
  18077. * @param scene defines the hosting scene
  18078. * @returns the new procedural texture attached to this node material
  18079. */
  18080. createProceduralTexture(size: number | {
  18081. width: number;
  18082. height: number;
  18083. layers?: number;
  18084. }, scene: Scene): Nullable<ProceduralTexture>;
  18085. private _createEffectForParticles;
  18086. private _checkInternals;
  18087. /**
  18088. * Create the effect to be used as the custom effect for a particle system
  18089. * @param particleSystem Particle system to create the effect for
  18090. * @param onCompiled defines a function to call when the effect creation is successful
  18091. * @param onError defines a function to call when the effect creation has failed
  18092. */
  18093. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18094. private _processDefines;
  18095. /**
  18096. * Get if the submesh is ready to be used and all its information available.
  18097. * Child classes can use it to update shaders
  18098. * @param mesh defines the mesh to check
  18099. * @param subMesh defines which submesh to check
  18100. * @param useInstances specifies that instances should be used
  18101. * @returns a boolean indicating that the submesh is ready or not
  18102. */
  18103. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18104. /**
  18105. * Get a string representing the shaders built by the current node graph
  18106. */
  18107. get compiledShaders(): string;
  18108. /**
  18109. * Binds the world matrix to the material
  18110. * @param world defines the world transformation matrix
  18111. */
  18112. bindOnlyWorldMatrix(world: Matrix): void;
  18113. /**
  18114. * Binds the submesh to this material by preparing the effect and shader to draw
  18115. * @param world defines the world transformation matrix
  18116. * @param mesh defines the mesh containing the submesh
  18117. * @param subMesh defines the submesh to bind the material to
  18118. */
  18119. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18120. /**
  18121. * Gets the active textures from the material
  18122. * @returns an array of textures
  18123. */
  18124. getActiveTextures(): BaseTexture[];
  18125. /**
  18126. * Gets the list of texture blocks
  18127. * @returns an array of texture blocks
  18128. */
  18129. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18130. /**
  18131. * Specifies if the material uses a texture
  18132. * @param texture defines the texture to check against the material
  18133. * @returns a boolean specifying if the material uses the texture
  18134. */
  18135. hasTexture(texture: BaseTexture): boolean;
  18136. /**
  18137. * Disposes the material
  18138. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18139. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18140. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18141. */
  18142. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18143. /** Creates the node editor window. */
  18144. private _createNodeEditor;
  18145. /**
  18146. * Launch the node material editor
  18147. * @param config Define the configuration of the editor
  18148. * @return a promise fulfilled when the node editor is visible
  18149. */
  18150. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18151. /**
  18152. * Clear the current material
  18153. */
  18154. clear(): void;
  18155. /**
  18156. * Clear the current material and set it to a default state
  18157. */
  18158. setToDefault(): void;
  18159. /**
  18160. * Clear the current material and set it to a default state for post process
  18161. */
  18162. setToDefaultPostProcess(): void;
  18163. /**
  18164. * Clear the current material and set it to a default state for procedural texture
  18165. */
  18166. setToDefaultProceduralTexture(): void;
  18167. /**
  18168. * Clear the current material and set it to a default state for particle
  18169. */
  18170. setToDefaultParticle(): void;
  18171. /**
  18172. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18173. * @param url defines the url to load from
  18174. * @returns a promise that will fullfil when the material is fully loaded
  18175. */
  18176. loadAsync(url: string): Promise<void>;
  18177. private _gatherBlocks;
  18178. /**
  18179. * Generate a string containing the code declaration required to create an equivalent of this material
  18180. * @returns a string
  18181. */
  18182. generateCode(): string;
  18183. /**
  18184. * Serializes this material in a JSON representation
  18185. * @returns the serialized material object
  18186. */
  18187. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18188. private _restoreConnections;
  18189. /**
  18190. * Clear the current graph and load a new one from a serialization object
  18191. * @param source defines the JSON representation of the material
  18192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18193. * @param merge defines whether or not the source must be merged or replace the current content
  18194. */
  18195. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18196. /**
  18197. * Makes a duplicate of the current material.
  18198. * @param name - name to use for the new material.
  18199. */
  18200. clone(name: string): NodeMaterial;
  18201. /**
  18202. * Creates a node material from parsed material data
  18203. * @param source defines the JSON representation of the material
  18204. * @param scene defines the hosting scene
  18205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18206. * @returns a new node material
  18207. */
  18208. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18209. /**
  18210. * Creates a node material from a snippet saved in a remote file
  18211. * @param name defines the name of the material to create
  18212. * @param url defines the url to load from
  18213. * @param scene defines the hosting scene
  18214. * @returns a promise that will resolve to the new node material
  18215. */
  18216. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18217. /**
  18218. * Creates a node material from a snippet saved by the node material editor
  18219. * @param snippetId defines the snippet to load
  18220. * @param scene defines the hosting scene
  18221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18222. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18223. * @returns a promise that will resolve to the new node material
  18224. */
  18225. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18226. /**
  18227. * Creates a new node material set to default basic configuration
  18228. * @param name defines the name of the material
  18229. * @param scene defines the hosting scene
  18230. * @returns a new NodeMaterial
  18231. */
  18232. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18233. }
  18234. }
  18235. declare module BABYLON {
  18236. interface ThinEngine {
  18237. /**
  18238. * Unbind a list of render target textures from the webGL context
  18239. * This is used only when drawBuffer extension or webGL2 are active
  18240. * @param textures defines the render target textures to unbind
  18241. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18242. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18243. */
  18244. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18245. /**
  18246. * Create a multi render target texture
  18247. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18248. * @param size defines the size of the texture
  18249. * @param options defines the creation options
  18250. * @returns the cube texture as an InternalTexture
  18251. */
  18252. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18253. /**
  18254. * Update the sample count for a given multiple render target texture
  18255. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18256. * @param textures defines the textures to update
  18257. * @param samples defines the sample count to set
  18258. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18259. */
  18260. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18261. /**
  18262. * Select a subsets of attachments to draw to.
  18263. * @param attachments gl attachments
  18264. */
  18265. bindAttachments(attachments: number[]): void;
  18266. /**
  18267. * Creates a layout object to draw/clear on specific textures in a MRT
  18268. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18269. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18270. */
  18271. buildTextureLayout(textureStatus: boolean[]): number[];
  18272. /**
  18273. * Restores the webgl state to only draw on the main color attachment
  18274. */
  18275. restoreSingleAttachment(): void;
  18276. /**
  18277. * Clears a list of attachments
  18278. * @param attachments list of the attachments
  18279. * @param colorMain clear color for the main attachment (the first one)
  18280. * @param colorOthers clear color for the other attachments
  18281. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18282. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18283. */
  18284. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18285. }
  18286. }
  18287. declare module BABYLON {
  18288. /**
  18289. * Creation options of the multi render target texture.
  18290. */
  18291. export interface IMultiRenderTargetOptions {
  18292. /**
  18293. * Define if the texture needs to create mip maps after render.
  18294. */
  18295. generateMipMaps?: boolean;
  18296. /**
  18297. * Define the types of all the draw buffers we want to create
  18298. */
  18299. types?: number[];
  18300. /**
  18301. * Define the sampling modes of all the draw buffers we want to create
  18302. */
  18303. samplingModes?: number[];
  18304. /**
  18305. * Define if a depth buffer is required
  18306. */
  18307. generateDepthBuffer?: boolean;
  18308. /**
  18309. * Define if a stencil buffer is required
  18310. */
  18311. generateStencilBuffer?: boolean;
  18312. /**
  18313. * Define if a depth texture is required instead of a depth buffer
  18314. */
  18315. generateDepthTexture?: boolean;
  18316. /**
  18317. * Define the number of desired draw buffers
  18318. */
  18319. textureCount?: number;
  18320. /**
  18321. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18322. */
  18323. doNotChangeAspectRatio?: boolean;
  18324. /**
  18325. * Define the default type of the buffers we are creating
  18326. */
  18327. defaultType?: number;
  18328. }
  18329. /**
  18330. * A multi render target, like a render target provides the ability to render to a texture.
  18331. * Unlike the render target, it can render to several draw buffers in one draw.
  18332. * This is specially interesting in deferred rendering or for any effects requiring more than
  18333. * just one color from a single pass.
  18334. */
  18335. export class MultiRenderTarget extends RenderTargetTexture {
  18336. private _internalTextures;
  18337. private _textures;
  18338. private _multiRenderTargetOptions;
  18339. private _count;
  18340. /**
  18341. * Get if draw buffers are currently supported by the used hardware and browser.
  18342. */
  18343. get isSupported(): boolean;
  18344. /**
  18345. * Get the list of textures generated by the multi render target.
  18346. */
  18347. get textures(): Texture[];
  18348. /**
  18349. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18350. */
  18351. get count(): number;
  18352. /**
  18353. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18354. */
  18355. get depthTexture(): Texture;
  18356. /**
  18357. * Set the wrapping mode on U of all the textures we are rendering to.
  18358. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18359. */
  18360. set wrapU(wrap: number);
  18361. /**
  18362. * Set the wrapping mode on V of all the textures we are rendering to.
  18363. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18364. */
  18365. set wrapV(wrap: number);
  18366. /**
  18367. * Instantiate a new multi render target texture.
  18368. * A multi render target, like a render target provides the ability to render to a texture.
  18369. * Unlike the render target, it can render to several draw buffers in one draw.
  18370. * This is specially interesting in deferred rendering or for any effects requiring more than
  18371. * just one color from a single pass.
  18372. * @param name Define the name of the texture
  18373. * @param size Define the size of the buffers to render to
  18374. * @param count Define the number of target we are rendering into
  18375. * @param scene Define the scene the texture belongs to
  18376. * @param options Define the options used to create the multi render target
  18377. */
  18378. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18379. private _initTypes;
  18380. /** @hidden */
  18381. _rebuild(forceFullRebuild?: boolean): void;
  18382. private _createInternalTextures;
  18383. private _createTextures;
  18384. /**
  18385. * Replaces a texture within the MRT.
  18386. * @param texture The new texture to insert in the MRT
  18387. * @param index The index of the texture to replace
  18388. */
  18389. replaceTexture(texture: Texture, index: number): void;
  18390. /**
  18391. * Define the number of samples used if MSAA is enabled.
  18392. */
  18393. get samples(): number;
  18394. set samples(value: number);
  18395. /**
  18396. * Resize all the textures in the multi render target.
  18397. * Be careful as it will recreate all the data in the new texture.
  18398. * @param size Define the new size
  18399. */
  18400. resize(size: any): void;
  18401. /**
  18402. * Changes the number of render targets in this MRT
  18403. * Be careful as it will recreate all the data in the new texture.
  18404. * @param count new texture count
  18405. * @param options Specifies texture types and sampling modes for new textures
  18406. */
  18407. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18408. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18409. /**
  18410. * Dispose the render targets and their associated resources
  18411. */
  18412. dispose(): void;
  18413. /**
  18414. * Release all the underlying texture used as draw buffers.
  18415. */
  18416. releaseInternalTextures(): void;
  18417. }
  18418. }
  18419. declare module BABYLON {
  18420. /** @hidden */
  18421. export var imageProcessingPixelShader: {
  18422. name: string;
  18423. shader: string;
  18424. };
  18425. }
  18426. declare module BABYLON {
  18427. /**
  18428. * ImageProcessingPostProcess
  18429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18430. */
  18431. export class ImageProcessingPostProcess extends PostProcess {
  18432. /**
  18433. * Default configuration related to image processing available in the PBR Material.
  18434. */
  18435. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18436. /**
  18437. * Gets the image processing configuration used either in this material.
  18438. */
  18439. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18440. /**
  18441. * Sets the Default image processing configuration used either in the this material.
  18442. *
  18443. * If sets to null, the scene one is in use.
  18444. */
  18445. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18446. /**
  18447. * Keep track of the image processing observer to allow dispose and replace.
  18448. */
  18449. private _imageProcessingObserver;
  18450. /**
  18451. * Attaches a new image processing configuration to the PBR Material.
  18452. * @param configuration
  18453. */
  18454. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18455. /**
  18456. * If the post process is supported.
  18457. */
  18458. get isSupported(): boolean;
  18459. /**
  18460. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18461. */
  18462. get colorCurves(): Nullable<ColorCurves>;
  18463. /**
  18464. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18465. */
  18466. set colorCurves(value: Nullable<ColorCurves>);
  18467. /**
  18468. * Gets wether the color curves effect is enabled.
  18469. */
  18470. get colorCurvesEnabled(): boolean;
  18471. /**
  18472. * Sets wether the color curves effect is enabled.
  18473. */
  18474. set colorCurvesEnabled(value: boolean);
  18475. /**
  18476. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18477. */
  18478. get colorGradingTexture(): Nullable<BaseTexture>;
  18479. /**
  18480. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18481. */
  18482. set colorGradingTexture(value: Nullable<BaseTexture>);
  18483. /**
  18484. * Gets wether the color grading effect is enabled.
  18485. */
  18486. get colorGradingEnabled(): boolean;
  18487. /**
  18488. * Gets wether the color grading effect is enabled.
  18489. */
  18490. set colorGradingEnabled(value: boolean);
  18491. /**
  18492. * Gets exposure used in the effect.
  18493. */
  18494. get exposure(): number;
  18495. /**
  18496. * Sets exposure used in the effect.
  18497. */
  18498. set exposure(value: number);
  18499. /**
  18500. * Gets wether tonemapping is enabled or not.
  18501. */
  18502. get toneMappingEnabled(): boolean;
  18503. /**
  18504. * Sets wether tonemapping is enabled or not
  18505. */
  18506. set toneMappingEnabled(value: boolean);
  18507. /**
  18508. * Gets the type of tone mapping effect.
  18509. */
  18510. get toneMappingType(): number;
  18511. /**
  18512. * Sets the type of tone mapping effect.
  18513. */
  18514. set toneMappingType(value: number);
  18515. /**
  18516. * Gets contrast used in the effect.
  18517. */
  18518. get contrast(): number;
  18519. /**
  18520. * Sets contrast used in the effect.
  18521. */
  18522. set contrast(value: number);
  18523. /**
  18524. * Gets Vignette stretch size.
  18525. */
  18526. get vignetteStretch(): number;
  18527. /**
  18528. * Sets Vignette stretch size.
  18529. */
  18530. set vignetteStretch(value: number);
  18531. /**
  18532. * Gets Vignette centre X Offset.
  18533. */
  18534. get vignetteCentreX(): number;
  18535. /**
  18536. * Sets Vignette centre X Offset.
  18537. */
  18538. set vignetteCentreX(value: number);
  18539. /**
  18540. * Gets Vignette centre Y Offset.
  18541. */
  18542. get vignetteCentreY(): number;
  18543. /**
  18544. * Sets Vignette centre Y Offset.
  18545. */
  18546. set vignetteCentreY(value: number);
  18547. /**
  18548. * Gets Vignette weight or intensity of the vignette effect.
  18549. */
  18550. get vignetteWeight(): number;
  18551. /**
  18552. * Sets Vignette weight or intensity of the vignette effect.
  18553. */
  18554. set vignetteWeight(value: number);
  18555. /**
  18556. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18557. * if vignetteEnabled is set to true.
  18558. */
  18559. get vignetteColor(): Color4;
  18560. /**
  18561. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18562. * if vignetteEnabled is set to true.
  18563. */
  18564. set vignetteColor(value: Color4);
  18565. /**
  18566. * Gets Camera field of view used by the Vignette effect.
  18567. */
  18568. get vignetteCameraFov(): number;
  18569. /**
  18570. * Sets Camera field of view used by the Vignette effect.
  18571. */
  18572. set vignetteCameraFov(value: number);
  18573. /**
  18574. * Gets the vignette blend mode allowing different kind of effect.
  18575. */
  18576. get vignetteBlendMode(): number;
  18577. /**
  18578. * Sets the vignette blend mode allowing different kind of effect.
  18579. */
  18580. set vignetteBlendMode(value: number);
  18581. /**
  18582. * Gets wether the vignette effect is enabled.
  18583. */
  18584. get vignetteEnabled(): boolean;
  18585. /**
  18586. * Sets wether the vignette effect is enabled.
  18587. */
  18588. set vignetteEnabled(value: boolean);
  18589. private _fromLinearSpace;
  18590. /**
  18591. * Gets wether the input of the processing is in Gamma or Linear Space.
  18592. */
  18593. get fromLinearSpace(): boolean;
  18594. /**
  18595. * Sets wether the input of the processing is in Gamma or Linear Space.
  18596. */
  18597. set fromLinearSpace(value: boolean);
  18598. /**
  18599. * Defines cache preventing GC.
  18600. */
  18601. private _defines;
  18602. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18603. /**
  18604. * "ImageProcessingPostProcess"
  18605. * @returns "ImageProcessingPostProcess"
  18606. */
  18607. getClassName(): string;
  18608. /**
  18609. * @hidden
  18610. */
  18611. _updateParameters(): void;
  18612. dispose(camera?: Camera): void;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Interface for defining prepass effects in the prepass post-process pipeline
  18618. */
  18619. export interface PrePassEffectConfiguration {
  18620. /**
  18621. * Name of the effect
  18622. */
  18623. name: string;
  18624. /**
  18625. * Post process to attach for this effect
  18626. */
  18627. postProcess?: PostProcess;
  18628. /**
  18629. * Textures required in the MRT
  18630. */
  18631. texturesRequired: number[];
  18632. /**
  18633. * Is the effect enabled
  18634. */
  18635. enabled: boolean;
  18636. /**
  18637. * Disposes the effect configuration
  18638. */
  18639. dispose?: () => void;
  18640. /**
  18641. * Creates the associated post process
  18642. */
  18643. createPostProcess?: () => PostProcess;
  18644. }
  18645. }
  18646. declare module BABYLON {
  18647. /**
  18648. * Options to be used when creating a FresnelParameters.
  18649. */
  18650. export type IFresnelParametersCreationOptions = {
  18651. /**
  18652. * Define the color used on edges (grazing angle)
  18653. */
  18654. leftColor?: Color3;
  18655. /**
  18656. * Define the color used on center
  18657. */
  18658. rightColor?: Color3;
  18659. /**
  18660. * Define bias applied to computed fresnel term
  18661. */
  18662. bias?: number;
  18663. /**
  18664. * Defined the power exponent applied to fresnel term
  18665. */
  18666. power?: number;
  18667. /**
  18668. * Define if the fresnel effect is enable or not.
  18669. */
  18670. isEnabled?: boolean;
  18671. };
  18672. /**
  18673. * Serialized format for FresnelParameters.
  18674. */
  18675. export type IFresnelParametersSerialized = {
  18676. /**
  18677. * Define the color used on edges (grazing angle) [as an array]
  18678. */
  18679. leftColor: number[];
  18680. /**
  18681. * Define the color used on center [as an array]
  18682. */
  18683. rightColor: number[];
  18684. /**
  18685. * Define bias applied to computed fresnel term
  18686. */
  18687. bias: number;
  18688. /**
  18689. * Defined the power exponent applied to fresnel term
  18690. */
  18691. power?: number;
  18692. /**
  18693. * Define if the fresnel effect is enable or not.
  18694. */
  18695. isEnabled: boolean;
  18696. };
  18697. /**
  18698. * This represents all the required information to add a fresnel effect on a material:
  18699. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18700. */
  18701. export class FresnelParameters {
  18702. private _isEnabled;
  18703. /**
  18704. * Define if the fresnel effect is enable or not.
  18705. */
  18706. get isEnabled(): boolean;
  18707. set isEnabled(value: boolean);
  18708. /**
  18709. * Define the color used on edges (grazing angle)
  18710. */
  18711. leftColor: Color3;
  18712. /**
  18713. * Define the color used on center
  18714. */
  18715. rightColor: Color3;
  18716. /**
  18717. * Define bias applied to computed fresnel term
  18718. */
  18719. bias: number;
  18720. /**
  18721. * Defined the power exponent applied to fresnel term
  18722. */
  18723. power: number;
  18724. /**
  18725. * Creates a new FresnelParameters object.
  18726. *
  18727. * @param options provide your own settings to optionally to override defaults
  18728. */
  18729. constructor(options?: IFresnelParametersCreationOptions);
  18730. /**
  18731. * Clones the current fresnel and its valuues
  18732. * @returns a clone fresnel configuration
  18733. */
  18734. clone(): FresnelParameters;
  18735. /**
  18736. * Determines equality between FresnelParameters objects
  18737. * @param otherFresnelParameters defines the second operand
  18738. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18739. */
  18740. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18741. /**
  18742. * Serializes the current fresnel parameters to a JSON representation.
  18743. * @return the JSON serialization
  18744. */
  18745. serialize(): IFresnelParametersSerialized;
  18746. /**
  18747. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18748. * @param parsedFresnelParameters Define the JSON representation
  18749. * @returns the parsed parameters
  18750. */
  18751. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18752. }
  18753. }
  18754. declare module BABYLON {
  18755. /**
  18756. * This groups all the flags used to control the materials channel.
  18757. */
  18758. export class MaterialFlags {
  18759. private static _DiffuseTextureEnabled;
  18760. /**
  18761. * Are diffuse textures enabled in the application.
  18762. */
  18763. static get DiffuseTextureEnabled(): boolean;
  18764. static set DiffuseTextureEnabled(value: boolean);
  18765. private static _DetailTextureEnabled;
  18766. /**
  18767. * Are detail textures enabled in the application.
  18768. */
  18769. static get DetailTextureEnabled(): boolean;
  18770. static set DetailTextureEnabled(value: boolean);
  18771. private static _AmbientTextureEnabled;
  18772. /**
  18773. * Are ambient textures enabled in the application.
  18774. */
  18775. static get AmbientTextureEnabled(): boolean;
  18776. static set AmbientTextureEnabled(value: boolean);
  18777. private static _OpacityTextureEnabled;
  18778. /**
  18779. * Are opacity textures enabled in the application.
  18780. */
  18781. static get OpacityTextureEnabled(): boolean;
  18782. static set OpacityTextureEnabled(value: boolean);
  18783. private static _ReflectionTextureEnabled;
  18784. /**
  18785. * Are reflection textures enabled in the application.
  18786. */
  18787. static get ReflectionTextureEnabled(): boolean;
  18788. static set ReflectionTextureEnabled(value: boolean);
  18789. private static _EmissiveTextureEnabled;
  18790. /**
  18791. * Are emissive textures enabled in the application.
  18792. */
  18793. static get EmissiveTextureEnabled(): boolean;
  18794. static set EmissiveTextureEnabled(value: boolean);
  18795. private static _SpecularTextureEnabled;
  18796. /**
  18797. * Are specular textures enabled in the application.
  18798. */
  18799. static get SpecularTextureEnabled(): boolean;
  18800. static set SpecularTextureEnabled(value: boolean);
  18801. private static _BumpTextureEnabled;
  18802. /**
  18803. * Are bump textures enabled in the application.
  18804. */
  18805. static get BumpTextureEnabled(): boolean;
  18806. static set BumpTextureEnabled(value: boolean);
  18807. private static _LightmapTextureEnabled;
  18808. /**
  18809. * Are lightmap textures enabled in the application.
  18810. */
  18811. static get LightmapTextureEnabled(): boolean;
  18812. static set LightmapTextureEnabled(value: boolean);
  18813. private static _RefractionTextureEnabled;
  18814. /**
  18815. * Are refraction textures enabled in the application.
  18816. */
  18817. static get RefractionTextureEnabled(): boolean;
  18818. static set RefractionTextureEnabled(value: boolean);
  18819. private static _ColorGradingTextureEnabled;
  18820. /**
  18821. * Are color grading textures enabled in the application.
  18822. */
  18823. static get ColorGradingTextureEnabled(): boolean;
  18824. static set ColorGradingTextureEnabled(value: boolean);
  18825. private static _FresnelEnabled;
  18826. /**
  18827. * Are fresnels enabled in the application.
  18828. */
  18829. static get FresnelEnabled(): boolean;
  18830. static set FresnelEnabled(value: boolean);
  18831. private static _ClearCoatTextureEnabled;
  18832. /**
  18833. * Are clear coat textures enabled in the application.
  18834. */
  18835. static get ClearCoatTextureEnabled(): boolean;
  18836. static set ClearCoatTextureEnabled(value: boolean);
  18837. private static _ClearCoatBumpTextureEnabled;
  18838. /**
  18839. * Are clear coat bump textures enabled in the application.
  18840. */
  18841. static get ClearCoatBumpTextureEnabled(): boolean;
  18842. static set ClearCoatBumpTextureEnabled(value: boolean);
  18843. private static _ClearCoatTintTextureEnabled;
  18844. /**
  18845. * Are clear coat tint textures enabled in the application.
  18846. */
  18847. static get ClearCoatTintTextureEnabled(): boolean;
  18848. static set ClearCoatTintTextureEnabled(value: boolean);
  18849. private static _SheenTextureEnabled;
  18850. /**
  18851. * Are sheen textures enabled in the application.
  18852. */
  18853. static get SheenTextureEnabled(): boolean;
  18854. static set SheenTextureEnabled(value: boolean);
  18855. private static _AnisotropicTextureEnabled;
  18856. /**
  18857. * Are anisotropic textures enabled in the application.
  18858. */
  18859. static get AnisotropicTextureEnabled(): boolean;
  18860. static set AnisotropicTextureEnabled(value: boolean);
  18861. private static _ThicknessTextureEnabled;
  18862. /**
  18863. * Are thickness textures enabled in the application.
  18864. */
  18865. static get ThicknessTextureEnabled(): boolean;
  18866. static set ThicknessTextureEnabled(value: boolean);
  18867. }
  18868. }
  18869. declare module BABYLON {
  18870. /** @hidden */
  18871. export var defaultFragmentDeclaration: {
  18872. name: string;
  18873. shader: string;
  18874. };
  18875. }
  18876. declare module BABYLON {
  18877. /** @hidden */
  18878. export var sceneUboDeclaration: {
  18879. name: string;
  18880. shader: string;
  18881. };
  18882. }
  18883. declare module BABYLON {
  18884. /** @hidden */
  18885. export var meshUboDeclaration: {
  18886. name: string;
  18887. shader: string;
  18888. };
  18889. }
  18890. declare module BABYLON {
  18891. /** @hidden */
  18892. export var defaultUboDeclaration: {
  18893. name: string;
  18894. shader: string;
  18895. };
  18896. }
  18897. declare module BABYLON {
  18898. /** @hidden */
  18899. export var prePassDeclaration: {
  18900. name: string;
  18901. shader: string;
  18902. };
  18903. }
  18904. declare module BABYLON {
  18905. /** @hidden */
  18906. export var lightFragmentDeclaration: {
  18907. name: string;
  18908. shader: string;
  18909. };
  18910. }
  18911. declare module BABYLON {
  18912. /** @hidden */
  18913. export var lightUboDeclaration: {
  18914. name: string;
  18915. shader: string;
  18916. };
  18917. }
  18918. declare module BABYLON {
  18919. /** @hidden */
  18920. export var lightsFragmentFunctions: {
  18921. name: string;
  18922. shader: string;
  18923. };
  18924. }
  18925. declare module BABYLON {
  18926. /** @hidden */
  18927. export var shadowsFragmentFunctions: {
  18928. name: string;
  18929. shader: string;
  18930. };
  18931. }
  18932. declare module BABYLON {
  18933. /** @hidden */
  18934. export var fresnelFunction: {
  18935. name: string;
  18936. shader: string;
  18937. };
  18938. }
  18939. declare module BABYLON {
  18940. /** @hidden */
  18941. export var bumpFragmentMainFunctions: {
  18942. name: string;
  18943. shader: string;
  18944. };
  18945. }
  18946. declare module BABYLON {
  18947. /** @hidden */
  18948. export var bumpFragmentFunctions: {
  18949. name: string;
  18950. shader: string;
  18951. };
  18952. }
  18953. declare module BABYLON {
  18954. /** @hidden */
  18955. export var logDepthDeclaration: {
  18956. name: string;
  18957. shader: string;
  18958. };
  18959. }
  18960. declare module BABYLON {
  18961. /** @hidden */
  18962. export var fogFragmentDeclaration: {
  18963. name: string;
  18964. shader: string;
  18965. };
  18966. }
  18967. declare module BABYLON {
  18968. /** @hidden */
  18969. export var bumpFragment: {
  18970. name: string;
  18971. shader: string;
  18972. };
  18973. }
  18974. declare module BABYLON {
  18975. /** @hidden */
  18976. export var depthPrePass: {
  18977. name: string;
  18978. shader: string;
  18979. };
  18980. }
  18981. declare module BABYLON {
  18982. /** @hidden */
  18983. export var lightFragment: {
  18984. name: string;
  18985. shader: string;
  18986. };
  18987. }
  18988. declare module BABYLON {
  18989. /** @hidden */
  18990. export var logDepthFragment: {
  18991. name: string;
  18992. shader: string;
  18993. };
  18994. }
  18995. declare module BABYLON {
  18996. /** @hidden */
  18997. export var fogFragment: {
  18998. name: string;
  18999. shader: string;
  19000. };
  19001. }
  19002. declare module BABYLON {
  19003. /** @hidden */
  19004. export var defaultPixelShader: {
  19005. name: string;
  19006. shader: string;
  19007. };
  19008. }
  19009. declare module BABYLON {
  19010. /** @hidden */
  19011. export var defaultVertexDeclaration: {
  19012. name: string;
  19013. shader: string;
  19014. };
  19015. }
  19016. declare module BABYLON {
  19017. /** @hidden */
  19018. export var bonesDeclaration: {
  19019. name: string;
  19020. shader: string;
  19021. };
  19022. }
  19023. declare module BABYLON {
  19024. /** @hidden */
  19025. export var prePassVertexDeclaration: {
  19026. name: string;
  19027. shader: string;
  19028. };
  19029. }
  19030. declare module BABYLON {
  19031. /** @hidden */
  19032. export var bumpVertexDeclaration: {
  19033. name: string;
  19034. shader: string;
  19035. };
  19036. }
  19037. declare module BABYLON {
  19038. /** @hidden */
  19039. export var fogVertexDeclaration: {
  19040. name: string;
  19041. shader: string;
  19042. };
  19043. }
  19044. declare module BABYLON {
  19045. /** @hidden */
  19046. export var lightVxFragmentDeclaration: {
  19047. name: string;
  19048. shader: string;
  19049. };
  19050. }
  19051. declare module BABYLON {
  19052. /** @hidden */
  19053. export var lightVxUboDeclaration: {
  19054. name: string;
  19055. shader: string;
  19056. };
  19057. }
  19058. declare module BABYLON {
  19059. /** @hidden */
  19060. export var morphTargetsVertexGlobalDeclaration: {
  19061. name: string;
  19062. shader: string;
  19063. };
  19064. }
  19065. declare module BABYLON {
  19066. /** @hidden */
  19067. export var morphTargetsVertexDeclaration: {
  19068. name: string;
  19069. shader: string;
  19070. };
  19071. }
  19072. declare module BABYLON {
  19073. /** @hidden */
  19074. export var morphTargetsVertex: {
  19075. name: string;
  19076. shader: string;
  19077. };
  19078. }
  19079. declare module BABYLON {
  19080. /** @hidden */
  19081. export var instancesVertex: {
  19082. name: string;
  19083. shader: string;
  19084. };
  19085. }
  19086. declare module BABYLON {
  19087. /** @hidden */
  19088. export var bonesVertex: {
  19089. name: string;
  19090. shader: string;
  19091. };
  19092. }
  19093. declare module BABYLON {
  19094. /** @hidden */
  19095. export var prePassVertex: {
  19096. name: string;
  19097. shader: string;
  19098. };
  19099. }
  19100. declare module BABYLON {
  19101. /** @hidden */
  19102. export var bumpVertex: {
  19103. name: string;
  19104. shader: string;
  19105. };
  19106. }
  19107. declare module BABYLON {
  19108. /** @hidden */
  19109. export var fogVertex: {
  19110. name: string;
  19111. shader: string;
  19112. };
  19113. }
  19114. declare module BABYLON {
  19115. /** @hidden */
  19116. export var shadowsVertex: {
  19117. name: string;
  19118. shader: string;
  19119. };
  19120. }
  19121. declare module BABYLON {
  19122. /** @hidden */
  19123. export var pointCloudVertex: {
  19124. name: string;
  19125. shader: string;
  19126. };
  19127. }
  19128. declare module BABYLON {
  19129. /** @hidden */
  19130. export var logDepthVertex: {
  19131. name: string;
  19132. shader: string;
  19133. };
  19134. }
  19135. declare module BABYLON {
  19136. /** @hidden */
  19137. export var defaultVertexShader: {
  19138. name: string;
  19139. shader: string;
  19140. };
  19141. }
  19142. declare module BABYLON {
  19143. /**
  19144. * @hidden
  19145. */
  19146. export interface IMaterialDetailMapDefines {
  19147. DETAIL: boolean;
  19148. DETAILDIRECTUV: number;
  19149. DETAIL_NORMALBLENDMETHOD: number;
  19150. /** @hidden */
  19151. _areTexturesDirty: boolean;
  19152. }
  19153. /**
  19154. * Define the code related to the detail map parameters of a material
  19155. *
  19156. * Inspired from:
  19157. * 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
  19158. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19159. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19160. */
  19161. export class DetailMapConfiguration {
  19162. private _texture;
  19163. /**
  19164. * The detail texture of the material.
  19165. */
  19166. texture: Nullable<BaseTexture>;
  19167. /**
  19168. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19169. * Bigger values mean stronger blending
  19170. */
  19171. diffuseBlendLevel: number;
  19172. /**
  19173. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19174. * Bigger values mean stronger blending. Only used with PBR materials
  19175. */
  19176. roughnessBlendLevel: number;
  19177. /**
  19178. * Defines how strong the bump effect from the detail map is
  19179. * Bigger values mean stronger effect
  19180. */
  19181. bumpLevel: number;
  19182. private _normalBlendMethod;
  19183. /**
  19184. * The method used to blend the bump and detail normals together
  19185. */
  19186. normalBlendMethod: number;
  19187. private _isEnabled;
  19188. /**
  19189. * Enable or disable the detail map on this material
  19190. */
  19191. isEnabled: boolean;
  19192. /** @hidden */
  19193. private _internalMarkAllSubMeshesAsTexturesDirty;
  19194. /** @hidden */
  19195. _markAllSubMeshesAsTexturesDirty(): void;
  19196. /**
  19197. * Instantiate a new detail map
  19198. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19199. */
  19200. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19201. /**
  19202. * Gets whether the submesh is ready to be used or not.
  19203. * @param defines the list of "defines" to update.
  19204. * @param scene defines the scene the material belongs to.
  19205. * @returns - boolean indicating that the submesh is ready or not.
  19206. */
  19207. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19208. /**
  19209. * Update the defines for detail map usage
  19210. * @param defines the list of "defines" to update.
  19211. * @param scene defines the scene the material belongs to.
  19212. */
  19213. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19214. /**
  19215. * Binds the material data.
  19216. * @param uniformBuffer defines the Uniform buffer to fill in.
  19217. * @param scene defines the scene the material belongs to.
  19218. * @param isFrozen defines whether the material is frozen or not.
  19219. */
  19220. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19221. /**
  19222. * Checks to see if a texture is used in the material.
  19223. * @param texture - Base texture to use.
  19224. * @returns - Boolean specifying if a texture is used in the material.
  19225. */
  19226. hasTexture(texture: BaseTexture): boolean;
  19227. /**
  19228. * Returns an array of the actively used textures.
  19229. * @param activeTextures Array of BaseTextures
  19230. */
  19231. getActiveTextures(activeTextures: BaseTexture[]): void;
  19232. /**
  19233. * Returns the animatable textures.
  19234. * @param animatables Array of animatable textures.
  19235. */
  19236. getAnimatables(animatables: IAnimatable[]): void;
  19237. /**
  19238. * Disposes the resources of the material.
  19239. * @param forceDisposeTextures - Forces the disposal of all textures.
  19240. */
  19241. dispose(forceDisposeTextures?: boolean): void;
  19242. /**
  19243. * Get the current class name useful for serialization or dynamic coding.
  19244. * @returns "DetailMap"
  19245. */
  19246. getClassName(): string;
  19247. /**
  19248. * Add the required uniforms to the current list.
  19249. * @param uniforms defines the current uniform list.
  19250. */
  19251. static AddUniforms(uniforms: string[]): void;
  19252. /**
  19253. * Add the required samplers to the current list.
  19254. * @param samplers defines the current sampler list.
  19255. */
  19256. static AddSamplers(samplers: string[]): void;
  19257. /**
  19258. * Add the required uniforms to the current buffer.
  19259. * @param uniformBuffer defines the current uniform buffer.
  19260. */
  19261. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19262. /**
  19263. * Makes a duplicate of the current instance into another one.
  19264. * @param detailMap define the instance where to copy the info
  19265. */
  19266. copyTo(detailMap: DetailMapConfiguration): void;
  19267. /**
  19268. * Serializes this detail map instance
  19269. * @returns - An object with the serialized instance.
  19270. */
  19271. serialize(): any;
  19272. /**
  19273. * Parses a detail map setting from a serialized object.
  19274. * @param source - Serialized object.
  19275. * @param scene Defines the scene we are parsing for
  19276. * @param rootUrl Defines the rootUrl to load from
  19277. */
  19278. parse(source: any, scene: Scene, rootUrl: string): void;
  19279. }
  19280. }
  19281. declare module BABYLON {
  19282. /** @hidden */
  19283. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19284. MAINUV1: boolean;
  19285. MAINUV2: boolean;
  19286. DIFFUSE: boolean;
  19287. DIFFUSEDIRECTUV: number;
  19288. DETAIL: boolean;
  19289. DETAILDIRECTUV: number;
  19290. DETAIL_NORMALBLENDMETHOD: number;
  19291. AMBIENT: boolean;
  19292. AMBIENTDIRECTUV: number;
  19293. OPACITY: boolean;
  19294. OPACITYDIRECTUV: number;
  19295. OPACITYRGB: boolean;
  19296. REFLECTION: boolean;
  19297. EMISSIVE: boolean;
  19298. EMISSIVEDIRECTUV: number;
  19299. SPECULAR: boolean;
  19300. SPECULARDIRECTUV: number;
  19301. BUMP: boolean;
  19302. BUMPDIRECTUV: number;
  19303. PARALLAX: boolean;
  19304. PARALLAXOCCLUSION: boolean;
  19305. SPECULAROVERALPHA: boolean;
  19306. CLIPPLANE: boolean;
  19307. CLIPPLANE2: boolean;
  19308. CLIPPLANE3: boolean;
  19309. CLIPPLANE4: boolean;
  19310. CLIPPLANE5: boolean;
  19311. CLIPPLANE6: boolean;
  19312. ALPHATEST: boolean;
  19313. DEPTHPREPASS: boolean;
  19314. ALPHAFROMDIFFUSE: boolean;
  19315. POINTSIZE: boolean;
  19316. FOG: boolean;
  19317. SPECULARTERM: boolean;
  19318. DIFFUSEFRESNEL: boolean;
  19319. OPACITYFRESNEL: boolean;
  19320. REFLECTIONFRESNEL: boolean;
  19321. REFRACTIONFRESNEL: boolean;
  19322. EMISSIVEFRESNEL: boolean;
  19323. FRESNEL: boolean;
  19324. NORMAL: boolean;
  19325. UV1: boolean;
  19326. UV2: boolean;
  19327. VERTEXCOLOR: boolean;
  19328. VERTEXALPHA: boolean;
  19329. NUM_BONE_INFLUENCERS: number;
  19330. BonesPerMesh: number;
  19331. BONETEXTURE: boolean;
  19332. BONES_VELOCITY_ENABLED: boolean;
  19333. INSTANCES: boolean;
  19334. THIN_INSTANCES: boolean;
  19335. GLOSSINESS: boolean;
  19336. ROUGHNESS: boolean;
  19337. EMISSIVEASILLUMINATION: boolean;
  19338. LINKEMISSIVEWITHDIFFUSE: boolean;
  19339. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19340. LIGHTMAP: boolean;
  19341. LIGHTMAPDIRECTUV: number;
  19342. OBJECTSPACE_NORMALMAP: boolean;
  19343. USELIGHTMAPASSHADOWMAP: boolean;
  19344. REFLECTIONMAP_3D: boolean;
  19345. REFLECTIONMAP_SPHERICAL: boolean;
  19346. REFLECTIONMAP_PLANAR: boolean;
  19347. REFLECTIONMAP_CUBIC: boolean;
  19348. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19349. REFLECTIONMAP_PROJECTION: boolean;
  19350. REFLECTIONMAP_SKYBOX: boolean;
  19351. REFLECTIONMAP_EXPLICIT: boolean;
  19352. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19353. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19354. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19355. REFLECTIONMAP_OPPOSITEZ: boolean;
  19356. INVERTCUBICMAP: boolean;
  19357. LOGARITHMICDEPTH: boolean;
  19358. REFRACTION: boolean;
  19359. REFRACTIONMAP_3D: boolean;
  19360. REFLECTIONOVERALPHA: boolean;
  19361. TWOSIDEDLIGHTING: boolean;
  19362. SHADOWFLOAT: boolean;
  19363. MORPHTARGETS: boolean;
  19364. MORPHTARGETS_NORMAL: boolean;
  19365. MORPHTARGETS_TANGENT: boolean;
  19366. MORPHTARGETS_UV: boolean;
  19367. NUM_MORPH_INFLUENCERS: number;
  19368. NONUNIFORMSCALING: boolean;
  19369. PREMULTIPLYALPHA: boolean;
  19370. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19371. ALPHABLEND: boolean;
  19372. PREPASS: boolean;
  19373. PREPASS_IRRADIANCE: boolean;
  19374. PREPASS_IRRADIANCE_INDEX: number;
  19375. PREPASS_ALBEDO: boolean;
  19376. PREPASS_ALBEDO_INDEX: number;
  19377. PREPASS_DEPTHNORMAL: boolean;
  19378. PREPASS_DEPTHNORMAL_INDEX: number;
  19379. PREPASS_POSITION: boolean;
  19380. PREPASS_POSITION_INDEX: number;
  19381. PREPASS_VELOCITY: boolean;
  19382. PREPASS_VELOCITY_INDEX: number;
  19383. PREPASS_REFLECTIVITY: boolean;
  19384. PREPASS_REFLECTIVITY_INDEX: number;
  19385. SCENE_MRT_COUNT: number;
  19386. RGBDLIGHTMAP: boolean;
  19387. RGBDREFLECTION: boolean;
  19388. RGBDREFRACTION: boolean;
  19389. IMAGEPROCESSING: boolean;
  19390. VIGNETTE: boolean;
  19391. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19392. VIGNETTEBLENDMODEOPAQUE: boolean;
  19393. TONEMAPPING: boolean;
  19394. TONEMAPPING_ACES: boolean;
  19395. CONTRAST: boolean;
  19396. COLORCURVES: boolean;
  19397. COLORGRADING: boolean;
  19398. COLORGRADING3D: boolean;
  19399. SAMPLER3DGREENDEPTH: boolean;
  19400. SAMPLER3DBGRMAP: boolean;
  19401. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19402. MULTIVIEW: boolean;
  19403. /**
  19404. * If the reflection texture on this material is in linear color space
  19405. * @hidden
  19406. */
  19407. IS_REFLECTION_LINEAR: boolean;
  19408. /**
  19409. * If the refraction texture on this material is in linear color space
  19410. * @hidden
  19411. */
  19412. IS_REFRACTION_LINEAR: boolean;
  19413. EXPOSURE: boolean;
  19414. constructor();
  19415. setReflectionMode(modeToEnable: string): void;
  19416. }
  19417. /**
  19418. * This is the default material used in Babylon. It is the best trade off between quality
  19419. * and performances.
  19420. * @see https://doc.babylonjs.com/babylon101/materials
  19421. */
  19422. export class StandardMaterial extends PushMaterial {
  19423. private _diffuseTexture;
  19424. /**
  19425. * The basic texture of the material as viewed under a light.
  19426. */
  19427. diffuseTexture: Nullable<BaseTexture>;
  19428. private _ambientTexture;
  19429. /**
  19430. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19431. */
  19432. ambientTexture: Nullable<BaseTexture>;
  19433. private _opacityTexture;
  19434. /**
  19435. * Define the transparency of the material from a texture.
  19436. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19437. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19438. */
  19439. opacityTexture: Nullable<BaseTexture>;
  19440. private _reflectionTexture;
  19441. /**
  19442. * Define the texture used to display the reflection.
  19443. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19444. */
  19445. reflectionTexture: Nullable<BaseTexture>;
  19446. private _emissiveTexture;
  19447. /**
  19448. * Define texture of the material as if self lit.
  19449. * This will be mixed in the final result even in the absence of light.
  19450. */
  19451. emissiveTexture: Nullable<BaseTexture>;
  19452. private _specularTexture;
  19453. /**
  19454. * Define how the color and intensity of the highlight given by the light in the material.
  19455. */
  19456. specularTexture: Nullable<BaseTexture>;
  19457. private _bumpTexture;
  19458. /**
  19459. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19460. * 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.
  19461. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19462. */
  19463. bumpTexture: Nullable<BaseTexture>;
  19464. private _lightmapTexture;
  19465. /**
  19466. * Complex lighting can be computationally expensive to compute at runtime.
  19467. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19468. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19469. */
  19470. lightmapTexture: Nullable<BaseTexture>;
  19471. private _refractionTexture;
  19472. /**
  19473. * Define the texture used to display the refraction.
  19474. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19475. */
  19476. refractionTexture: Nullable<BaseTexture>;
  19477. /**
  19478. * The color of the material lit by the environmental background lighting.
  19479. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19480. */
  19481. ambientColor: Color3;
  19482. /**
  19483. * The basic color of the material as viewed under a light.
  19484. */
  19485. diffuseColor: Color3;
  19486. /**
  19487. * Define how the color and intensity of the highlight given by the light in the material.
  19488. */
  19489. specularColor: Color3;
  19490. /**
  19491. * Define the color of the material as if self lit.
  19492. * This will be mixed in the final result even in the absence of light.
  19493. */
  19494. emissiveColor: Color3;
  19495. /**
  19496. * Defines how sharp are the highlights in the material.
  19497. * The bigger the value the sharper giving a more glossy feeling to the result.
  19498. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19499. */
  19500. specularPower: number;
  19501. private _useAlphaFromDiffuseTexture;
  19502. /**
  19503. * Does the transparency come from the diffuse texture alpha channel.
  19504. */
  19505. useAlphaFromDiffuseTexture: boolean;
  19506. private _useEmissiveAsIllumination;
  19507. /**
  19508. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19509. */
  19510. useEmissiveAsIllumination: boolean;
  19511. private _linkEmissiveWithDiffuse;
  19512. /**
  19513. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19514. * the emissive level when the final color is close to one.
  19515. */
  19516. linkEmissiveWithDiffuse: boolean;
  19517. private _useSpecularOverAlpha;
  19518. /**
  19519. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19520. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19521. */
  19522. useSpecularOverAlpha: boolean;
  19523. private _useReflectionOverAlpha;
  19524. /**
  19525. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19526. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19527. */
  19528. useReflectionOverAlpha: boolean;
  19529. private _disableLighting;
  19530. /**
  19531. * Does lights from the scene impacts this material.
  19532. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19533. */
  19534. disableLighting: boolean;
  19535. private _useObjectSpaceNormalMap;
  19536. /**
  19537. * Allows using an object space normal map (instead of tangent space).
  19538. */
  19539. useObjectSpaceNormalMap: boolean;
  19540. private _useParallax;
  19541. /**
  19542. * Is parallax enabled or not.
  19543. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19544. */
  19545. useParallax: boolean;
  19546. private _useParallaxOcclusion;
  19547. /**
  19548. * Is parallax occlusion enabled or not.
  19549. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19550. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19551. */
  19552. useParallaxOcclusion: boolean;
  19553. /**
  19554. * 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.
  19555. */
  19556. parallaxScaleBias: number;
  19557. private _roughness;
  19558. /**
  19559. * Helps to define how blurry the reflections should appears in the material.
  19560. */
  19561. roughness: number;
  19562. /**
  19563. * In case of refraction, define the value of the index of refraction.
  19564. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19565. */
  19566. indexOfRefraction: number;
  19567. /**
  19568. * Invert the refraction texture alongside the y axis.
  19569. * It can be useful with procedural textures or probe for instance.
  19570. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19571. */
  19572. invertRefractionY: boolean;
  19573. /**
  19574. * Defines the alpha limits in alpha test mode.
  19575. */
  19576. alphaCutOff: number;
  19577. private _useLightmapAsShadowmap;
  19578. /**
  19579. * In case of light mapping, define whether the map contains light or shadow informations.
  19580. */
  19581. useLightmapAsShadowmap: boolean;
  19582. private _diffuseFresnelParameters;
  19583. /**
  19584. * Define the diffuse fresnel parameters of the material.
  19585. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19586. */
  19587. diffuseFresnelParameters: FresnelParameters;
  19588. private _opacityFresnelParameters;
  19589. /**
  19590. * Define the opacity fresnel parameters of the material.
  19591. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19592. */
  19593. opacityFresnelParameters: FresnelParameters;
  19594. private _reflectionFresnelParameters;
  19595. /**
  19596. * Define the reflection fresnel parameters of the material.
  19597. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19598. */
  19599. reflectionFresnelParameters: FresnelParameters;
  19600. private _refractionFresnelParameters;
  19601. /**
  19602. * Define the refraction fresnel parameters of the material.
  19603. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19604. */
  19605. refractionFresnelParameters: FresnelParameters;
  19606. private _emissiveFresnelParameters;
  19607. /**
  19608. * Define the emissive fresnel parameters of the material.
  19609. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19610. */
  19611. emissiveFresnelParameters: FresnelParameters;
  19612. private _useReflectionFresnelFromSpecular;
  19613. /**
  19614. * If true automatically deducts the fresnels values from the material specularity.
  19615. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19616. */
  19617. useReflectionFresnelFromSpecular: boolean;
  19618. private _useGlossinessFromSpecularMapAlpha;
  19619. /**
  19620. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19621. */
  19622. useGlossinessFromSpecularMapAlpha: boolean;
  19623. private _maxSimultaneousLights;
  19624. /**
  19625. * Defines the maximum number of lights that can be used in the material
  19626. */
  19627. maxSimultaneousLights: number;
  19628. private _invertNormalMapX;
  19629. /**
  19630. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19631. */
  19632. invertNormalMapX: boolean;
  19633. private _invertNormalMapY;
  19634. /**
  19635. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19636. */
  19637. invertNormalMapY: boolean;
  19638. private _twoSidedLighting;
  19639. /**
  19640. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19641. */
  19642. twoSidedLighting: boolean;
  19643. /**
  19644. * Default configuration related to image processing available in the standard Material.
  19645. */
  19646. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19647. /**
  19648. * Gets the image processing configuration used either in this material.
  19649. */
  19650. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19651. /**
  19652. * Sets the Default image processing configuration used either in the this material.
  19653. *
  19654. * If sets to null, the scene one is in use.
  19655. */
  19656. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19657. /**
  19658. * Keep track of the image processing observer to allow dispose and replace.
  19659. */
  19660. private _imageProcessingObserver;
  19661. /**
  19662. * Attaches a new image processing configuration to the Standard Material.
  19663. * @param configuration
  19664. */
  19665. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19666. /**
  19667. * Defines additionnal PrePass parameters for the material.
  19668. */
  19669. readonly prePassConfiguration: PrePassConfiguration;
  19670. /**
  19671. * Gets wether the color curves effect is enabled.
  19672. */
  19673. get cameraColorCurvesEnabled(): boolean;
  19674. /**
  19675. * Sets wether the color curves effect is enabled.
  19676. */
  19677. set cameraColorCurvesEnabled(value: boolean);
  19678. /**
  19679. * Gets wether the color grading effect is enabled.
  19680. */
  19681. get cameraColorGradingEnabled(): boolean;
  19682. /**
  19683. * Gets wether the color grading effect is enabled.
  19684. */
  19685. set cameraColorGradingEnabled(value: boolean);
  19686. /**
  19687. * Gets wether tonemapping is enabled or not.
  19688. */
  19689. get cameraToneMappingEnabled(): boolean;
  19690. /**
  19691. * Sets wether tonemapping is enabled or not
  19692. */
  19693. set cameraToneMappingEnabled(value: boolean);
  19694. /**
  19695. * The camera exposure used on this material.
  19696. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19697. * This corresponds to a photographic exposure.
  19698. */
  19699. get cameraExposure(): number;
  19700. /**
  19701. * The camera exposure used on this material.
  19702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19703. * This corresponds to a photographic exposure.
  19704. */
  19705. set cameraExposure(value: number);
  19706. /**
  19707. * Gets The camera contrast used on this material.
  19708. */
  19709. get cameraContrast(): number;
  19710. /**
  19711. * Sets The camera contrast used on this material.
  19712. */
  19713. set cameraContrast(value: number);
  19714. /**
  19715. * Gets the Color Grading 2D Lookup Texture.
  19716. */
  19717. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19718. /**
  19719. * Sets the Color Grading 2D Lookup Texture.
  19720. */
  19721. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19722. /**
  19723. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19724. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19725. * 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;
  19726. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19727. */
  19728. get cameraColorCurves(): Nullable<ColorCurves>;
  19729. /**
  19730. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19731. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19732. * 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;
  19733. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19734. */
  19735. set cameraColorCurves(value: Nullable<ColorCurves>);
  19736. /**
  19737. * Can this material render to several textures at once
  19738. */
  19739. get canRenderToMRT(): boolean;
  19740. /**
  19741. * Defines the detail map parameters for the material.
  19742. */
  19743. readonly detailMap: DetailMapConfiguration;
  19744. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19745. protected _worldViewProjectionMatrix: Matrix;
  19746. protected _globalAmbientColor: Color3;
  19747. protected _useLogarithmicDepth: boolean;
  19748. protected _rebuildInParallel: boolean;
  19749. /**
  19750. * Instantiates a new standard material.
  19751. * This is the default material used in Babylon. It is the best trade off between quality
  19752. * and performances.
  19753. * @see https://doc.babylonjs.com/babylon101/materials
  19754. * @param name Define the name of the material in the scene
  19755. * @param scene Define the scene the material belong to
  19756. */
  19757. constructor(name: string, scene: Scene);
  19758. /**
  19759. * Gets a boolean indicating that current material needs to register RTT
  19760. */
  19761. get hasRenderTargetTextures(): boolean;
  19762. /**
  19763. * Gets the current class name of the material e.g. "StandardMaterial"
  19764. * Mainly use in serialization.
  19765. * @returns the class name
  19766. */
  19767. getClassName(): string;
  19768. /**
  19769. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19770. * You can try switching to logarithmic depth.
  19771. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19772. */
  19773. get useLogarithmicDepth(): boolean;
  19774. set useLogarithmicDepth(value: boolean);
  19775. /**
  19776. * Specifies if the material will require alpha blending
  19777. * @returns a boolean specifying if alpha blending is needed
  19778. */
  19779. needAlphaBlending(): boolean;
  19780. /**
  19781. * Specifies if this material should be rendered in alpha test mode
  19782. * @returns a boolean specifying if an alpha test is needed.
  19783. */
  19784. needAlphaTesting(): boolean;
  19785. /**
  19786. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19787. */
  19788. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19789. /**
  19790. * Specifies whether or not there is a usable alpha channel for transparency.
  19791. */
  19792. protected _hasAlphaChannel(): boolean;
  19793. /**
  19794. * Get the texture used for alpha test purpose.
  19795. * @returns the diffuse texture in case of the standard material.
  19796. */
  19797. getAlphaTestTexture(): Nullable<BaseTexture>;
  19798. /**
  19799. * Get if the submesh is ready to be used and all its information available.
  19800. * Child classes can use it to update shaders
  19801. * @param mesh defines the mesh to check
  19802. * @param subMesh defines which submesh to check
  19803. * @param useInstances specifies that instances should be used
  19804. * @returns a boolean indicating that the submesh is ready or not
  19805. */
  19806. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19807. /**
  19808. * Builds the material UBO layouts.
  19809. * Used internally during the effect preparation.
  19810. */
  19811. buildUniformLayout(): void;
  19812. /**
  19813. * Unbinds the material from the mesh
  19814. */
  19815. unbind(): void;
  19816. /**
  19817. * Binds the submesh to this material by preparing the effect and shader to draw
  19818. * @param world defines the world transformation matrix
  19819. * @param mesh defines the mesh containing the submesh
  19820. * @param subMesh defines the submesh to bind the material to
  19821. */
  19822. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19823. /**
  19824. * Get the list of animatables in the material.
  19825. * @returns the list of animatables object used in the material
  19826. */
  19827. getAnimatables(): IAnimatable[];
  19828. /**
  19829. * Gets the active textures from the material
  19830. * @returns an array of textures
  19831. */
  19832. getActiveTextures(): BaseTexture[];
  19833. /**
  19834. * Specifies if the material uses a texture
  19835. * @param texture defines the texture to check against the material
  19836. * @returns a boolean specifying if the material uses the texture
  19837. */
  19838. hasTexture(texture: BaseTexture): boolean;
  19839. /**
  19840. * Disposes the material
  19841. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19842. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19843. */
  19844. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19845. /**
  19846. * Makes a duplicate of the material, and gives it a new name
  19847. * @param name defines the new name for the duplicated material
  19848. * @returns the cloned material
  19849. */
  19850. clone(name: string): StandardMaterial;
  19851. /**
  19852. * Serializes this material in a JSON representation
  19853. * @returns the serialized material object
  19854. */
  19855. serialize(): any;
  19856. /**
  19857. * Creates a standard material from parsed material data
  19858. * @param source defines the JSON representation of the material
  19859. * @param scene defines the hosting scene
  19860. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19861. * @returns a new standard material
  19862. */
  19863. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19864. /**
  19865. * Are diffuse textures enabled in the application.
  19866. */
  19867. static get DiffuseTextureEnabled(): boolean;
  19868. static set DiffuseTextureEnabled(value: boolean);
  19869. /**
  19870. * Are detail textures enabled in the application.
  19871. */
  19872. static get DetailTextureEnabled(): boolean;
  19873. static set DetailTextureEnabled(value: boolean);
  19874. /**
  19875. * Are ambient textures enabled in the application.
  19876. */
  19877. static get AmbientTextureEnabled(): boolean;
  19878. static set AmbientTextureEnabled(value: boolean);
  19879. /**
  19880. * Are opacity textures enabled in the application.
  19881. */
  19882. static get OpacityTextureEnabled(): boolean;
  19883. static set OpacityTextureEnabled(value: boolean);
  19884. /**
  19885. * Are reflection textures enabled in the application.
  19886. */
  19887. static get ReflectionTextureEnabled(): boolean;
  19888. static set ReflectionTextureEnabled(value: boolean);
  19889. /**
  19890. * Are emissive textures enabled in the application.
  19891. */
  19892. static get EmissiveTextureEnabled(): boolean;
  19893. static set EmissiveTextureEnabled(value: boolean);
  19894. /**
  19895. * Are specular textures enabled in the application.
  19896. */
  19897. static get SpecularTextureEnabled(): boolean;
  19898. static set SpecularTextureEnabled(value: boolean);
  19899. /**
  19900. * Are bump textures enabled in the application.
  19901. */
  19902. static get BumpTextureEnabled(): boolean;
  19903. static set BumpTextureEnabled(value: boolean);
  19904. /**
  19905. * Are lightmap textures enabled in the application.
  19906. */
  19907. static get LightmapTextureEnabled(): boolean;
  19908. static set LightmapTextureEnabled(value: boolean);
  19909. /**
  19910. * Are refraction textures enabled in the application.
  19911. */
  19912. static get RefractionTextureEnabled(): boolean;
  19913. static set RefractionTextureEnabled(value: boolean);
  19914. /**
  19915. * Are color grading textures enabled in the application.
  19916. */
  19917. static get ColorGradingTextureEnabled(): boolean;
  19918. static set ColorGradingTextureEnabled(value: boolean);
  19919. /**
  19920. * Are fresnels enabled in the application.
  19921. */
  19922. static get FresnelEnabled(): boolean;
  19923. static set FresnelEnabled(value: boolean);
  19924. }
  19925. }
  19926. declare module BABYLON {
  19927. /** @hidden */
  19928. export var rgbdDecodePixelShader: {
  19929. name: string;
  19930. shader: string;
  19931. };
  19932. }
  19933. declare module BABYLON {
  19934. /** @hidden */
  19935. export var passPixelShader: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module BABYLON {
  19941. /** @hidden */
  19942. export var passCubePixelShader: {
  19943. name: string;
  19944. shader: string;
  19945. };
  19946. }
  19947. declare module BABYLON {
  19948. /**
  19949. * PassPostProcess which produces an output the same as it's input
  19950. */
  19951. export class PassPostProcess extends PostProcess {
  19952. /**
  19953. * Gets a string identifying the name of the class
  19954. * @returns "PassPostProcess" string
  19955. */
  19956. getClassName(): string;
  19957. /**
  19958. * Creates the PassPostProcess
  19959. * @param name The name of the effect.
  19960. * @param options The required width/height ratio to downsize to before computing the render pass.
  19961. * @param camera The camera to apply the render pass to.
  19962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19963. * @param engine The engine which the post process will be applied. (default: current engine)
  19964. * @param reusable If the post process can be reused on the same frame. (default: false)
  19965. * @param textureType The type of texture to be used when performing the post processing.
  19966. * @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)
  19967. */
  19968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19969. /** @hidden */
  19970. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19971. }
  19972. /**
  19973. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19974. */
  19975. export class PassCubePostProcess extends PostProcess {
  19976. private _face;
  19977. /**
  19978. * Gets or sets the cube face to display.
  19979. * * 0 is +X
  19980. * * 1 is -X
  19981. * * 2 is +Y
  19982. * * 3 is -Y
  19983. * * 4 is +Z
  19984. * * 5 is -Z
  19985. */
  19986. get face(): number;
  19987. set face(value: number);
  19988. /**
  19989. * Gets a string identifying the name of the class
  19990. * @returns "PassCubePostProcess" string
  19991. */
  19992. getClassName(): string;
  19993. /**
  19994. * Creates the PassCubePostProcess
  19995. * @param name The name of the effect.
  19996. * @param options The required width/height ratio to downsize to before computing the render pass.
  19997. * @param camera The camera to apply the render pass to.
  19998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19999. * @param engine The engine which the post process will be applied. (default: current engine)
  20000. * @param reusable If the post process can be reused on the same frame. (default: false)
  20001. * @param textureType The type of texture to be used when performing the post processing.
  20002. * @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)
  20003. */
  20004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20005. /** @hidden */
  20006. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20007. }
  20008. }
  20009. declare module BABYLON {
  20010. /**
  20011. * Class used to host texture specific utilities
  20012. */
  20013. export class TextureTools {
  20014. /**
  20015. * Uses the GPU to create a copy texture rescaled at a given size
  20016. * @param texture Texture to copy from
  20017. * @param width defines the desired width
  20018. * @param height defines the desired height
  20019. * @param useBilinearMode defines if bilinear mode has to be used
  20020. * @return the generated texture
  20021. */
  20022. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20023. /**
  20024. * Apply a post process to a texture
  20025. * @param postProcessName name of the fragment post process
  20026. * @param internalTexture the texture to encode
  20027. * @param scene the scene hosting the texture
  20028. * @param type type of the output texture. If not provided, use the one from internalTexture
  20029. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20030. * @param format format of the output texture. If not provided, use the one from internalTexture
  20031. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20032. */
  20033. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20034. }
  20035. }
  20036. declare module BABYLON {
  20037. /**
  20038. * Class used to host RGBD texture specific utilities
  20039. */
  20040. export class RGBDTextureTools {
  20041. /**
  20042. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20043. * @param texture the texture to expand.
  20044. */
  20045. static ExpandRGBDTexture(texture: Texture): void;
  20046. /**
  20047. * Encode the texture to RGBD if possible.
  20048. * @param internalTexture the texture to encode
  20049. * @param scene the scene hosting the texture
  20050. * @param outputTextureType type of the texture in which the encoding is performed
  20051. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20052. */
  20053. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20054. }
  20055. }
  20056. declare module BABYLON {
  20057. /**
  20058. * Class used to host texture specific utilities
  20059. */
  20060. export class BRDFTextureTools {
  20061. /**
  20062. * Prevents texture cache collision
  20063. */
  20064. private static _instanceNumber;
  20065. /**
  20066. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20067. * @param scene defines the hosting scene
  20068. * @returns the environment BRDF texture
  20069. */
  20070. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20071. private static _environmentBRDFBase64Texture;
  20072. }
  20073. }
  20074. declare module BABYLON {
  20075. /**
  20076. * @hidden
  20077. */
  20078. export interface IMaterialClearCoatDefines {
  20079. CLEARCOAT: boolean;
  20080. CLEARCOAT_DEFAULTIOR: boolean;
  20081. CLEARCOAT_TEXTURE: boolean;
  20082. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20083. CLEARCOAT_TEXTUREDIRECTUV: number;
  20084. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20085. CLEARCOAT_BUMP: boolean;
  20086. CLEARCOAT_BUMPDIRECTUV: number;
  20087. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20088. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20089. CLEARCOAT_REMAP_F0: boolean;
  20090. CLEARCOAT_TINT: boolean;
  20091. CLEARCOAT_TINT_TEXTURE: boolean;
  20092. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20093. /** @hidden */
  20094. _areTexturesDirty: boolean;
  20095. }
  20096. /**
  20097. * Define the code related to the clear coat parameters of the pbr material.
  20098. */
  20099. export class PBRClearCoatConfiguration {
  20100. /**
  20101. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20102. * The default fits with a polyurethane material.
  20103. * @hidden
  20104. */
  20105. static readonly _DefaultIndexOfRefraction: number;
  20106. private _isEnabled;
  20107. /**
  20108. * Defines if the clear coat is enabled in the material.
  20109. */
  20110. isEnabled: boolean;
  20111. /**
  20112. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20113. */
  20114. intensity: number;
  20115. /**
  20116. * Defines the clear coat layer roughness.
  20117. */
  20118. roughness: number;
  20119. private _indexOfRefraction;
  20120. /**
  20121. * Defines the index of refraction of the clear coat.
  20122. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20123. * The default fits with a polyurethane material.
  20124. * Changing the default value is more performance intensive.
  20125. */
  20126. indexOfRefraction: number;
  20127. private _texture;
  20128. /**
  20129. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20130. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20131. * if textureRoughness is not empty, else no texture roughness is used
  20132. */
  20133. texture: Nullable<BaseTexture>;
  20134. private _useRoughnessFromMainTexture;
  20135. /**
  20136. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20137. * If false, the green channel from textureRoughness is used for roughness
  20138. */
  20139. useRoughnessFromMainTexture: boolean;
  20140. private _textureRoughness;
  20141. /**
  20142. * Stores the clear coat roughness in a texture (green channel)
  20143. * Not used if useRoughnessFromMainTexture is true
  20144. */
  20145. textureRoughness: Nullable<BaseTexture>;
  20146. private _remapF0OnInterfaceChange;
  20147. /**
  20148. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20149. */
  20150. remapF0OnInterfaceChange: boolean;
  20151. private _bumpTexture;
  20152. /**
  20153. * Define the clear coat specific bump texture.
  20154. */
  20155. bumpTexture: Nullable<BaseTexture>;
  20156. private _isTintEnabled;
  20157. /**
  20158. * Defines if the clear coat tint is enabled in the material.
  20159. */
  20160. isTintEnabled: boolean;
  20161. /**
  20162. * Defines the clear coat tint of the material.
  20163. * This is only use if tint is enabled
  20164. */
  20165. tintColor: Color3;
  20166. /**
  20167. * Defines the distance at which the tint color should be found in the
  20168. * clear coat media.
  20169. * This is only use if tint is enabled
  20170. */
  20171. tintColorAtDistance: number;
  20172. /**
  20173. * Defines the clear coat layer thickness.
  20174. * This is only use if tint is enabled
  20175. */
  20176. tintThickness: number;
  20177. private _tintTexture;
  20178. /**
  20179. * Stores the clear tint values in a texture.
  20180. * rgb is tint
  20181. * a is a thickness factor
  20182. */
  20183. tintTexture: Nullable<BaseTexture>;
  20184. /** @hidden */
  20185. private _internalMarkAllSubMeshesAsTexturesDirty;
  20186. /** @hidden */
  20187. _markAllSubMeshesAsTexturesDirty(): void;
  20188. /**
  20189. * Instantiate a new istance of clear coat configuration.
  20190. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20191. */
  20192. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20193. /**
  20194. * Gets wehter the submesh is ready to be used or not.
  20195. * @param defines the list of "defines" to update.
  20196. * @param scene defines the scene the material belongs to.
  20197. * @param engine defines the engine the material belongs to.
  20198. * @param disableBumpMap defines wether the material disables bump or not.
  20199. * @returns - boolean indicating that the submesh is ready or not.
  20200. */
  20201. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20202. /**
  20203. * Checks to see if a texture is used in the material.
  20204. * @param defines the list of "defines" to update.
  20205. * @param scene defines the scene to the material belongs to.
  20206. */
  20207. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20208. /**
  20209. * Binds the material data.
  20210. * @param uniformBuffer defines the Uniform buffer to fill in.
  20211. * @param scene defines the scene the material belongs to.
  20212. * @param engine defines the engine the material belongs to.
  20213. * @param disableBumpMap defines wether the material disables bump or not.
  20214. * @param isFrozen defines wether the material is frozen or not.
  20215. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20216. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20217. * @param subMesh the submesh to bind data for
  20218. */
  20219. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20220. /**
  20221. * Checks to see if a texture is used in the material.
  20222. * @param texture - Base texture to use.
  20223. * @returns - Boolean specifying if a texture is used in the material.
  20224. */
  20225. hasTexture(texture: BaseTexture): boolean;
  20226. /**
  20227. * Returns an array of the actively used textures.
  20228. * @param activeTextures Array of BaseTextures
  20229. */
  20230. getActiveTextures(activeTextures: BaseTexture[]): void;
  20231. /**
  20232. * Returns the animatable textures.
  20233. * @param animatables Array of animatable textures.
  20234. */
  20235. getAnimatables(animatables: IAnimatable[]): void;
  20236. /**
  20237. * Disposes the resources of the material.
  20238. * @param forceDisposeTextures - Forces the disposal of all textures.
  20239. */
  20240. dispose(forceDisposeTextures?: boolean): void;
  20241. /**
  20242. * Get the current class name of the texture useful for serialization or dynamic coding.
  20243. * @returns "PBRClearCoatConfiguration"
  20244. */
  20245. getClassName(): string;
  20246. /**
  20247. * Add fallbacks to the effect fallbacks list.
  20248. * @param defines defines the Base texture to use.
  20249. * @param fallbacks defines the current fallback list.
  20250. * @param currentRank defines the current fallback rank.
  20251. * @returns the new fallback rank.
  20252. */
  20253. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20254. /**
  20255. * Add the required uniforms to the current list.
  20256. * @param uniforms defines the current uniform list.
  20257. */
  20258. static AddUniforms(uniforms: string[]): void;
  20259. /**
  20260. * Add the required samplers to the current list.
  20261. * @param samplers defines the current sampler list.
  20262. */
  20263. static AddSamplers(samplers: string[]): void;
  20264. /**
  20265. * Add the required uniforms to the current buffer.
  20266. * @param uniformBuffer defines the current uniform buffer.
  20267. */
  20268. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20269. /**
  20270. * Makes a duplicate of the current configuration into another one.
  20271. * @param clearCoatConfiguration define the config where to copy the info
  20272. */
  20273. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20274. /**
  20275. * Serializes this clear coat configuration.
  20276. * @returns - An object with the serialized config.
  20277. */
  20278. serialize(): any;
  20279. /**
  20280. * Parses a anisotropy Configuration from a serialized object.
  20281. * @param source - Serialized object.
  20282. * @param scene Defines the scene we are parsing for
  20283. * @param rootUrl Defines the rootUrl to load from
  20284. */
  20285. parse(source: any, scene: Scene, rootUrl: string): void;
  20286. }
  20287. }
  20288. declare module BABYLON {
  20289. /**
  20290. * @hidden
  20291. */
  20292. export interface IMaterialAnisotropicDefines {
  20293. ANISOTROPIC: boolean;
  20294. ANISOTROPIC_TEXTURE: boolean;
  20295. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20296. MAINUV1: boolean;
  20297. _areTexturesDirty: boolean;
  20298. _needUVs: boolean;
  20299. }
  20300. /**
  20301. * Define the code related to the anisotropic parameters of the pbr material.
  20302. */
  20303. export class PBRAnisotropicConfiguration {
  20304. private _isEnabled;
  20305. /**
  20306. * Defines if the anisotropy is enabled in the material.
  20307. */
  20308. isEnabled: boolean;
  20309. /**
  20310. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20311. */
  20312. intensity: number;
  20313. /**
  20314. * Defines if the effect is along the tangents, bitangents or in between.
  20315. * By default, the effect is "strectching" the highlights along the tangents.
  20316. */
  20317. direction: Vector2;
  20318. private _texture;
  20319. /**
  20320. * Stores the anisotropy values in a texture.
  20321. * rg is direction (like normal from -1 to 1)
  20322. * b is a intensity
  20323. */
  20324. texture: Nullable<BaseTexture>;
  20325. /** @hidden */
  20326. private _internalMarkAllSubMeshesAsTexturesDirty;
  20327. /** @hidden */
  20328. _markAllSubMeshesAsTexturesDirty(): void;
  20329. /**
  20330. * Instantiate a new istance of anisotropy configuration.
  20331. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20332. */
  20333. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20334. /**
  20335. * Specifies that the submesh is ready to be used.
  20336. * @param defines the list of "defines" to update.
  20337. * @param scene defines the scene the material belongs to.
  20338. * @returns - boolean indicating that the submesh is ready or not.
  20339. */
  20340. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20341. /**
  20342. * Checks to see if a texture is used in the material.
  20343. * @param defines the list of "defines" to update.
  20344. * @param mesh the mesh we are preparing the defines for.
  20345. * @param scene defines the scene the material belongs to.
  20346. */
  20347. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20348. /**
  20349. * Binds the material data.
  20350. * @param uniformBuffer defines the Uniform buffer to fill in.
  20351. * @param scene defines the scene the material belongs to.
  20352. * @param isFrozen defines wether the material is frozen or not.
  20353. */
  20354. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20355. /**
  20356. * Checks to see if a texture is used in the material.
  20357. * @param texture - Base texture to use.
  20358. * @returns - Boolean specifying if a texture is used in the material.
  20359. */
  20360. hasTexture(texture: BaseTexture): boolean;
  20361. /**
  20362. * Returns an array of the actively used textures.
  20363. * @param activeTextures Array of BaseTextures
  20364. */
  20365. getActiveTextures(activeTextures: BaseTexture[]): void;
  20366. /**
  20367. * Returns the animatable textures.
  20368. * @param animatables Array of animatable textures.
  20369. */
  20370. getAnimatables(animatables: IAnimatable[]): void;
  20371. /**
  20372. * Disposes the resources of the material.
  20373. * @param forceDisposeTextures - Forces the disposal of all textures.
  20374. */
  20375. dispose(forceDisposeTextures?: boolean): void;
  20376. /**
  20377. * Get the current class name of the texture useful for serialization or dynamic coding.
  20378. * @returns "PBRAnisotropicConfiguration"
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Add fallbacks to the effect fallbacks list.
  20383. * @param defines defines the Base texture to use.
  20384. * @param fallbacks defines the current fallback list.
  20385. * @param currentRank defines the current fallback rank.
  20386. * @returns the new fallback rank.
  20387. */
  20388. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20389. /**
  20390. * Add the required uniforms to the current list.
  20391. * @param uniforms defines the current uniform list.
  20392. */
  20393. static AddUniforms(uniforms: string[]): void;
  20394. /**
  20395. * Add the required uniforms to the current buffer.
  20396. * @param uniformBuffer defines the current uniform buffer.
  20397. */
  20398. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20399. /**
  20400. * Add the required samplers to the current list.
  20401. * @param samplers defines the current sampler list.
  20402. */
  20403. static AddSamplers(samplers: string[]): void;
  20404. /**
  20405. * Makes a duplicate of the current configuration into another one.
  20406. * @param anisotropicConfiguration define the config where to copy the info
  20407. */
  20408. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20409. /**
  20410. * Serializes this anisotropy configuration.
  20411. * @returns - An object with the serialized config.
  20412. */
  20413. serialize(): any;
  20414. /**
  20415. * Parses a anisotropy Configuration from a serialized object.
  20416. * @param source - Serialized object.
  20417. * @param scene Defines the scene we are parsing for
  20418. * @param rootUrl Defines the rootUrl to load from
  20419. */
  20420. parse(source: any, scene: Scene, rootUrl: string): void;
  20421. }
  20422. }
  20423. declare module BABYLON {
  20424. /**
  20425. * @hidden
  20426. */
  20427. export interface IMaterialBRDFDefines {
  20428. BRDF_V_HEIGHT_CORRELATED: boolean;
  20429. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20430. SPHERICAL_HARMONICS: boolean;
  20431. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20432. /** @hidden */
  20433. _areMiscDirty: boolean;
  20434. }
  20435. /**
  20436. * Define the code related to the BRDF parameters of the pbr material.
  20437. */
  20438. export class PBRBRDFConfiguration {
  20439. /**
  20440. * Default value used for the energy conservation.
  20441. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20442. */
  20443. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20444. /**
  20445. * Default value used for the Smith Visibility Height Correlated mode.
  20446. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20447. */
  20448. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20449. /**
  20450. * Default value used for the IBL diffuse part.
  20451. * This can help switching back to the polynomials mode globally which is a tiny bit
  20452. * less GPU intensive at the drawback of a lower quality.
  20453. */
  20454. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20455. /**
  20456. * Default value used for activating energy conservation for the specular workflow.
  20457. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20458. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20459. */
  20460. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20461. private _useEnergyConservation;
  20462. /**
  20463. * Defines if the material uses energy conservation.
  20464. */
  20465. useEnergyConservation: boolean;
  20466. private _useSmithVisibilityHeightCorrelated;
  20467. /**
  20468. * LEGACY Mode set to false
  20469. * Defines if the material uses height smith correlated visibility term.
  20470. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20471. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20472. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20473. * Not relying on height correlated will also disable energy conservation.
  20474. */
  20475. useSmithVisibilityHeightCorrelated: boolean;
  20476. private _useSphericalHarmonics;
  20477. /**
  20478. * LEGACY Mode set to false
  20479. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20480. * diffuse part of the IBL.
  20481. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20482. * to the ground truth.
  20483. */
  20484. useSphericalHarmonics: boolean;
  20485. private _useSpecularGlossinessInputEnergyConservation;
  20486. /**
  20487. * Defines if the material uses energy conservation, when the specular workflow is active.
  20488. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20489. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20490. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20491. */
  20492. useSpecularGlossinessInputEnergyConservation: boolean;
  20493. /** @hidden */
  20494. private _internalMarkAllSubMeshesAsMiscDirty;
  20495. /** @hidden */
  20496. _markAllSubMeshesAsMiscDirty(): void;
  20497. /**
  20498. * Instantiate a new istance of clear coat configuration.
  20499. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20500. */
  20501. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20502. /**
  20503. * Checks to see if a texture is used in the material.
  20504. * @param defines the list of "defines" to update.
  20505. */
  20506. prepareDefines(defines: IMaterialBRDFDefines): void;
  20507. /**
  20508. * Get the current class name of the texture useful for serialization or dynamic coding.
  20509. * @returns "PBRClearCoatConfiguration"
  20510. */
  20511. getClassName(): string;
  20512. /**
  20513. * Makes a duplicate of the current configuration into another one.
  20514. * @param brdfConfiguration define the config where to copy the info
  20515. */
  20516. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20517. /**
  20518. * Serializes this BRDF configuration.
  20519. * @returns - An object with the serialized config.
  20520. */
  20521. serialize(): any;
  20522. /**
  20523. * Parses a anisotropy Configuration from a serialized object.
  20524. * @param source - Serialized object.
  20525. * @param scene Defines the scene we are parsing for
  20526. * @param rootUrl Defines the rootUrl to load from
  20527. */
  20528. parse(source: any, scene: Scene, rootUrl: string): void;
  20529. }
  20530. }
  20531. declare module BABYLON {
  20532. /**
  20533. * @hidden
  20534. */
  20535. export interface IMaterialSheenDefines {
  20536. SHEEN: boolean;
  20537. SHEEN_TEXTURE: boolean;
  20538. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20539. SHEEN_TEXTUREDIRECTUV: number;
  20540. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20541. SHEEN_LINKWITHALBEDO: boolean;
  20542. SHEEN_ROUGHNESS: boolean;
  20543. SHEEN_ALBEDOSCALING: boolean;
  20544. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20545. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20546. /** @hidden */
  20547. _areTexturesDirty: boolean;
  20548. }
  20549. /**
  20550. * Define the code related to the Sheen parameters of the pbr material.
  20551. */
  20552. export class PBRSheenConfiguration {
  20553. private _isEnabled;
  20554. /**
  20555. * Defines if the material uses sheen.
  20556. */
  20557. isEnabled: boolean;
  20558. private _linkSheenWithAlbedo;
  20559. /**
  20560. * Defines if the sheen is linked to the sheen color.
  20561. */
  20562. linkSheenWithAlbedo: boolean;
  20563. /**
  20564. * Defines the sheen intensity.
  20565. */
  20566. intensity: number;
  20567. /**
  20568. * Defines the sheen color.
  20569. */
  20570. color: Color3;
  20571. private _texture;
  20572. /**
  20573. * Stores the sheen tint values in a texture.
  20574. * rgb is tint
  20575. * 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)
  20576. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20577. */
  20578. texture: Nullable<BaseTexture>;
  20579. private _useRoughnessFromMainTexture;
  20580. /**
  20581. * Indicates that the alpha channel of the texture property will be used for roughness.
  20582. * Has no effect if the roughness (and texture!) property is not defined
  20583. */
  20584. useRoughnessFromMainTexture: boolean;
  20585. private _roughness;
  20586. /**
  20587. * Defines the sheen roughness.
  20588. * It is not taken into account if linkSheenWithAlbedo is true.
  20589. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20590. */
  20591. roughness: Nullable<number>;
  20592. private _textureRoughness;
  20593. /**
  20594. * Stores the sheen roughness in a texture.
  20595. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20596. */
  20597. textureRoughness: Nullable<BaseTexture>;
  20598. private _albedoScaling;
  20599. /**
  20600. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20601. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20602. * making it easier to setup and tweak the effect
  20603. */
  20604. albedoScaling: boolean;
  20605. /** @hidden */
  20606. private _internalMarkAllSubMeshesAsTexturesDirty;
  20607. /** @hidden */
  20608. _markAllSubMeshesAsTexturesDirty(): void;
  20609. /**
  20610. * Instantiate a new istance of clear coat configuration.
  20611. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20612. */
  20613. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20614. /**
  20615. * Specifies that the submesh is ready to be used.
  20616. * @param defines the list of "defines" to update.
  20617. * @param scene defines the scene the material belongs to.
  20618. * @returns - boolean indicating that the submesh is ready or not.
  20619. */
  20620. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20621. /**
  20622. * Checks to see if a texture is used in the material.
  20623. * @param defines the list of "defines" to update.
  20624. * @param scene defines the scene the material belongs to.
  20625. */
  20626. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20627. /**
  20628. * Binds the material data.
  20629. * @param uniformBuffer defines the Uniform buffer to fill in.
  20630. * @param scene defines the scene the material belongs to.
  20631. * @param isFrozen defines wether the material is frozen or not.
  20632. * @param subMesh the submesh to bind data for
  20633. */
  20634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20635. /**
  20636. * Checks to see if a texture is used in the material.
  20637. * @param texture - Base texture to use.
  20638. * @returns - Boolean specifying if a texture is used in the material.
  20639. */
  20640. hasTexture(texture: BaseTexture): boolean;
  20641. /**
  20642. * Returns an array of the actively used textures.
  20643. * @param activeTextures Array of BaseTextures
  20644. */
  20645. getActiveTextures(activeTextures: BaseTexture[]): void;
  20646. /**
  20647. * Returns the animatable textures.
  20648. * @param animatables Array of animatable textures.
  20649. */
  20650. getAnimatables(animatables: IAnimatable[]): void;
  20651. /**
  20652. * Disposes the resources of the material.
  20653. * @param forceDisposeTextures - Forces the disposal of all textures.
  20654. */
  20655. dispose(forceDisposeTextures?: boolean): void;
  20656. /**
  20657. * Get the current class name of the texture useful for serialization or dynamic coding.
  20658. * @returns "PBRSheenConfiguration"
  20659. */
  20660. getClassName(): string;
  20661. /**
  20662. * Add fallbacks to the effect fallbacks list.
  20663. * @param defines defines the Base texture to use.
  20664. * @param fallbacks defines the current fallback list.
  20665. * @param currentRank defines the current fallback rank.
  20666. * @returns the new fallback rank.
  20667. */
  20668. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20669. /**
  20670. * Add the required uniforms to the current list.
  20671. * @param uniforms defines the current uniform list.
  20672. */
  20673. static AddUniforms(uniforms: string[]): void;
  20674. /**
  20675. * Add the required uniforms to the current buffer.
  20676. * @param uniformBuffer defines the current uniform buffer.
  20677. */
  20678. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20679. /**
  20680. * Add the required samplers to the current list.
  20681. * @param samplers defines the current sampler list.
  20682. */
  20683. static AddSamplers(samplers: string[]): void;
  20684. /**
  20685. * Makes a duplicate of the current configuration into another one.
  20686. * @param sheenConfiguration define the config where to copy the info
  20687. */
  20688. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20689. /**
  20690. * Serializes this BRDF configuration.
  20691. * @returns - An object with the serialized config.
  20692. */
  20693. serialize(): any;
  20694. /**
  20695. * Parses a anisotropy Configuration from a serialized object.
  20696. * @param source - Serialized object.
  20697. * @param scene Defines the scene we are parsing for
  20698. * @param rootUrl Defines the rootUrl to load from
  20699. */
  20700. parse(source: any, scene: Scene, rootUrl: string): void;
  20701. }
  20702. }
  20703. declare module BABYLON {
  20704. /**
  20705. * @hidden
  20706. */
  20707. export interface IMaterialSubSurfaceDefines {
  20708. SUBSURFACE: boolean;
  20709. SS_REFRACTION: boolean;
  20710. SS_TRANSLUCENCY: boolean;
  20711. SS_SCATTERING: boolean;
  20712. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20713. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20714. SS_REFRACTIONMAP_3D: boolean;
  20715. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20716. SS_LODINREFRACTIONALPHA: boolean;
  20717. SS_GAMMAREFRACTION: boolean;
  20718. SS_RGBDREFRACTION: boolean;
  20719. SS_LINEARSPECULARREFRACTION: boolean;
  20720. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20721. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20722. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20723. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20724. /** @hidden */
  20725. _areTexturesDirty: boolean;
  20726. }
  20727. /**
  20728. * Define the code related to the sub surface parameters of the pbr material.
  20729. */
  20730. export class PBRSubSurfaceConfiguration {
  20731. private _isRefractionEnabled;
  20732. /**
  20733. * Defines if the refraction is enabled in the material.
  20734. */
  20735. isRefractionEnabled: boolean;
  20736. private _isTranslucencyEnabled;
  20737. /**
  20738. * Defines if the translucency is enabled in the material.
  20739. */
  20740. isTranslucencyEnabled: boolean;
  20741. private _isScatteringEnabled;
  20742. /**
  20743. * Defines if the sub surface scattering is enabled in the material.
  20744. */
  20745. isScatteringEnabled: boolean;
  20746. private _scatteringDiffusionProfileIndex;
  20747. /**
  20748. * Diffusion profile for subsurface scattering.
  20749. * Useful for better scattering in the skins or foliages.
  20750. */
  20751. get scatteringDiffusionProfile(): Nullable<Color3>;
  20752. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20753. /**
  20754. * Defines the refraction intensity of the material.
  20755. * The refraction when enabled replaces the Diffuse part of the material.
  20756. * The intensity helps transitionning between diffuse and refraction.
  20757. */
  20758. refractionIntensity: number;
  20759. /**
  20760. * Defines the translucency intensity of the material.
  20761. * When translucency has been enabled, this defines how much of the "translucency"
  20762. * is addded to the diffuse part of the material.
  20763. */
  20764. translucencyIntensity: number;
  20765. /**
  20766. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20767. */
  20768. useAlbedoToTintRefraction: boolean;
  20769. private _thicknessTexture;
  20770. /**
  20771. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20772. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20773. * 0 would mean minimumThickness
  20774. * 1 would mean maximumThickness
  20775. * The other channels might be use as a mask to vary the different effects intensity.
  20776. */
  20777. thicknessTexture: Nullable<BaseTexture>;
  20778. private _refractionTexture;
  20779. /**
  20780. * Defines the texture to use for refraction.
  20781. */
  20782. refractionTexture: Nullable<BaseTexture>;
  20783. private _indexOfRefraction;
  20784. /**
  20785. * Index of refraction of the material base layer.
  20786. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20787. *
  20788. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20789. *
  20790. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20791. */
  20792. indexOfRefraction: number;
  20793. private _volumeIndexOfRefraction;
  20794. /**
  20795. * Index of refraction of the material's volume.
  20796. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20797. *
  20798. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20799. * the volume will use the same IOR as the surface.
  20800. */
  20801. get volumeIndexOfRefraction(): number;
  20802. set volumeIndexOfRefraction(value: number);
  20803. private _invertRefractionY;
  20804. /**
  20805. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20806. */
  20807. invertRefractionY: boolean;
  20808. private _linkRefractionWithTransparency;
  20809. /**
  20810. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20811. * Materials half opaque for instance using refraction could benefit from this control.
  20812. */
  20813. linkRefractionWithTransparency: boolean;
  20814. /**
  20815. * Defines the minimum thickness stored in the thickness map.
  20816. * If no thickness map is defined, this value will be used to simulate thickness.
  20817. */
  20818. minimumThickness: number;
  20819. /**
  20820. * Defines the maximum thickness stored in the thickness map.
  20821. */
  20822. maximumThickness: number;
  20823. /**
  20824. * Defines the volume tint of the material.
  20825. * This is used for both translucency and scattering.
  20826. */
  20827. tintColor: Color3;
  20828. /**
  20829. * Defines the distance at which the tint color should be found in the media.
  20830. * This is used for refraction only.
  20831. */
  20832. tintColorAtDistance: number;
  20833. /**
  20834. * Defines how far each channel transmit through the media.
  20835. * It is defined as a color to simplify it selection.
  20836. */
  20837. diffusionDistance: Color3;
  20838. private _useMaskFromThicknessTexture;
  20839. /**
  20840. * Stores the intensity of the different subsurface effects in the thickness texture.
  20841. * * the green channel is the translucency intensity.
  20842. * * the blue channel is the scattering intensity.
  20843. * * the alpha channel is the refraction intensity.
  20844. */
  20845. useMaskFromThicknessTexture: boolean;
  20846. private _scene;
  20847. private _useMaskFromThicknessTextureGltf;
  20848. /**
  20849. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20850. * matches the channel-packing that is used by glTF.
  20851. * * the red channel is the transmission/translucency intensity.
  20852. * * the green channel is the thickness.
  20853. */
  20854. useMaskFromThicknessTextureGltf: boolean;
  20855. /** @hidden */
  20856. private _internalMarkAllSubMeshesAsTexturesDirty;
  20857. private _internalMarkScenePrePassDirty;
  20858. /** @hidden */
  20859. _markAllSubMeshesAsTexturesDirty(): void;
  20860. /** @hidden */
  20861. _markScenePrePassDirty(): void;
  20862. /**
  20863. * Instantiate a new istance of sub surface configuration.
  20864. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20865. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20866. * @param scene The scene
  20867. */
  20868. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20869. /**
  20870. * Gets wehter the submesh is ready to be used or not.
  20871. * @param defines the list of "defines" to update.
  20872. * @param scene defines the scene the material belongs to.
  20873. * @returns - boolean indicating that the submesh is ready or not.
  20874. */
  20875. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20876. /**
  20877. * Checks to see if a texture is used in the material.
  20878. * @param defines the list of "defines" to update.
  20879. * @param scene defines the scene to the material belongs to.
  20880. */
  20881. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20882. /**
  20883. * Binds the material data.
  20884. * @param uniformBuffer defines the Uniform buffer to fill in.
  20885. * @param scene defines the scene the material belongs to.
  20886. * @param engine defines the engine the material belongs to.
  20887. * @param isFrozen defines whether the material is frozen or not.
  20888. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20889. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20890. */
  20891. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20892. /**
  20893. * Unbinds the material from the mesh.
  20894. * @param activeEffect defines the effect that should be unbound from.
  20895. * @returns true if unbound, otherwise false
  20896. */
  20897. unbind(activeEffect: Effect): boolean;
  20898. /**
  20899. * Returns the texture used for refraction or null if none is used.
  20900. * @param scene defines the scene the material belongs to.
  20901. * @returns - Refraction texture if present. If no refraction texture and refraction
  20902. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20903. */
  20904. private _getRefractionTexture;
  20905. /**
  20906. * Returns true if alpha blending should be disabled.
  20907. */
  20908. get disableAlphaBlending(): boolean;
  20909. /**
  20910. * Fills the list of render target textures.
  20911. * @param renderTargets the list of render targets to update
  20912. */
  20913. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20914. /**
  20915. * Checks to see if a texture is used in the material.
  20916. * @param texture - Base texture to use.
  20917. * @returns - Boolean specifying if a texture is used in the material.
  20918. */
  20919. hasTexture(texture: BaseTexture): boolean;
  20920. /**
  20921. * Gets a boolean indicating that current material needs to register RTT
  20922. * @returns true if this uses a render target otherwise false.
  20923. */
  20924. hasRenderTargetTextures(): boolean;
  20925. /**
  20926. * Returns an array of the actively used textures.
  20927. * @param activeTextures Array of BaseTextures
  20928. */
  20929. getActiveTextures(activeTextures: BaseTexture[]): void;
  20930. /**
  20931. * Returns the animatable textures.
  20932. * @param animatables Array of animatable textures.
  20933. */
  20934. getAnimatables(animatables: IAnimatable[]): void;
  20935. /**
  20936. * Disposes the resources of the material.
  20937. * @param forceDisposeTextures - Forces the disposal of all textures.
  20938. */
  20939. dispose(forceDisposeTextures?: boolean): void;
  20940. /**
  20941. * Get the current class name of the texture useful for serialization or dynamic coding.
  20942. * @returns "PBRSubSurfaceConfiguration"
  20943. */
  20944. getClassName(): string;
  20945. /**
  20946. * Add fallbacks to the effect fallbacks list.
  20947. * @param defines defines the Base texture to use.
  20948. * @param fallbacks defines the current fallback list.
  20949. * @param currentRank defines the current fallback rank.
  20950. * @returns the new fallback rank.
  20951. */
  20952. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20953. /**
  20954. * Add the required uniforms to the current list.
  20955. * @param uniforms defines the current uniform list.
  20956. */
  20957. static AddUniforms(uniforms: string[]): void;
  20958. /**
  20959. * Add the required samplers to the current list.
  20960. * @param samplers defines the current sampler list.
  20961. */
  20962. static AddSamplers(samplers: string[]): void;
  20963. /**
  20964. * Add the required uniforms to the current buffer.
  20965. * @param uniformBuffer defines the current uniform buffer.
  20966. */
  20967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20968. /**
  20969. * Makes a duplicate of the current configuration into another one.
  20970. * @param configuration define the config where to copy the info
  20971. */
  20972. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20973. /**
  20974. * Serializes this Sub Surface configuration.
  20975. * @returns - An object with the serialized config.
  20976. */
  20977. serialize(): any;
  20978. /**
  20979. * Parses a anisotropy Configuration from a serialized object.
  20980. * @param source - Serialized object.
  20981. * @param scene Defines the scene we are parsing for
  20982. * @param rootUrl Defines the rootUrl to load from
  20983. */
  20984. parse(source: any, scene: Scene, rootUrl: string): void;
  20985. }
  20986. }
  20987. declare module BABYLON {
  20988. /**
  20989. * Class representing spherical harmonics coefficients to the 3rd degree
  20990. */
  20991. export class SphericalHarmonics {
  20992. /**
  20993. * Defines whether or not the harmonics have been prescaled for rendering.
  20994. */
  20995. preScaled: boolean;
  20996. /**
  20997. * The l0,0 coefficients of the spherical harmonics
  20998. */
  20999. l00: Vector3;
  21000. /**
  21001. * The l1,-1 coefficients of the spherical harmonics
  21002. */
  21003. l1_1: Vector3;
  21004. /**
  21005. * The l1,0 coefficients of the spherical harmonics
  21006. */
  21007. l10: Vector3;
  21008. /**
  21009. * The l1,1 coefficients of the spherical harmonics
  21010. */
  21011. l11: Vector3;
  21012. /**
  21013. * The l2,-2 coefficients of the spherical harmonics
  21014. */
  21015. l2_2: Vector3;
  21016. /**
  21017. * The l2,-1 coefficients of the spherical harmonics
  21018. */
  21019. l2_1: Vector3;
  21020. /**
  21021. * The l2,0 coefficients of the spherical harmonics
  21022. */
  21023. l20: Vector3;
  21024. /**
  21025. * The l2,1 coefficients of the spherical harmonics
  21026. */
  21027. l21: Vector3;
  21028. /**
  21029. * The l2,2 coefficients of the spherical harmonics
  21030. */
  21031. l22: Vector3;
  21032. /**
  21033. * Adds a light to the spherical harmonics
  21034. * @param direction the direction of the light
  21035. * @param color the color of the light
  21036. * @param deltaSolidAngle the delta solid angle of the light
  21037. */
  21038. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21039. /**
  21040. * Scales the spherical harmonics by the given amount
  21041. * @param scale the amount to scale
  21042. */
  21043. scaleInPlace(scale: number): void;
  21044. /**
  21045. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21046. *
  21047. * ```
  21048. * E_lm = A_l * L_lm
  21049. * ```
  21050. *
  21051. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21052. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21053. * the scaling factors are given in equation 9.
  21054. */
  21055. convertIncidentRadianceToIrradiance(): void;
  21056. /**
  21057. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21058. *
  21059. * ```
  21060. * L = (1/pi) * E * rho
  21061. * ```
  21062. *
  21063. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21064. */
  21065. convertIrradianceToLambertianRadiance(): void;
  21066. /**
  21067. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21068. * required operations at run time.
  21069. *
  21070. * This is simply done by scaling back the SH with Ylm constants parameter.
  21071. * The trigonometric part being applied by the shader at run time.
  21072. */
  21073. preScaleForRendering(): void;
  21074. /**
  21075. * Constructs a spherical harmonics from an array.
  21076. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21077. * @returns the spherical harmonics
  21078. */
  21079. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21080. /**
  21081. * Gets the spherical harmonics from polynomial
  21082. * @param polynomial the spherical polynomial
  21083. * @returns the spherical harmonics
  21084. */
  21085. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21086. }
  21087. /**
  21088. * Class representing spherical polynomial coefficients to the 3rd degree
  21089. */
  21090. export class SphericalPolynomial {
  21091. private _harmonics;
  21092. /**
  21093. * The spherical harmonics used to create the polynomials.
  21094. */
  21095. get preScaledHarmonics(): SphericalHarmonics;
  21096. /**
  21097. * The x coefficients of the spherical polynomial
  21098. */
  21099. x: Vector3;
  21100. /**
  21101. * The y coefficients of the spherical polynomial
  21102. */
  21103. y: Vector3;
  21104. /**
  21105. * The z coefficients of the spherical polynomial
  21106. */
  21107. z: Vector3;
  21108. /**
  21109. * The xx coefficients of the spherical polynomial
  21110. */
  21111. xx: Vector3;
  21112. /**
  21113. * The yy coefficients of the spherical polynomial
  21114. */
  21115. yy: Vector3;
  21116. /**
  21117. * The zz coefficients of the spherical polynomial
  21118. */
  21119. zz: Vector3;
  21120. /**
  21121. * The xy coefficients of the spherical polynomial
  21122. */
  21123. xy: Vector3;
  21124. /**
  21125. * The yz coefficients of the spherical polynomial
  21126. */
  21127. yz: Vector3;
  21128. /**
  21129. * The zx coefficients of the spherical polynomial
  21130. */
  21131. zx: Vector3;
  21132. /**
  21133. * Adds an ambient color to the spherical polynomial
  21134. * @param color the color to add
  21135. */
  21136. addAmbient(color: Color3): void;
  21137. /**
  21138. * Scales the spherical polynomial by the given amount
  21139. * @param scale the amount to scale
  21140. */
  21141. scaleInPlace(scale: number): void;
  21142. /**
  21143. * Gets the spherical polynomial from harmonics
  21144. * @param harmonics the spherical harmonics
  21145. * @returns the spherical polynomial
  21146. */
  21147. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21148. /**
  21149. * Constructs a spherical polynomial from an array.
  21150. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21151. * @returns the spherical polynomial
  21152. */
  21153. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21154. }
  21155. }
  21156. declare module BABYLON {
  21157. /**
  21158. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21159. */
  21160. export interface CubeMapInfo {
  21161. /**
  21162. * The pixel array for the front face.
  21163. * This is stored in format, left to right, up to down format.
  21164. */
  21165. front: Nullable<ArrayBufferView>;
  21166. /**
  21167. * The pixel array for the back face.
  21168. * This is stored in format, left to right, up to down format.
  21169. */
  21170. back: Nullable<ArrayBufferView>;
  21171. /**
  21172. * The pixel array for the left face.
  21173. * This is stored in format, left to right, up to down format.
  21174. */
  21175. left: Nullable<ArrayBufferView>;
  21176. /**
  21177. * The pixel array for the right face.
  21178. * This is stored in format, left to right, up to down format.
  21179. */
  21180. right: Nullable<ArrayBufferView>;
  21181. /**
  21182. * The pixel array for the up face.
  21183. * This is stored in format, left to right, up to down format.
  21184. */
  21185. up: Nullable<ArrayBufferView>;
  21186. /**
  21187. * The pixel array for the down face.
  21188. * This is stored in format, left to right, up to down format.
  21189. */
  21190. down: Nullable<ArrayBufferView>;
  21191. /**
  21192. * The size of the cubemap stored.
  21193. *
  21194. * Each faces will be size * size pixels.
  21195. */
  21196. size: number;
  21197. /**
  21198. * The format of the texture.
  21199. *
  21200. * RGBA, RGB.
  21201. */
  21202. format: number;
  21203. /**
  21204. * The type of the texture data.
  21205. *
  21206. * UNSIGNED_INT, FLOAT.
  21207. */
  21208. type: number;
  21209. /**
  21210. * Specifies whether the texture is in gamma space.
  21211. */
  21212. gammaSpace: boolean;
  21213. }
  21214. /**
  21215. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21216. */
  21217. export class PanoramaToCubeMapTools {
  21218. private static FACE_LEFT;
  21219. private static FACE_RIGHT;
  21220. private static FACE_FRONT;
  21221. private static FACE_BACK;
  21222. private static FACE_DOWN;
  21223. private static FACE_UP;
  21224. /**
  21225. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21226. *
  21227. * @param float32Array The source data.
  21228. * @param inputWidth The width of the input panorama.
  21229. * @param inputHeight The height of the input panorama.
  21230. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21231. * @return The cubemap data
  21232. */
  21233. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21234. private static CreateCubemapTexture;
  21235. private static CalcProjectionSpherical;
  21236. }
  21237. }
  21238. declare module BABYLON {
  21239. /**
  21240. * Helper class dealing with the extraction of spherical polynomial dataArray
  21241. * from a cube map.
  21242. */
  21243. export class CubeMapToSphericalPolynomialTools {
  21244. private static FileFaces;
  21245. /**
  21246. * Converts a texture to the according Spherical Polynomial data.
  21247. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21248. *
  21249. * @param texture The texture to extract the information from.
  21250. * @return The Spherical Polynomial data.
  21251. */
  21252. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21253. /**
  21254. * Converts a cubemap to the according Spherical Polynomial data.
  21255. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21256. *
  21257. * @param cubeInfo The Cube map to extract the information from.
  21258. * @return The Spherical Polynomial data.
  21259. */
  21260. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21261. }
  21262. }
  21263. declare module BABYLON {
  21264. interface BaseTexture {
  21265. /**
  21266. * Get the polynomial representation of the texture data.
  21267. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21268. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21269. */
  21270. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21271. }
  21272. }
  21273. declare module BABYLON {
  21274. /** @hidden */
  21275. export var pbrFragmentDeclaration: {
  21276. name: string;
  21277. shader: string;
  21278. };
  21279. }
  21280. declare module BABYLON {
  21281. /** @hidden */
  21282. export var pbrUboDeclaration: {
  21283. name: string;
  21284. shader: string;
  21285. };
  21286. }
  21287. declare module BABYLON {
  21288. /** @hidden */
  21289. export var pbrFragmentExtraDeclaration: {
  21290. name: string;
  21291. shader: string;
  21292. };
  21293. }
  21294. declare module BABYLON {
  21295. /** @hidden */
  21296. export var pbrFragmentSamplersDeclaration: {
  21297. name: string;
  21298. shader: string;
  21299. };
  21300. }
  21301. declare module BABYLON {
  21302. /** @hidden */
  21303. export var subSurfaceScatteringFunctions: {
  21304. name: string;
  21305. shader: string;
  21306. };
  21307. }
  21308. declare module BABYLON {
  21309. /** @hidden */
  21310. export var importanceSampling: {
  21311. name: string;
  21312. shader: string;
  21313. };
  21314. }
  21315. declare module BABYLON {
  21316. /** @hidden */
  21317. export var pbrHelperFunctions: {
  21318. name: string;
  21319. shader: string;
  21320. };
  21321. }
  21322. declare module BABYLON {
  21323. /** @hidden */
  21324. export var harmonicsFunctions: {
  21325. name: string;
  21326. shader: string;
  21327. };
  21328. }
  21329. declare module BABYLON {
  21330. /** @hidden */
  21331. export var pbrDirectLightingSetupFunctions: {
  21332. name: string;
  21333. shader: string;
  21334. };
  21335. }
  21336. declare module BABYLON {
  21337. /** @hidden */
  21338. export var pbrDirectLightingFalloffFunctions: {
  21339. name: string;
  21340. shader: string;
  21341. };
  21342. }
  21343. declare module BABYLON {
  21344. /** @hidden */
  21345. export var pbrBRDFFunctions: {
  21346. name: string;
  21347. shader: string;
  21348. };
  21349. }
  21350. declare module BABYLON {
  21351. /** @hidden */
  21352. export var hdrFilteringFunctions: {
  21353. name: string;
  21354. shader: string;
  21355. };
  21356. }
  21357. declare module BABYLON {
  21358. /** @hidden */
  21359. export var pbrDirectLightingFunctions: {
  21360. name: string;
  21361. shader: string;
  21362. };
  21363. }
  21364. declare module BABYLON {
  21365. /** @hidden */
  21366. export var pbrIBLFunctions: {
  21367. name: string;
  21368. shader: string;
  21369. };
  21370. }
  21371. declare module BABYLON {
  21372. /** @hidden */
  21373. export var pbrBlockAlbedoOpacity: {
  21374. name: string;
  21375. shader: string;
  21376. };
  21377. }
  21378. declare module BABYLON {
  21379. /** @hidden */
  21380. export var pbrBlockReflectivity: {
  21381. name: string;
  21382. shader: string;
  21383. };
  21384. }
  21385. declare module BABYLON {
  21386. /** @hidden */
  21387. export var pbrBlockAmbientOcclusion: {
  21388. name: string;
  21389. shader: string;
  21390. };
  21391. }
  21392. declare module BABYLON {
  21393. /** @hidden */
  21394. export var pbrBlockAlphaFresnel: {
  21395. name: string;
  21396. shader: string;
  21397. };
  21398. }
  21399. declare module BABYLON {
  21400. /** @hidden */
  21401. export var pbrBlockAnisotropic: {
  21402. name: string;
  21403. shader: string;
  21404. };
  21405. }
  21406. declare module BABYLON {
  21407. /** @hidden */
  21408. export var pbrBlockReflection: {
  21409. name: string;
  21410. shader: string;
  21411. };
  21412. }
  21413. declare module BABYLON {
  21414. /** @hidden */
  21415. export var pbrBlockSheen: {
  21416. name: string;
  21417. shader: string;
  21418. };
  21419. }
  21420. declare module BABYLON {
  21421. /** @hidden */
  21422. export var pbrBlockClearcoat: {
  21423. name: string;
  21424. shader: string;
  21425. };
  21426. }
  21427. declare module BABYLON {
  21428. /** @hidden */
  21429. export var pbrBlockSubSurface: {
  21430. name: string;
  21431. shader: string;
  21432. };
  21433. }
  21434. declare module BABYLON {
  21435. /** @hidden */
  21436. export var pbrBlockNormalGeometric: {
  21437. name: string;
  21438. shader: string;
  21439. };
  21440. }
  21441. declare module BABYLON {
  21442. /** @hidden */
  21443. export var pbrBlockNormalFinal: {
  21444. name: string;
  21445. shader: string;
  21446. };
  21447. }
  21448. declare module BABYLON {
  21449. /** @hidden */
  21450. export var pbrBlockLightmapInit: {
  21451. name: string;
  21452. shader: string;
  21453. };
  21454. }
  21455. declare module BABYLON {
  21456. /** @hidden */
  21457. export var pbrBlockGeometryInfo: {
  21458. name: string;
  21459. shader: string;
  21460. };
  21461. }
  21462. declare module BABYLON {
  21463. /** @hidden */
  21464. export var pbrBlockReflectance0: {
  21465. name: string;
  21466. shader: string;
  21467. };
  21468. }
  21469. declare module BABYLON {
  21470. /** @hidden */
  21471. export var pbrBlockReflectance: {
  21472. name: string;
  21473. shader: string;
  21474. };
  21475. }
  21476. declare module BABYLON {
  21477. /** @hidden */
  21478. export var pbrBlockDirectLighting: {
  21479. name: string;
  21480. shader: string;
  21481. };
  21482. }
  21483. declare module BABYLON {
  21484. /** @hidden */
  21485. export var pbrBlockFinalLitComponents: {
  21486. name: string;
  21487. shader: string;
  21488. };
  21489. }
  21490. declare module BABYLON {
  21491. /** @hidden */
  21492. export var pbrBlockFinalUnlitComponents: {
  21493. name: string;
  21494. shader: string;
  21495. };
  21496. }
  21497. declare module BABYLON {
  21498. /** @hidden */
  21499. export var pbrBlockFinalColorComposition: {
  21500. name: string;
  21501. shader: string;
  21502. };
  21503. }
  21504. declare module BABYLON {
  21505. /** @hidden */
  21506. export var pbrBlockImageProcessing: {
  21507. name: string;
  21508. shader: string;
  21509. };
  21510. }
  21511. declare module BABYLON {
  21512. /** @hidden */
  21513. export var pbrDebug: {
  21514. name: string;
  21515. shader: string;
  21516. };
  21517. }
  21518. declare module BABYLON {
  21519. /** @hidden */
  21520. export var pbrPixelShader: {
  21521. name: string;
  21522. shader: string;
  21523. };
  21524. }
  21525. declare module BABYLON {
  21526. /** @hidden */
  21527. export var pbrVertexDeclaration: {
  21528. name: string;
  21529. shader: string;
  21530. };
  21531. }
  21532. declare module BABYLON {
  21533. /** @hidden */
  21534. export var pbrVertexShader: {
  21535. name: string;
  21536. shader: string;
  21537. };
  21538. }
  21539. declare module BABYLON {
  21540. /**
  21541. * Manages the defines for the PBR Material.
  21542. * @hidden
  21543. */
  21544. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21545. PBR: boolean;
  21546. NUM_SAMPLES: string;
  21547. REALTIME_FILTERING: boolean;
  21548. MAINUV1: boolean;
  21549. MAINUV2: boolean;
  21550. UV1: boolean;
  21551. UV2: boolean;
  21552. ALBEDO: boolean;
  21553. GAMMAALBEDO: boolean;
  21554. ALBEDODIRECTUV: number;
  21555. VERTEXCOLOR: boolean;
  21556. DETAIL: boolean;
  21557. DETAILDIRECTUV: number;
  21558. DETAIL_NORMALBLENDMETHOD: number;
  21559. AMBIENT: boolean;
  21560. AMBIENTDIRECTUV: number;
  21561. AMBIENTINGRAYSCALE: boolean;
  21562. OPACITY: boolean;
  21563. VERTEXALPHA: boolean;
  21564. OPACITYDIRECTUV: number;
  21565. OPACITYRGB: boolean;
  21566. ALPHATEST: boolean;
  21567. DEPTHPREPASS: boolean;
  21568. ALPHABLEND: boolean;
  21569. ALPHAFROMALBEDO: boolean;
  21570. ALPHATESTVALUE: string;
  21571. SPECULAROVERALPHA: boolean;
  21572. RADIANCEOVERALPHA: boolean;
  21573. ALPHAFRESNEL: boolean;
  21574. LINEARALPHAFRESNEL: boolean;
  21575. PREMULTIPLYALPHA: boolean;
  21576. EMISSIVE: boolean;
  21577. EMISSIVEDIRECTUV: number;
  21578. REFLECTIVITY: boolean;
  21579. REFLECTIVITYDIRECTUV: number;
  21580. SPECULARTERM: boolean;
  21581. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21582. MICROSURFACEAUTOMATIC: boolean;
  21583. LODBASEDMICROSFURACE: boolean;
  21584. MICROSURFACEMAP: boolean;
  21585. MICROSURFACEMAPDIRECTUV: number;
  21586. METALLICWORKFLOW: boolean;
  21587. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21588. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21589. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21590. AOSTOREINMETALMAPRED: boolean;
  21591. METALLIC_REFLECTANCE: boolean;
  21592. METALLIC_REFLECTANCEDIRECTUV: number;
  21593. ENVIRONMENTBRDF: boolean;
  21594. ENVIRONMENTBRDF_RGBD: boolean;
  21595. NORMAL: boolean;
  21596. TANGENT: boolean;
  21597. BUMP: boolean;
  21598. BUMPDIRECTUV: number;
  21599. OBJECTSPACE_NORMALMAP: boolean;
  21600. PARALLAX: boolean;
  21601. PARALLAXOCCLUSION: boolean;
  21602. NORMALXYSCALE: boolean;
  21603. LIGHTMAP: boolean;
  21604. LIGHTMAPDIRECTUV: number;
  21605. USELIGHTMAPASSHADOWMAP: boolean;
  21606. GAMMALIGHTMAP: boolean;
  21607. RGBDLIGHTMAP: boolean;
  21608. REFLECTION: boolean;
  21609. REFLECTIONMAP_3D: boolean;
  21610. REFLECTIONMAP_SPHERICAL: boolean;
  21611. REFLECTIONMAP_PLANAR: boolean;
  21612. REFLECTIONMAP_CUBIC: boolean;
  21613. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21614. REFLECTIONMAP_PROJECTION: boolean;
  21615. REFLECTIONMAP_SKYBOX: boolean;
  21616. REFLECTIONMAP_EXPLICIT: boolean;
  21617. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21618. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21619. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21620. INVERTCUBICMAP: boolean;
  21621. USESPHERICALFROMREFLECTIONMAP: boolean;
  21622. USEIRRADIANCEMAP: boolean;
  21623. SPHERICAL_HARMONICS: boolean;
  21624. USESPHERICALINVERTEX: boolean;
  21625. REFLECTIONMAP_OPPOSITEZ: boolean;
  21626. LODINREFLECTIONALPHA: boolean;
  21627. GAMMAREFLECTION: boolean;
  21628. RGBDREFLECTION: boolean;
  21629. LINEARSPECULARREFLECTION: boolean;
  21630. RADIANCEOCCLUSION: boolean;
  21631. HORIZONOCCLUSION: boolean;
  21632. INSTANCES: boolean;
  21633. THIN_INSTANCES: boolean;
  21634. PREPASS: boolean;
  21635. PREPASS_IRRADIANCE: boolean;
  21636. PREPASS_IRRADIANCE_INDEX: number;
  21637. PREPASS_ALBEDO: boolean;
  21638. PREPASS_ALBEDO_INDEX: number;
  21639. PREPASS_DEPTHNORMAL: boolean;
  21640. PREPASS_DEPTHNORMAL_INDEX: number;
  21641. PREPASS_POSITION: boolean;
  21642. PREPASS_POSITION_INDEX: number;
  21643. PREPASS_VELOCITY: boolean;
  21644. PREPASS_VELOCITY_INDEX: number;
  21645. PREPASS_REFLECTIVITY: boolean;
  21646. PREPASS_REFLECTIVITY_INDEX: number;
  21647. SCENE_MRT_COUNT: number;
  21648. NUM_BONE_INFLUENCERS: number;
  21649. BonesPerMesh: number;
  21650. BONETEXTURE: boolean;
  21651. BONES_VELOCITY_ENABLED: boolean;
  21652. NONUNIFORMSCALING: boolean;
  21653. MORPHTARGETS: boolean;
  21654. MORPHTARGETS_NORMAL: boolean;
  21655. MORPHTARGETS_TANGENT: boolean;
  21656. MORPHTARGETS_UV: boolean;
  21657. NUM_MORPH_INFLUENCERS: number;
  21658. IMAGEPROCESSING: boolean;
  21659. VIGNETTE: boolean;
  21660. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21661. VIGNETTEBLENDMODEOPAQUE: boolean;
  21662. TONEMAPPING: boolean;
  21663. TONEMAPPING_ACES: boolean;
  21664. CONTRAST: boolean;
  21665. COLORCURVES: boolean;
  21666. COLORGRADING: boolean;
  21667. COLORGRADING3D: boolean;
  21668. SAMPLER3DGREENDEPTH: boolean;
  21669. SAMPLER3DBGRMAP: boolean;
  21670. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21671. EXPOSURE: boolean;
  21672. MULTIVIEW: boolean;
  21673. USEPHYSICALLIGHTFALLOFF: boolean;
  21674. USEGLTFLIGHTFALLOFF: boolean;
  21675. TWOSIDEDLIGHTING: boolean;
  21676. SHADOWFLOAT: boolean;
  21677. CLIPPLANE: boolean;
  21678. CLIPPLANE2: boolean;
  21679. CLIPPLANE3: boolean;
  21680. CLIPPLANE4: boolean;
  21681. CLIPPLANE5: boolean;
  21682. CLIPPLANE6: boolean;
  21683. POINTSIZE: boolean;
  21684. FOG: boolean;
  21685. LOGARITHMICDEPTH: boolean;
  21686. FORCENORMALFORWARD: boolean;
  21687. SPECULARAA: boolean;
  21688. CLEARCOAT: boolean;
  21689. CLEARCOAT_DEFAULTIOR: boolean;
  21690. CLEARCOAT_TEXTURE: boolean;
  21691. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21692. CLEARCOAT_TEXTUREDIRECTUV: number;
  21693. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21694. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21695. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21696. CLEARCOAT_BUMP: boolean;
  21697. CLEARCOAT_BUMPDIRECTUV: number;
  21698. CLEARCOAT_REMAP_F0: boolean;
  21699. CLEARCOAT_TINT: boolean;
  21700. CLEARCOAT_TINT_TEXTURE: boolean;
  21701. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21702. ANISOTROPIC: boolean;
  21703. ANISOTROPIC_TEXTURE: boolean;
  21704. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21705. BRDF_V_HEIGHT_CORRELATED: boolean;
  21706. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21707. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21708. SHEEN: boolean;
  21709. SHEEN_TEXTURE: boolean;
  21710. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21711. SHEEN_TEXTUREDIRECTUV: number;
  21712. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21713. SHEEN_LINKWITHALBEDO: boolean;
  21714. SHEEN_ROUGHNESS: boolean;
  21715. SHEEN_ALBEDOSCALING: boolean;
  21716. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21717. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21718. SUBSURFACE: boolean;
  21719. SS_REFRACTION: boolean;
  21720. SS_TRANSLUCENCY: boolean;
  21721. SS_SCATTERING: boolean;
  21722. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21723. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21724. SS_REFRACTIONMAP_3D: boolean;
  21725. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21726. SS_LODINREFRACTIONALPHA: boolean;
  21727. SS_GAMMAREFRACTION: boolean;
  21728. SS_RGBDREFRACTION: boolean;
  21729. SS_LINEARSPECULARREFRACTION: boolean;
  21730. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21731. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21732. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21733. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21734. UNLIT: boolean;
  21735. DEBUGMODE: number;
  21736. /**
  21737. * Initializes the PBR Material defines.
  21738. */
  21739. constructor();
  21740. /**
  21741. * Resets the PBR Material defines.
  21742. */
  21743. reset(): void;
  21744. }
  21745. /**
  21746. * The Physically based material base class of BJS.
  21747. *
  21748. * This offers the main features of a standard PBR material.
  21749. * For more information, please refer to the documentation :
  21750. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21751. */
  21752. export abstract class PBRBaseMaterial extends PushMaterial {
  21753. /**
  21754. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21755. */
  21756. static readonly PBRMATERIAL_OPAQUE: number;
  21757. /**
  21758. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21759. */
  21760. static readonly PBRMATERIAL_ALPHATEST: number;
  21761. /**
  21762. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21763. */
  21764. static readonly PBRMATERIAL_ALPHABLEND: number;
  21765. /**
  21766. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21767. * They are also discarded below the alpha cutoff threshold to improve performances.
  21768. */
  21769. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21770. /**
  21771. * Defines the default value of how much AO map is occluding the analytical lights
  21772. * (point spot...).
  21773. */
  21774. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21775. /**
  21776. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21777. */
  21778. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21779. /**
  21780. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21781. * to enhance interoperability with other engines.
  21782. */
  21783. static readonly LIGHTFALLOFF_GLTF: number;
  21784. /**
  21785. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21786. * to enhance interoperability with other materials.
  21787. */
  21788. static readonly LIGHTFALLOFF_STANDARD: number;
  21789. /**
  21790. * Intensity of the direct lights e.g. the four lights available in your scene.
  21791. * This impacts both the direct diffuse and specular highlights.
  21792. */
  21793. protected _directIntensity: number;
  21794. /**
  21795. * Intensity of the emissive part of the material.
  21796. * This helps controlling the emissive effect without modifying the emissive color.
  21797. */
  21798. protected _emissiveIntensity: number;
  21799. /**
  21800. * Intensity of the environment e.g. how much the environment will light the object
  21801. * either through harmonics for rough material or through the refelction for shiny ones.
  21802. */
  21803. protected _environmentIntensity: number;
  21804. /**
  21805. * This is a special control allowing the reduction of the specular highlights coming from the
  21806. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21807. */
  21808. protected _specularIntensity: number;
  21809. /**
  21810. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21811. */
  21812. private _lightingInfos;
  21813. /**
  21814. * Debug Control allowing disabling the bump map on this material.
  21815. */
  21816. protected _disableBumpMap: boolean;
  21817. /**
  21818. * AKA Diffuse Texture in standard nomenclature.
  21819. */
  21820. protected _albedoTexture: Nullable<BaseTexture>;
  21821. /**
  21822. * AKA Occlusion Texture in other nomenclature.
  21823. */
  21824. protected _ambientTexture: Nullable<BaseTexture>;
  21825. /**
  21826. * AKA Occlusion Texture Intensity in other nomenclature.
  21827. */
  21828. protected _ambientTextureStrength: number;
  21829. /**
  21830. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21831. * 1 means it completely occludes it
  21832. * 0 mean it has no impact
  21833. */
  21834. protected _ambientTextureImpactOnAnalyticalLights: number;
  21835. /**
  21836. * Stores the alpha values in a texture.
  21837. */
  21838. protected _opacityTexture: Nullable<BaseTexture>;
  21839. /**
  21840. * Stores the reflection values in a texture.
  21841. */
  21842. protected _reflectionTexture: Nullable<BaseTexture>;
  21843. /**
  21844. * Stores the emissive values in a texture.
  21845. */
  21846. protected _emissiveTexture: Nullable<BaseTexture>;
  21847. /**
  21848. * AKA Specular texture in other nomenclature.
  21849. */
  21850. protected _reflectivityTexture: Nullable<BaseTexture>;
  21851. /**
  21852. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21853. */
  21854. protected _metallicTexture: Nullable<BaseTexture>;
  21855. /**
  21856. * Specifies the metallic scalar of the metallic/roughness workflow.
  21857. * Can also be used to scale the metalness values of the metallic texture.
  21858. */
  21859. protected _metallic: Nullable<number>;
  21860. /**
  21861. * Specifies the roughness scalar of the metallic/roughness workflow.
  21862. * Can also be used to scale the roughness values of the metallic texture.
  21863. */
  21864. protected _roughness: Nullable<number>;
  21865. /**
  21866. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21867. * By default the indexOfrefraction is used to compute F0;
  21868. *
  21869. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21870. *
  21871. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21872. * F90 = metallicReflectanceColor;
  21873. */
  21874. protected _metallicF0Factor: number;
  21875. /**
  21876. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21877. * By default the F90 is always 1;
  21878. *
  21879. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21880. *
  21881. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21882. * F90 = metallicReflectanceColor;
  21883. */
  21884. protected _metallicReflectanceColor: Color3;
  21885. /**
  21886. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21887. * This is multiply against the scalar values defined in the material.
  21888. */
  21889. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21890. /**
  21891. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21892. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21893. */
  21894. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21895. /**
  21896. * Stores surface normal data used to displace a mesh in a texture.
  21897. */
  21898. protected _bumpTexture: Nullable<BaseTexture>;
  21899. /**
  21900. * Stores the pre-calculated light information of a mesh in a texture.
  21901. */
  21902. protected _lightmapTexture: Nullable<BaseTexture>;
  21903. /**
  21904. * The color of a material in ambient lighting.
  21905. */
  21906. protected _ambientColor: Color3;
  21907. /**
  21908. * AKA Diffuse Color in other nomenclature.
  21909. */
  21910. protected _albedoColor: Color3;
  21911. /**
  21912. * AKA Specular Color in other nomenclature.
  21913. */
  21914. protected _reflectivityColor: Color3;
  21915. /**
  21916. * The color applied when light is reflected from a material.
  21917. */
  21918. protected _reflectionColor: Color3;
  21919. /**
  21920. * The color applied when light is emitted from a material.
  21921. */
  21922. protected _emissiveColor: Color3;
  21923. /**
  21924. * AKA Glossiness in other nomenclature.
  21925. */
  21926. protected _microSurface: number;
  21927. /**
  21928. * Specifies that the material will use the light map as a show map.
  21929. */
  21930. protected _useLightmapAsShadowmap: boolean;
  21931. /**
  21932. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21933. * makes the reflect vector face the model (under horizon).
  21934. */
  21935. protected _useHorizonOcclusion: boolean;
  21936. /**
  21937. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21938. * too much the area relying on ambient texture to define their ambient occlusion.
  21939. */
  21940. protected _useRadianceOcclusion: boolean;
  21941. /**
  21942. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21943. */
  21944. protected _useAlphaFromAlbedoTexture: boolean;
  21945. /**
  21946. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21947. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21948. */
  21949. protected _useSpecularOverAlpha: boolean;
  21950. /**
  21951. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21952. */
  21953. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21954. /**
  21955. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21956. */
  21957. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21958. /**
  21959. * Specifies if the metallic texture contains the roughness information in its green channel.
  21960. */
  21961. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21962. /**
  21963. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21964. */
  21965. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21966. /**
  21967. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21968. */
  21969. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21970. /**
  21971. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21972. */
  21973. protected _useAmbientInGrayScale: boolean;
  21974. /**
  21975. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21976. * The material will try to infer what glossiness each pixel should be.
  21977. */
  21978. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21979. /**
  21980. * Defines the falloff type used in this material.
  21981. * It by default is Physical.
  21982. */
  21983. protected _lightFalloff: number;
  21984. /**
  21985. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21986. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21987. */
  21988. protected _useRadianceOverAlpha: boolean;
  21989. /**
  21990. * Allows using an object space normal map (instead of tangent space).
  21991. */
  21992. protected _useObjectSpaceNormalMap: boolean;
  21993. /**
  21994. * Allows using the bump map in parallax mode.
  21995. */
  21996. protected _useParallax: boolean;
  21997. /**
  21998. * Allows using the bump map in parallax occlusion mode.
  21999. */
  22000. protected _useParallaxOcclusion: boolean;
  22001. /**
  22002. * Controls the scale bias of the parallax mode.
  22003. */
  22004. protected _parallaxScaleBias: number;
  22005. /**
  22006. * If sets to true, disables all the lights affecting the material.
  22007. */
  22008. protected _disableLighting: boolean;
  22009. /**
  22010. * Number of Simultaneous lights allowed on the material.
  22011. */
  22012. protected _maxSimultaneousLights: number;
  22013. /**
  22014. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22015. */
  22016. protected _invertNormalMapX: boolean;
  22017. /**
  22018. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22019. */
  22020. protected _invertNormalMapY: boolean;
  22021. /**
  22022. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22023. */
  22024. protected _twoSidedLighting: boolean;
  22025. /**
  22026. * Defines the alpha limits in alpha test mode.
  22027. */
  22028. protected _alphaCutOff: number;
  22029. /**
  22030. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22031. */
  22032. protected _forceAlphaTest: boolean;
  22033. /**
  22034. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22035. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22036. */
  22037. protected _useAlphaFresnel: boolean;
  22038. /**
  22039. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22040. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22041. */
  22042. protected _useLinearAlphaFresnel: boolean;
  22043. /**
  22044. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22045. * from cos thetav and roughness:
  22046. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22047. */
  22048. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22049. /**
  22050. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22051. */
  22052. protected _forceIrradianceInFragment: boolean;
  22053. private _realTimeFiltering;
  22054. /**
  22055. * Enables realtime filtering on the texture.
  22056. */
  22057. get realTimeFiltering(): boolean;
  22058. set realTimeFiltering(b: boolean);
  22059. private _realTimeFilteringQuality;
  22060. /**
  22061. * Quality switch for realtime filtering
  22062. */
  22063. get realTimeFilteringQuality(): number;
  22064. set realTimeFilteringQuality(n: number);
  22065. /**
  22066. * Can this material render to several textures at once
  22067. */
  22068. get canRenderToMRT(): boolean;
  22069. /**
  22070. * Force normal to face away from face.
  22071. */
  22072. protected _forceNormalForward: boolean;
  22073. /**
  22074. * Enables specular anti aliasing in the PBR shader.
  22075. * It will both interacts on the Geometry for analytical and IBL lighting.
  22076. * It also prefilter the roughness map based on the bump values.
  22077. */
  22078. protected _enableSpecularAntiAliasing: boolean;
  22079. /**
  22080. * Default configuration related to image processing available in the PBR Material.
  22081. */
  22082. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22083. /**
  22084. * Keep track of the image processing observer to allow dispose and replace.
  22085. */
  22086. private _imageProcessingObserver;
  22087. /**
  22088. * Attaches a new image processing configuration to the PBR Material.
  22089. * @param configuration
  22090. */
  22091. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22092. /**
  22093. * Stores the available render targets.
  22094. */
  22095. private _renderTargets;
  22096. /**
  22097. * Sets the global ambient color for the material used in lighting calculations.
  22098. */
  22099. private _globalAmbientColor;
  22100. /**
  22101. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22102. */
  22103. private _useLogarithmicDepth;
  22104. /**
  22105. * If set to true, no lighting calculations will be applied.
  22106. */
  22107. private _unlit;
  22108. private _debugMode;
  22109. /**
  22110. * @hidden
  22111. * This is reserved for the inspector.
  22112. * Defines the material debug mode.
  22113. * It helps seeing only some components of the material while troubleshooting.
  22114. */
  22115. debugMode: number;
  22116. /**
  22117. * @hidden
  22118. * This is reserved for the inspector.
  22119. * Specify from where on screen the debug mode should start.
  22120. * The value goes from -1 (full screen) to 1 (not visible)
  22121. * It helps with side by side comparison against the final render
  22122. * This defaults to -1
  22123. */
  22124. private debugLimit;
  22125. /**
  22126. * @hidden
  22127. * This is reserved for the inspector.
  22128. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22129. * You can use the factor to better multiply the final value.
  22130. */
  22131. private debugFactor;
  22132. /**
  22133. * Defines the clear coat layer parameters for the material.
  22134. */
  22135. readonly clearCoat: PBRClearCoatConfiguration;
  22136. /**
  22137. * Defines the anisotropic parameters for the material.
  22138. */
  22139. readonly anisotropy: PBRAnisotropicConfiguration;
  22140. /**
  22141. * Defines the BRDF parameters for the material.
  22142. */
  22143. readonly brdf: PBRBRDFConfiguration;
  22144. /**
  22145. * Defines the Sheen parameters for the material.
  22146. */
  22147. readonly sheen: PBRSheenConfiguration;
  22148. /**
  22149. * Defines the SubSurface parameters for the material.
  22150. */
  22151. readonly subSurface: PBRSubSurfaceConfiguration;
  22152. /**
  22153. * Defines additionnal PrePass parameters for the material.
  22154. */
  22155. readonly prePassConfiguration: PrePassConfiguration;
  22156. /**
  22157. * Defines the detail map parameters for the material.
  22158. */
  22159. readonly detailMap: DetailMapConfiguration;
  22160. protected _rebuildInParallel: boolean;
  22161. /**
  22162. * Instantiates a new PBRMaterial instance.
  22163. *
  22164. * @param name The material name
  22165. * @param scene The scene the material will be use in.
  22166. */
  22167. constructor(name: string, scene: Scene);
  22168. /**
  22169. * Gets a boolean indicating that current material needs to register RTT
  22170. */
  22171. get hasRenderTargetTextures(): boolean;
  22172. /**
  22173. * Gets the name of the material class.
  22174. */
  22175. getClassName(): string;
  22176. /**
  22177. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22178. */
  22179. get useLogarithmicDepth(): boolean;
  22180. /**
  22181. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22182. */
  22183. set useLogarithmicDepth(value: boolean);
  22184. /**
  22185. * Returns true if alpha blending should be disabled.
  22186. */
  22187. protected get _disableAlphaBlending(): boolean;
  22188. /**
  22189. * Specifies whether or not this material should be rendered in alpha blend mode.
  22190. */
  22191. needAlphaBlending(): boolean;
  22192. /**
  22193. * Specifies whether or not this material should be rendered in alpha test mode.
  22194. */
  22195. needAlphaTesting(): boolean;
  22196. /**
  22197. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22198. */
  22199. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22200. /**
  22201. * Specifies whether or not there is a usable alpha channel for transparency.
  22202. */
  22203. protected _hasAlphaChannel(): boolean;
  22204. /**
  22205. * Gets the texture used for the alpha test.
  22206. */
  22207. getAlphaTestTexture(): Nullable<BaseTexture>;
  22208. /**
  22209. * Specifies that the submesh is ready to be used.
  22210. * @param mesh - BJS mesh.
  22211. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22212. * @param useInstances - Specifies that instances should be used.
  22213. * @returns - boolean indicating that the submesh is ready or not.
  22214. */
  22215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22216. /**
  22217. * Specifies if the material uses metallic roughness workflow.
  22218. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22219. */
  22220. isMetallicWorkflow(): boolean;
  22221. private _prepareEffect;
  22222. private _prepareDefines;
  22223. /**
  22224. * Force shader compilation
  22225. */
  22226. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22227. /**
  22228. * Initializes the uniform buffer layout for the shader.
  22229. */
  22230. buildUniformLayout(): void;
  22231. /**
  22232. * Unbinds the material from the mesh
  22233. */
  22234. unbind(): void;
  22235. /**
  22236. * Binds the submesh data.
  22237. * @param world - The world matrix.
  22238. * @param mesh - The BJS mesh.
  22239. * @param subMesh - A submesh of the BJS mesh.
  22240. */
  22241. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22242. /**
  22243. * Returns the animatable textures.
  22244. * @returns - Array of animatable textures.
  22245. */
  22246. getAnimatables(): IAnimatable[];
  22247. /**
  22248. * Returns the texture used for reflections.
  22249. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22250. */
  22251. private _getReflectionTexture;
  22252. /**
  22253. * Returns an array of the actively used textures.
  22254. * @returns - Array of BaseTextures
  22255. */
  22256. getActiveTextures(): BaseTexture[];
  22257. /**
  22258. * Checks to see if a texture is used in the material.
  22259. * @param texture - Base texture to use.
  22260. * @returns - Boolean specifying if a texture is used in the material.
  22261. */
  22262. hasTexture(texture: BaseTexture): boolean;
  22263. /**
  22264. * Sets the required values to the prepass renderer.
  22265. * @param prePassRenderer defines the prepass renderer to setup
  22266. */
  22267. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22268. /**
  22269. * Disposes the resources of the material.
  22270. * @param forceDisposeEffect - Forces the disposal of effects.
  22271. * @param forceDisposeTextures - Forces the disposal of all textures.
  22272. */
  22273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22274. }
  22275. }
  22276. declare module BABYLON {
  22277. /**
  22278. * The Physically based material of BJS.
  22279. *
  22280. * This offers the main features of a standard PBR material.
  22281. * For more information, please refer to the documentation :
  22282. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22283. */
  22284. export class PBRMaterial extends PBRBaseMaterial {
  22285. /**
  22286. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22287. */
  22288. static readonly PBRMATERIAL_OPAQUE: number;
  22289. /**
  22290. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22291. */
  22292. static readonly PBRMATERIAL_ALPHATEST: number;
  22293. /**
  22294. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22295. */
  22296. static readonly PBRMATERIAL_ALPHABLEND: number;
  22297. /**
  22298. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22299. * They are also discarded below the alpha cutoff threshold to improve performances.
  22300. */
  22301. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22302. /**
  22303. * Defines the default value of how much AO map is occluding the analytical lights
  22304. * (point spot...).
  22305. */
  22306. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22307. /**
  22308. * Intensity of the direct lights e.g. the four lights available in your scene.
  22309. * This impacts both the direct diffuse and specular highlights.
  22310. */
  22311. directIntensity: number;
  22312. /**
  22313. * Intensity of the emissive part of the material.
  22314. * This helps controlling the emissive effect without modifying the emissive color.
  22315. */
  22316. emissiveIntensity: number;
  22317. /**
  22318. * Intensity of the environment e.g. how much the environment will light the object
  22319. * either through harmonics for rough material or through the refelction for shiny ones.
  22320. */
  22321. environmentIntensity: number;
  22322. /**
  22323. * This is a special control allowing the reduction of the specular highlights coming from the
  22324. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22325. */
  22326. specularIntensity: number;
  22327. /**
  22328. * Debug Control allowing disabling the bump map on this material.
  22329. */
  22330. disableBumpMap: boolean;
  22331. /**
  22332. * AKA Diffuse Texture in standard nomenclature.
  22333. */
  22334. albedoTexture: BaseTexture;
  22335. /**
  22336. * AKA Occlusion Texture in other nomenclature.
  22337. */
  22338. ambientTexture: BaseTexture;
  22339. /**
  22340. * AKA Occlusion Texture Intensity in other nomenclature.
  22341. */
  22342. ambientTextureStrength: number;
  22343. /**
  22344. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22345. * 1 means it completely occludes it
  22346. * 0 mean it has no impact
  22347. */
  22348. ambientTextureImpactOnAnalyticalLights: number;
  22349. /**
  22350. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22351. */
  22352. opacityTexture: BaseTexture;
  22353. /**
  22354. * Stores the reflection values in a texture.
  22355. */
  22356. reflectionTexture: Nullable<BaseTexture>;
  22357. /**
  22358. * Stores the emissive values in a texture.
  22359. */
  22360. emissiveTexture: BaseTexture;
  22361. /**
  22362. * AKA Specular texture in other nomenclature.
  22363. */
  22364. reflectivityTexture: BaseTexture;
  22365. /**
  22366. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22367. */
  22368. metallicTexture: BaseTexture;
  22369. /**
  22370. * Specifies the metallic scalar of the metallic/roughness workflow.
  22371. * Can also be used to scale the metalness values of the metallic texture.
  22372. */
  22373. metallic: Nullable<number>;
  22374. /**
  22375. * Specifies the roughness scalar of the metallic/roughness workflow.
  22376. * Can also be used to scale the roughness values of the metallic texture.
  22377. */
  22378. roughness: Nullable<number>;
  22379. /**
  22380. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22381. * By default the indexOfrefraction is used to compute F0;
  22382. *
  22383. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22384. *
  22385. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22386. * F90 = metallicReflectanceColor;
  22387. */
  22388. metallicF0Factor: number;
  22389. /**
  22390. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22391. * By default the F90 is always 1;
  22392. *
  22393. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22394. *
  22395. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22396. * F90 = metallicReflectanceColor;
  22397. */
  22398. metallicReflectanceColor: Color3;
  22399. /**
  22400. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22401. * This is multiply against the scalar values defined in the material.
  22402. */
  22403. metallicReflectanceTexture: Nullable<BaseTexture>;
  22404. /**
  22405. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22406. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22407. */
  22408. microSurfaceTexture: BaseTexture;
  22409. /**
  22410. * Stores surface normal data used to displace a mesh in a texture.
  22411. */
  22412. bumpTexture: BaseTexture;
  22413. /**
  22414. * Stores the pre-calculated light information of a mesh in a texture.
  22415. */
  22416. lightmapTexture: BaseTexture;
  22417. /**
  22418. * Stores the refracted light information in a texture.
  22419. */
  22420. get refractionTexture(): Nullable<BaseTexture>;
  22421. set refractionTexture(value: Nullable<BaseTexture>);
  22422. /**
  22423. * The color of a material in ambient lighting.
  22424. */
  22425. ambientColor: Color3;
  22426. /**
  22427. * AKA Diffuse Color in other nomenclature.
  22428. */
  22429. albedoColor: Color3;
  22430. /**
  22431. * AKA Specular Color in other nomenclature.
  22432. */
  22433. reflectivityColor: Color3;
  22434. /**
  22435. * The color reflected from the material.
  22436. */
  22437. reflectionColor: Color3;
  22438. /**
  22439. * The color emitted from the material.
  22440. */
  22441. emissiveColor: Color3;
  22442. /**
  22443. * AKA Glossiness in other nomenclature.
  22444. */
  22445. microSurface: number;
  22446. /**
  22447. * Index of refraction of the material base layer.
  22448. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22449. *
  22450. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22451. *
  22452. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22453. */
  22454. get indexOfRefraction(): number;
  22455. set indexOfRefraction(value: number);
  22456. /**
  22457. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22458. */
  22459. get invertRefractionY(): boolean;
  22460. set invertRefractionY(value: boolean);
  22461. /**
  22462. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22463. * Materials half opaque for instance using refraction could benefit from this control.
  22464. */
  22465. get linkRefractionWithTransparency(): boolean;
  22466. set linkRefractionWithTransparency(value: boolean);
  22467. /**
  22468. * If true, the light map contains occlusion information instead of lighting info.
  22469. */
  22470. useLightmapAsShadowmap: boolean;
  22471. /**
  22472. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22473. */
  22474. useAlphaFromAlbedoTexture: boolean;
  22475. /**
  22476. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22477. */
  22478. forceAlphaTest: boolean;
  22479. /**
  22480. * Defines the alpha limits in alpha test mode.
  22481. */
  22482. alphaCutOff: number;
  22483. /**
  22484. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22485. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22486. */
  22487. useSpecularOverAlpha: boolean;
  22488. /**
  22489. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22490. */
  22491. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22492. /**
  22493. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22494. */
  22495. useRoughnessFromMetallicTextureAlpha: boolean;
  22496. /**
  22497. * Specifies if the metallic texture contains the roughness information in its green channel.
  22498. */
  22499. useRoughnessFromMetallicTextureGreen: boolean;
  22500. /**
  22501. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22502. */
  22503. useMetallnessFromMetallicTextureBlue: boolean;
  22504. /**
  22505. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22506. */
  22507. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22508. /**
  22509. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22510. */
  22511. useAmbientInGrayScale: boolean;
  22512. /**
  22513. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22514. * The material will try to infer what glossiness each pixel should be.
  22515. */
  22516. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22517. /**
  22518. * BJS is using an harcoded light falloff based on a manually sets up range.
  22519. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22520. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22521. */
  22522. get usePhysicalLightFalloff(): boolean;
  22523. /**
  22524. * BJS is using an harcoded light falloff based on a manually sets up range.
  22525. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22526. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22527. */
  22528. set usePhysicalLightFalloff(value: boolean);
  22529. /**
  22530. * In order to support the falloff compatibility with gltf, a special mode has been added
  22531. * to reproduce the gltf light falloff.
  22532. */
  22533. get useGLTFLightFalloff(): boolean;
  22534. /**
  22535. * In order to support the falloff compatibility with gltf, a special mode has been added
  22536. * to reproduce the gltf light falloff.
  22537. */
  22538. set useGLTFLightFalloff(value: boolean);
  22539. /**
  22540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22542. */
  22543. useRadianceOverAlpha: boolean;
  22544. /**
  22545. * Allows using an object space normal map (instead of tangent space).
  22546. */
  22547. useObjectSpaceNormalMap: boolean;
  22548. /**
  22549. * Allows using the bump map in parallax mode.
  22550. */
  22551. useParallax: boolean;
  22552. /**
  22553. * Allows using the bump map in parallax occlusion mode.
  22554. */
  22555. useParallaxOcclusion: boolean;
  22556. /**
  22557. * Controls the scale bias of the parallax mode.
  22558. */
  22559. parallaxScaleBias: number;
  22560. /**
  22561. * If sets to true, disables all the lights affecting the material.
  22562. */
  22563. disableLighting: boolean;
  22564. /**
  22565. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22566. */
  22567. forceIrradianceInFragment: boolean;
  22568. /**
  22569. * Number of Simultaneous lights allowed on the material.
  22570. */
  22571. maxSimultaneousLights: number;
  22572. /**
  22573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22574. */
  22575. invertNormalMapX: boolean;
  22576. /**
  22577. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22578. */
  22579. invertNormalMapY: boolean;
  22580. /**
  22581. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22582. */
  22583. twoSidedLighting: boolean;
  22584. /**
  22585. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22586. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22587. */
  22588. useAlphaFresnel: boolean;
  22589. /**
  22590. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22591. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22592. */
  22593. useLinearAlphaFresnel: boolean;
  22594. /**
  22595. * Let user defines the brdf lookup texture used for IBL.
  22596. * A default 8bit version is embedded but you could point at :
  22597. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22598. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22599. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22600. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22601. */
  22602. environmentBRDFTexture: Nullable<BaseTexture>;
  22603. /**
  22604. * Force normal to face away from face.
  22605. */
  22606. forceNormalForward: boolean;
  22607. /**
  22608. * Enables specular anti aliasing in the PBR shader.
  22609. * It will both interacts on the Geometry for analytical and IBL lighting.
  22610. * It also prefilter the roughness map based on the bump values.
  22611. */
  22612. enableSpecularAntiAliasing: boolean;
  22613. /**
  22614. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22615. * makes the reflect vector face the model (under horizon).
  22616. */
  22617. useHorizonOcclusion: boolean;
  22618. /**
  22619. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22620. * too much the area relying on ambient texture to define their ambient occlusion.
  22621. */
  22622. useRadianceOcclusion: boolean;
  22623. /**
  22624. * If set to true, no lighting calculations will be applied.
  22625. */
  22626. unlit: boolean;
  22627. /**
  22628. * Gets the image processing configuration used either in this material.
  22629. */
  22630. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22631. /**
  22632. * Sets the Default image processing configuration used either in the this material.
  22633. *
  22634. * If sets to null, the scene one is in use.
  22635. */
  22636. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22637. /**
  22638. * Gets wether the color curves effect is enabled.
  22639. */
  22640. get cameraColorCurvesEnabled(): boolean;
  22641. /**
  22642. * Sets wether the color curves effect is enabled.
  22643. */
  22644. set cameraColorCurvesEnabled(value: boolean);
  22645. /**
  22646. * Gets wether the color grading effect is enabled.
  22647. */
  22648. get cameraColorGradingEnabled(): boolean;
  22649. /**
  22650. * Gets wether the color grading effect is enabled.
  22651. */
  22652. set cameraColorGradingEnabled(value: boolean);
  22653. /**
  22654. * Gets wether tonemapping is enabled or not.
  22655. */
  22656. get cameraToneMappingEnabled(): boolean;
  22657. /**
  22658. * Sets wether tonemapping is enabled or not
  22659. */
  22660. set cameraToneMappingEnabled(value: boolean);
  22661. /**
  22662. * The camera exposure used on this material.
  22663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22664. * This corresponds to a photographic exposure.
  22665. */
  22666. get cameraExposure(): number;
  22667. /**
  22668. * The camera exposure used on this material.
  22669. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22670. * This corresponds to a photographic exposure.
  22671. */
  22672. set cameraExposure(value: number);
  22673. /**
  22674. * Gets The camera contrast used on this material.
  22675. */
  22676. get cameraContrast(): number;
  22677. /**
  22678. * Sets The camera contrast used on this material.
  22679. */
  22680. set cameraContrast(value: number);
  22681. /**
  22682. * Gets the Color Grading 2D Lookup Texture.
  22683. */
  22684. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22685. /**
  22686. * Sets the Color Grading 2D Lookup Texture.
  22687. */
  22688. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22689. /**
  22690. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22691. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22692. * 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;
  22693. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22694. */
  22695. get cameraColorCurves(): Nullable<ColorCurves>;
  22696. /**
  22697. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22698. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22699. * 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;
  22700. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22701. */
  22702. set cameraColorCurves(value: Nullable<ColorCurves>);
  22703. /**
  22704. * Instantiates a new PBRMaterial instance.
  22705. *
  22706. * @param name The material name
  22707. * @param scene The scene the material will be use in.
  22708. */
  22709. constructor(name: string, scene: Scene);
  22710. /**
  22711. * Returns the name of this material class.
  22712. */
  22713. getClassName(): string;
  22714. /**
  22715. * Makes a duplicate of the current material.
  22716. * @param name - name to use for the new material.
  22717. */
  22718. clone(name: string): PBRMaterial;
  22719. /**
  22720. * Serializes this PBR Material.
  22721. * @returns - An object with the serialized material.
  22722. */
  22723. serialize(): any;
  22724. /**
  22725. * Parses a PBR Material from a serialized object.
  22726. * @param source - Serialized object.
  22727. * @param scene - BJS scene instance.
  22728. * @param rootUrl - url for the scene object
  22729. * @returns - PBRMaterial
  22730. */
  22731. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22732. }
  22733. }
  22734. declare module BABYLON {
  22735. /** @hidden */
  22736. export var mrtFragmentDeclaration: {
  22737. name: string;
  22738. shader: string;
  22739. };
  22740. }
  22741. declare module BABYLON {
  22742. /** @hidden */
  22743. export var geometryPixelShader: {
  22744. name: string;
  22745. shader: string;
  22746. };
  22747. }
  22748. declare module BABYLON {
  22749. /** @hidden */
  22750. export var instancesDeclaration: {
  22751. name: string;
  22752. shader: string;
  22753. };
  22754. }
  22755. declare module BABYLON {
  22756. /** @hidden */
  22757. export var geometryVertexShader: {
  22758. name: string;
  22759. shader: string;
  22760. };
  22761. }
  22762. declare module BABYLON {
  22763. /** @hidden */
  22764. interface ISavedTransformationMatrix {
  22765. world: Matrix;
  22766. viewProjection: Matrix;
  22767. }
  22768. /**
  22769. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22770. */
  22771. export class GeometryBufferRenderer {
  22772. /**
  22773. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22774. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22775. */
  22776. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22777. /**
  22778. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22779. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22780. */
  22781. static readonly POSITION_TEXTURE_TYPE: number;
  22782. /**
  22783. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22784. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22785. */
  22786. static readonly VELOCITY_TEXTURE_TYPE: number;
  22787. /**
  22788. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22789. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22790. */
  22791. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22792. /**
  22793. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22794. * in order to compute objects velocities when enableVelocity is set to "true"
  22795. * @hidden
  22796. */
  22797. _previousTransformationMatrices: {
  22798. [index: number]: ISavedTransformationMatrix;
  22799. };
  22800. /**
  22801. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22802. * in order to compute objects velocities when enableVelocity is set to "true"
  22803. * @hidden
  22804. */
  22805. _previousBonesTransformationMatrices: {
  22806. [index: number]: Float32Array;
  22807. };
  22808. /**
  22809. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22810. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22811. */
  22812. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22813. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22814. renderTransparentMeshes: boolean;
  22815. private _scene;
  22816. private _resizeObserver;
  22817. private _multiRenderTarget;
  22818. private _ratio;
  22819. private _enablePosition;
  22820. private _enableVelocity;
  22821. private _enableReflectivity;
  22822. private _positionIndex;
  22823. private _velocityIndex;
  22824. private _reflectivityIndex;
  22825. private _depthNormalIndex;
  22826. private _linkedWithPrePass;
  22827. private _prePassRenderer;
  22828. private _attachments;
  22829. protected _effect: Effect;
  22830. protected _cachedDefines: string;
  22831. /**
  22832. * @hidden
  22833. * Sets up internal structures to share outputs with PrePassRenderer
  22834. * This method should only be called by the PrePassRenderer itself
  22835. */
  22836. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22837. /**
  22838. * @hidden
  22839. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22840. * This method should only be called by the PrePassRenderer itself
  22841. */
  22842. _unlinkPrePassRenderer(): void;
  22843. /**
  22844. * @hidden
  22845. * Resets the geometry buffer layout
  22846. */
  22847. _resetLayout(): void;
  22848. /**
  22849. * @hidden
  22850. * Replaces a texture in the geometry buffer renderer
  22851. * Useful when linking textures of the prepass renderer
  22852. */
  22853. _forceTextureType(geometryBufferType: number, index: number): void;
  22854. /**
  22855. * @hidden
  22856. * Sets texture attachments
  22857. * Useful when linking textures of the prepass renderer
  22858. */
  22859. _setAttachments(attachments: number[]): void;
  22860. /**
  22861. * @hidden
  22862. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22863. * Useful when linking textures of the prepass renderer
  22864. */
  22865. _linkInternalTexture(internalTexture: InternalTexture): void;
  22866. /**
  22867. * Gets the render list (meshes to be rendered) used in the G buffer.
  22868. */
  22869. get renderList(): Nullable<AbstractMesh[]>;
  22870. /**
  22871. * Set the render list (meshes to be rendered) used in the G buffer.
  22872. */
  22873. set renderList(meshes: Nullable<AbstractMesh[]>);
  22874. /**
  22875. * Gets wether or not G buffer are supported by the running hardware.
  22876. * This requires draw buffer supports
  22877. */
  22878. get isSupported(): boolean;
  22879. /**
  22880. * Returns the index of the given texture type in the G-Buffer textures array
  22881. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22882. * @returns the index of the given texture type in the G-Buffer textures array
  22883. */
  22884. getTextureIndex(textureType: number): number;
  22885. /**
  22886. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22887. */
  22888. get enablePosition(): boolean;
  22889. /**
  22890. * Sets whether or not objects positions are enabled for the G buffer.
  22891. */
  22892. set enablePosition(enable: boolean);
  22893. /**
  22894. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22895. */
  22896. get enableVelocity(): boolean;
  22897. /**
  22898. * Sets wether or not objects velocities are enabled for the G buffer.
  22899. */
  22900. set enableVelocity(enable: boolean);
  22901. /**
  22902. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22903. */
  22904. get enableReflectivity(): boolean;
  22905. /**
  22906. * Sets wether or not objects roughness are enabled for the G buffer.
  22907. */
  22908. set enableReflectivity(enable: boolean);
  22909. /**
  22910. * Gets the scene associated with the buffer.
  22911. */
  22912. get scene(): Scene;
  22913. /**
  22914. * Gets the ratio used by the buffer during its creation.
  22915. * How big is the buffer related to the main canvas.
  22916. */
  22917. get ratio(): number;
  22918. /** @hidden */
  22919. static _SceneComponentInitialization: (scene: Scene) => void;
  22920. /**
  22921. * Creates a new G Buffer for the scene
  22922. * @param scene The scene the buffer belongs to
  22923. * @param ratio How big is the buffer related to the main canvas.
  22924. */
  22925. constructor(scene: Scene, ratio?: number);
  22926. /**
  22927. * Checks wether everything is ready to render a submesh to the G buffer.
  22928. * @param subMesh the submesh to check readiness for
  22929. * @param useInstances is the mesh drawn using instance or not
  22930. * @returns true if ready otherwise false
  22931. */
  22932. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22933. /**
  22934. * Gets the current underlying G Buffer.
  22935. * @returns the buffer
  22936. */
  22937. getGBuffer(): MultiRenderTarget;
  22938. /**
  22939. * Gets the number of samples used to render the buffer (anti aliasing).
  22940. */
  22941. get samples(): number;
  22942. /**
  22943. * Sets the number of samples used to render the buffer (anti aliasing).
  22944. */
  22945. set samples(value: number);
  22946. /**
  22947. * Disposes the renderer and frees up associated resources.
  22948. */
  22949. dispose(): void;
  22950. private _assignRenderTargetIndices;
  22951. protected _createRenderTargets(): void;
  22952. private _copyBonesTransformationMatrices;
  22953. }
  22954. }
  22955. declare module BABYLON {
  22956. /**
  22957. * Renders a pre pass of the scene
  22958. * This means every mesh in the scene will be rendered to a render target texture
  22959. * And then this texture will be composited to the rendering canvas with post processes
  22960. * It is necessary for effects like subsurface scattering or deferred shading
  22961. */
  22962. export class PrePassRenderer {
  22963. /** @hidden */
  22964. static _SceneComponentInitialization: (scene: Scene) => void;
  22965. private _textureFormats;
  22966. /**
  22967. * To save performance, we can excluded skinned meshes from the prepass
  22968. */
  22969. excludedSkinnedMesh: AbstractMesh[];
  22970. /**
  22971. * Force material to be excluded from the prepass
  22972. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22973. * and you don't want a material to show in the effect.
  22974. */
  22975. excludedMaterials: Material[];
  22976. private _textureIndices;
  22977. private _scene;
  22978. private _engine;
  22979. private _isDirty;
  22980. /**
  22981. * Number of textures in the multi render target texture where the scene is directly rendered
  22982. */
  22983. mrtCount: number;
  22984. /**
  22985. * The render target where the scene is directly rendered
  22986. */
  22987. prePassRT: MultiRenderTarget;
  22988. private _multiRenderAttachments;
  22989. private _defaultAttachments;
  22990. private _postProcesses;
  22991. private readonly _clearColor;
  22992. /**
  22993. * Image processing post process for composition
  22994. */
  22995. imageProcessingPostProcess: ImageProcessingPostProcess;
  22996. /**
  22997. * Configuration for prepass effects
  22998. */
  22999. private _effectConfigurations;
  23000. private _mrtFormats;
  23001. private _mrtLayout;
  23002. private _enabled;
  23003. /**
  23004. * Indicates if the prepass is enabled
  23005. */
  23006. get enabled(): boolean;
  23007. /**
  23008. * How many samples are used for MSAA of the scene render target
  23009. */
  23010. get samples(): number;
  23011. set samples(n: number);
  23012. private _geometryBuffer;
  23013. private _useGeometryBufferFallback;
  23014. /**
  23015. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23016. */
  23017. get useGeometryBufferFallback(): boolean;
  23018. set useGeometryBufferFallback(value: boolean);
  23019. /**
  23020. * Set to true to disable gamma transform in PrePass.
  23021. * Can be useful in case you already proceed to gamma transform on a material level
  23022. * and your post processes don't need to be in linear color space.
  23023. */
  23024. disableGammaTransform: boolean;
  23025. /**
  23026. * Instanciates a prepass renderer
  23027. * @param scene The scene
  23028. */
  23029. constructor(scene: Scene);
  23030. private _initializeAttachments;
  23031. private _createCompositionEffect;
  23032. /**
  23033. * Indicates if rendering a prepass is supported
  23034. */
  23035. get isSupported(): boolean;
  23036. /**
  23037. * Sets the proper output textures to draw in the engine.
  23038. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23039. * @param subMesh Submesh on which the effect is applied
  23040. */
  23041. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23042. /**
  23043. * Restores attachments for single texture draw.
  23044. */
  23045. restoreAttachments(): void;
  23046. /**
  23047. * @hidden
  23048. */
  23049. _beforeCameraDraw(): void;
  23050. /**
  23051. * @hidden
  23052. */
  23053. _afterCameraDraw(): void;
  23054. private _checkRTSize;
  23055. private _bindFrameBuffer;
  23056. /**
  23057. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23058. */
  23059. clear(): void;
  23060. private _setState;
  23061. private _updateGeometryBufferLayout;
  23062. /**
  23063. * Adds an effect configuration to the prepass.
  23064. * If an effect has already been added, it won't add it twice and will return the configuration
  23065. * already present.
  23066. * @param cfg the effect configuration
  23067. * @return the effect configuration now used by the prepass
  23068. */
  23069. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23070. /**
  23071. * Returns the index of a texture in the multi render target texture array.
  23072. * @param type Texture type
  23073. * @return The index
  23074. */
  23075. getIndex(type: number): number;
  23076. private _enable;
  23077. private _disable;
  23078. private _resetLayout;
  23079. private _resetPostProcessChain;
  23080. private _bindPostProcessChain;
  23081. /**
  23082. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23083. */
  23084. markAsDirty(): void;
  23085. /**
  23086. * Enables a texture on the MultiRenderTarget for prepass
  23087. */
  23088. private _enableTextures;
  23089. private _update;
  23090. private _markAllMaterialsAsPrePassDirty;
  23091. /**
  23092. * Disposes the prepass renderer.
  23093. */
  23094. dispose(): void;
  23095. }
  23096. }
  23097. declare module BABYLON {
  23098. /**
  23099. * Size options for a post process
  23100. */
  23101. export type PostProcessOptions = {
  23102. width: number;
  23103. height: number;
  23104. };
  23105. /**
  23106. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23107. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23108. */
  23109. export class PostProcess {
  23110. /**
  23111. * Gets or sets the unique id of the post process
  23112. */
  23113. uniqueId: number;
  23114. /** Name of the PostProcess. */
  23115. name: string;
  23116. /**
  23117. * Width of the texture to apply the post process on
  23118. */
  23119. width: number;
  23120. /**
  23121. * Height of the texture to apply the post process on
  23122. */
  23123. height: number;
  23124. /**
  23125. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23126. */
  23127. nodeMaterialSource: Nullable<NodeMaterial>;
  23128. /**
  23129. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23130. * @hidden
  23131. */
  23132. _outputTexture: Nullable<InternalTexture>;
  23133. /**
  23134. * Sampling mode used by the shader
  23135. * See https://doc.babylonjs.com/classes/3.1/texture
  23136. */
  23137. renderTargetSamplingMode: number;
  23138. /**
  23139. * Clear color to use when screen clearing
  23140. */
  23141. clearColor: Color4;
  23142. /**
  23143. * If the buffer needs to be cleared before applying the post process. (default: true)
  23144. * Should be set to false if shader will overwrite all previous pixels.
  23145. */
  23146. autoClear: boolean;
  23147. /**
  23148. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23149. */
  23150. alphaMode: number;
  23151. /**
  23152. * Sets the setAlphaBlendConstants of the babylon engine
  23153. */
  23154. alphaConstants: Color4;
  23155. /**
  23156. * Animations to be used for the post processing
  23157. */
  23158. animations: Animation[];
  23159. /**
  23160. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23161. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23162. */
  23163. enablePixelPerfectMode: boolean;
  23164. /**
  23165. * Force the postprocess to be applied without taking in account viewport
  23166. */
  23167. forceFullscreenViewport: boolean;
  23168. /**
  23169. * List of inspectable custom properties (used by the Inspector)
  23170. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23171. */
  23172. inspectableCustomProperties: IInspectable[];
  23173. /**
  23174. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23175. *
  23176. * | Value | Type | Description |
  23177. * | ----- | ----------------------------------- | ----------- |
  23178. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23179. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23180. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23181. *
  23182. */
  23183. scaleMode: number;
  23184. /**
  23185. * Force textures to be a power of two (default: false)
  23186. */
  23187. alwaysForcePOT: boolean;
  23188. private _samples;
  23189. /**
  23190. * Number of sample textures (default: 1)
  23191. */
  23192. get samples(): number;
  23193. set samples(n: number);
  23194. /**
  23195. * Modify the scale of the post process to be the same as the viewport (default: false)
  23196. */
  23197. adaptScaleToCurrentViewport: boolean;
  23198. private _camera;
  23199. protected _scene: Scene;
  23200. private _engine;
  23201. private _options;
  23202. private _reusable;
  23203. private _textureType;
  23204. private _textureFormat;
  23205. /**
  23206. * Smart array of input and output textures for the post process.
  23207. * @hidden
  23208. */
  23209. _textures: SmartArray<InternalTexture>;
  23210. /**
  23211. * The index in _textures that corresponds to the output texture.
  23212. * @hidden
  23213. */
  23214. _currentRenderTextureInd: number;
  23215. private _effect;
  23216. private _samplers;
  23217. private _fragmentUrl;
  23218. private _vertexUrl;
  23219. private _parameters;
  23220. private _scaleRatio;
  23221. protected _indexParameters: any;
  23222. private _shareOutputWithPostProcess;
  23223. private _texelSize;
  23224. private _forcedOutputTexture;
  23225. /**
  23226. * Prepass configuration in case this post process needs a texture from prepass
  23227. * @hidden
  23228. */
  23229. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23230. /**
  23231. * Returns the fragment url or shader name used in the post process.
  23232. * @returns the fragment url or name in the shader store.
  23233. */
  23234. getEffectName(): string;
  23235. /**
  23236. * An event triggered when the postprocess is activated.
  23237. */
  23238. onActivateObservable: Observable<Camera>;
  23239. private _onActivateObserver;
  23240. /**
  23241. * A function that is added to the onActivateObservable
  23242. */
  23243. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23244. /**
  23245. * An event triggered when the postprocess changes its size.
  23246. */
  23247. onSizeChangedObservable: Observable<PostProcess>;
  23248. private _onSizeChangedObserver;
  23249. /**
  23250. * A function that is added to the onSizeChangedObservable
  23251. */
  23252. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23253. /**
  23254. * An event triggered when the postprocess applies its effect.
  23255. */
  23256. onApplyObservable: Observable<Effect>;
  23257. private _onApplyObserver;
  23258. /**
  23259. * A function that is added to the onApplyObservable
  23260. */
  23261. set onApply(callback: (effect: Effect) => void);
  23262. /**
  23263. * An event triggered before rendering the postprocess
  23264. */
  23265. onBeforeRenderObservable: Observable<Effect>;
  23266. private _onBeforeRenderObserver;
  23267. /**
  23268. * A function that is added to the onBeforeRenderObservable
  23269. */
  23270. set onBeforeRender(callback: (effect: Effect) => void);
  23271. /**
  23272. * An event triggered after rendering the postprocess
  23273. */
  23274. onAfterRenderObservable: Observable<Effect>;
  23275. private _onAfterRenderObserver;
  23276. /**
  23277. * A function that is added to the onAfterRenderObservable
  23278. */
  23279. set onAfterRender(callback: (efect: Effect) => void);
  23280. /**
  23281. * 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
  23282. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23283. */
  23284. get inputTexture(): InternalTexture;
  23285. set inputTexture(value: InternalTexture);
  23286. /**
  23287. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23288. * the only way to unset it is to use this function to restore its internal state
  23289. */
  23290. restoreDefaultInputTexture(): void;
  23291. /**
  23292. * Gets the camera which post process is applied to.
  23293. * @returns The camera the post process is applied to.
  23294. */
  23295. getCamera(): Camera;
  23296. /**
  23297. * Gets the texel size of the postprocess.
  23298. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23299. */
  23300. get texelSize(): Vector2;
  23301. /**
  23302. * Creates a new instance PostProcess
  23303. * @param name The name of the PostProcess.
  23304. * @param fragmentUrl The url of the fragment shader to be used.
  23305. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23306. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23307. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23308. * @param camera The camera to apply the render pass to.
  23309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23310. * @param engine The engine which the post process will be applied. (default: current engine)
  23311. * @param reusable If the post process can be reused on the same frame. (default: false)
  23312. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23313. * @param textureType Type of textures used when performing the post process. (default: 0)
  23314. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23315. * @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
  23316. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23317. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23318. */
  23319. 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);
  23320. /**
  23321. * Gets a string identifying the name of the class
  23322. * @returns "PostProcess" string
  23323. */
  23324. getClassName(): string;
  23325. /**
  23326. * Gets the engine which this post process belongs to.
  23327. * @returns The engine the post process was enabled with.
  23328. */
  23329. getEngine(): Engine;
  23330. /**
  23331. * The effect that is created when initializing the post process.
  23332. * @returns The created effect corresponding the the postprocess.
  23333. */
  23334. getEffect(): Effect;
  23335. /**
  23336. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23337. * @param postProcess The post process to share the output with.
  23338. * @returns This post process.
  23339. */
  23340. shareOutputWith(postProcess: PostProcess): PostProcess;
  23341. /**
  23342. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23343. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23344. */
  23345. useOwnOutput(): void;
  23346. /**
  23347. * Updates the effect with the current post process compile time values and recompiles the shader.
  23348. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23349. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23350. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23351. * @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
  23352. * @param onCompiled Called when the shader has been compiled.
  23353. * @param onError Called if there is an error when compiling a shader.
  23354. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23355. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23356. */
  23357. 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;
  23358. /**
  23359. * The post process is reusable if it can be used multiple times within one frame.
  23360. * @returns If the post process is reusable
  23361. */
  23362. isReusable(): boolean;
  23363. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23364. markTextureDirty(): void;
  23365. /**
  23366. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23367. * 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.
  23368. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23369. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23370. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23371. * @returns The target texture that was bound to be written to.
  23372. */
  23373. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23374. /**
  23375. * If the post process is supported.
  23376. */
  23377. get isSupported(): boolean;
  23378. /**
  23379. * The aspect ratio of the output texture.
  23380. */
  23381. get aspectRatio(): number;
  23382. /**
  23383. * Get a value indicating if the post-process is ready to be used
  23384. * @returns true if the post-process is ready (shader is compiled)
  23385. */
  23386. isReady(): boolean;
  23387. /**
  23388. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23389. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23390. */
  23391. apply(): Nullable<Effect>;
  23392. private _disposeTextures;
  23393. /**
  23394. * Sets the required values to the prepass renderer.
  23395. * @param prePassRenderer defines the prepass renderer to setup.
  23396. * @returns true if the pre pass is needed.
  23397. */
  23398. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23399. /**
  23400. * Disposes the post process.
  23401. * @param camera The camera to dispose the post process on.
  23402. */
  23403. dispose(camera?: Camera): void;
  23404. /**
  23405. * Serializes the particle system to a JSON object
  23406. * @returns the JSON object
  23407. */
  23408. serialize(): any;
  23409. /**
  23410. * Creates a material from parsed material data
  23411. * @param parsedPostProcess defines parsed post process data
  23412. * @param scene defines the hosting scene
  23413. * @param rootUrl defines the root URL to use to load textures
  23414. * @returns a new post process
  23415. */
  23416. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23417. }
  23418. }
  23419. declare module BABYLON {
  23420. /** @hidden */
  23421. export var kernelBlurVaryingDeclaration: {
  23422. name: string;
  23423. shader: string;
  23424. };
  23425. }
  23426. declare module BABYLON {
  23427. /** @hidden */
  23428. export var packingFunctions: {
  23429. name: string;
  23430. shader: string;
  23431. };
  23432. }
  23433. declare module BABYLON {
  23434. /** @hidden */
  23435. export var kernelBlurFragment: {
  23436. name: string;
  23437. shader: string;
  23438. };
  23439. }
  23440. declare module BABYLON {
  23441. /** @hidden */
  23442. export var kernelBlurFragment2: {
  23443. name: string;
  23444. shader: string;
  23445. };
  23446. }
  23447. declare module BABYLON {
  23448. /** @hidden */
  23449. export var kernelBlurPixelShader: {
  23450. name: string;
  23451. shader: string;
  23452. };
  23453. }
  23454. declare module BABYLON {
  23455. /** @hidden */
  23456. export var kernelBlurVertex: {
  23457. name: string;
  23458. shader: string;
  23459. };
  23460. }
  23461. declare module BABYLON {
  23462. /** @hidden */
  23463. export var kernelBlurVertexShader: {
  23464. name: string;
  23465. shader: string;
  23466. };
  23467. }
  23468. declare module BABYLON {
  23469. /**
  23470. * The Blur Post Process which blurs an image based on a kernel and direction.
  23471. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23472. */
  23473. export class BlurPostProcess extends PostProcess {
  23474. private blockCompilation;
  23475. protected _kernel: number;
  23476. protected _idealKernel: number;
  23477. protected _packedFloat: boolean;
  23478. private _staticDefines;
  23479. /** The direction in which to blur the image. */
  23480. direction: Vector2;
  23481. /**
  23482. * Sets the length in pixels of the blur sample region
  23483. */
  23484. set kernel(v: number);
  23485. /**
  23486. * Gets the length in pixels of the blur sample region
  23487. */
  23488. get kernel(): number;
  23489. /**
  23490. * Sets wether or not the blur needs to unpack/repack floats
  23491. */
  23492. set packedFloat(v: boolean);
  23493. /**
  23494. * Gets wether or not the blur is unpacking/repacking floats
  23495. */
  23496. get packedFloat(): boolean;
  23497. /**
  23498. * Gets a string identifying the name of the class
  23499. * @returns "BlurPostProcess" string
  23500. */
  23501. getClassName(): string;
  23502. /**
  23503. * Creates a new instance BlurPostProcess
  23504. * @param name The name of the effect.
  23505. * @param direction The direction in which to blur the image.
  23506. * @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.
  23507. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23508. * @param camera The camera to apply the render pass to.
  23509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23510. * @param engine The engine which the post process will be applied. (default: current engine)
  23511. * @param reusable If the post process can be reused on the same frame. (default: false)
  23512. * @param textureType Type of textures used when performing the post process. (default: 0)
  23513. * @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)
  23514. */
  23515. 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);
  23516. /**
  23517. * Updates the effect with the current post process compile time values and recompiles the shader.
  23518. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23519. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23520. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23521. * @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
  23522. * @param onCompiled Called when the shader has been compiled.
  23523. * @param onError Called if there is an error when compiling a shader.
  23524. */
  23525. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23526. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23527. /**
  23528. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23529. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23530. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23531. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23532. * The gaps between physical kernels are compensated for in the weighting of the samples
  23533. * @param idealKernel Ideal blur kernel.
  23534. * @return Nearest best kernel.
  23535. */
  23536. protected _nearestBestKernel(idealKernel: number): number;
  23537. /**
  23538. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23539. * @param x The point on the Gaussian distribution to sample.
  23540. * @return the value of the Gaussian function at x.
  23541. */
  23542. protected _gaussianWeight(x: number): number;
  23543. /**
  23544. * Generates a string that can be used as a floating point number in GLSL.
  23545. * @param x Value to print.
  23546. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23547. * @return GLSL float string.
  23548. */
  23549. protected _glslFloat(x: number, decimalFigures?: number): string;
  23550. /** @hidden */
  23551. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23552. }
  23553. }
  23554. declare module BABYLON {
  23555. /**
  23556. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23557. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23558. * You can then easily use it as a reflectionTexture on a flat surface.
  23559. * In case the surface is not a plane, please consider relying on reflection probes.
  23560. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23561. */
  23562. export class MirrorTexture extends RenderTargetTexture {
  23563. private scene;
  23564. /**
  23565. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23566. * 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.
  23567. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23568. */
  23569. mirrorPlane: Plane;
  23570. /**
  23571. * Define the blur ratio used to blur the reflection if needed.
  23572. */
  23573. set blurRatio(value: number);
  23574. get blurRatio(): number;
  23575. /**
  23576. * Define the adaptive blur kernel used to blur the reflection if needed.
  23577. * This will autocompute the closest best match for the `blurKernel`
  23578. */
  23579. set adaptiveBlurKernel(value: number);
  23580. /**
  23581. * Define the blur kernel used to blur the reflection if needed.
  23582. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23583. */
  23584. set blurKernel(value: number);
  23585. /**
  23586. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23588. */
  23589. set blurKernelX(value: number);
  23590. get blurKernelX(): number;
  23591. /**
  23592. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23594. */
  23595. set blurKernelY(value: number);
  23596. get blurKernelY(): number;
  23597. private _autoComputeBlurKernel;
  23598. protected _onRatioRescale(): void;
  23599. private _updateGammaSpace;
  23600. private _imageProcessingConfigChangeObserver;
  23601. private _transformMatrix;
  23602. private _mirrorMatrix;
  23603. private _savedViewMatrix;
  23604. private _blurX;
  23605. private _blurY;
  23606. private _adaptiveBlurKernel;
  23607. private _blurKernelX;
  23608. private _blurKernelY;
  23609. private _blurRatio;
  23610. /**
  23611. * Instantiates a Mirror Texture.
  23612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23614. * You can then easily use it as a reflectionTexture on a flat surface.
  23615. * In case the surface is not a plane, please consider relying on reflection probes.
  23616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23617. * @param name
  23618. * @param size
  23619. * @param scene
  23620. * @param generateMipMaps
  23621. * @param type
  23622. * @param samplingMode
  23623. * @param generateDepthBuffer
  23624. */
  23625. constructor(name: string, size: number | {
  23626. width: number;
  23627. height: number;
  23628. } | {
  23629. ratio: number;
  23630. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23631. private _preparePostProcesses;
  23632. /**
  23633. * Clone the mirror texture.
  23634. * @returns the cloned texture
  23635. */
  23636. clone(): MirrorTexture;
  23637. /**
  23638. * Serialize the texture to a JSON representation you could use in Parse later on
  23639. * @returns the serialized JSON representation
  23640. */
  23641. serialize(): any;
  23642. /**
  23643. * Dispose the texture and release its associated resources.
  23644. */
  23645. dispose(): void;
  23646. }
  23647. }
  23648. declare module BABYLON {
  23649. /**
  23650. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23651. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23652. */
  23653. export class Texture extends BaseTexture {
  23654. /**
  23655. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23656. */
  23657. static SerializeBuffers: boolean;
  23658. /**
  23659. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23660. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23661. */
  23662. static ForceSerializeBuffers: boolean;
  23663. /** @hidden */
  23664. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23665. /** @hidden */
  23666. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23667. /** @hidden */
  23668. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23669. /** nearest is mag = nearest and min = nearest and mip = linear */
  23670. static readonly NEAREST_SAMPLINGMODE: number;
  23671. /** nearest is mag = nearest and min = nearest and mip = linear */
  23672. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23673. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23674. static readonly BILINEAR_SAMPLINGMODE: number;
  23675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23676. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23677. /** Trilinear is mag = linear and min = linear and mip = linear */
  23678. static readonly TRILINEAR_SAMPLINGMODE: number;
  23679. /** Trilinear is mag = linear and min = linear and mip = linear */
  23680. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23681. /** mag = nearest and min = nearest and mip = nearest */
  23682. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23683. /** mag = nearest and min = linear and mip = nearest */
  23684. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23685. /** mag = nearest and min = linear and mip = linear */
  23686. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23687. /** mag = nearest and min = linear and mip = none */
  23688. static readonly NEAREST_LINEAR: number;
  23689. /** mag = nearest and min = nearest and mip = none */
  23690. static readonly NEAREST_NEAREST: number;
  23691. /** mag = linear and min = nearest and mip = nearest */
  23692. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23693. /** mag = linear and min = nearest and mip = linear */
  23694. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23695. /** mag = linear and min = linear and mip = none */
  23696. static readonly LINEAR_LINEAR: number;
  23697. /** mag = linear and min = nearest and mip = none */
  23698. static readonly LINEAR_NEAREST: number;
  23699. /** Explicit coordinates mode */
  23700. static readonly EXPLICIT_MODE: number;
  23701. /** Spherical coordinates mode */
  23702. static readonly SPHERICAL_MODE: number;
  23703. /** Planar coordinates mode */
  23704. static readonly PLANAR_MODE: number;
  23705. /** Cubic coordinates mode */
  23706. static readonly CUBIC_MODE: number;
  23707. /** Projection coordinates mode */
  23708. static readonly PROJECTION_MODE: number;
  23709. /** Inverse Cubic coordinates mode */
  23710. static readonly SKYBOX_MODE: number;
  23711. /** Inverse Cubic coordinates mode */
  23712. static readonly INVCUBIC_MODE: number;
  23713. /** Equirectangular coordinates mode */
  23714. static readonly EQUIRECTANGULAR_MODE: number;
  23715. /** Equirectangular Fixed coordinates mode */
  23716. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23717. /** Equirectangular Fixed Mirrored coordinates mode */
  23718. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23719. /** Texture is not repeating outside of 0..1 UVs */
  23720. static readonly CLAMP_ADDRESSMODE: number;
  23721. /** Texture is repeating outside of 0..1 UVs */
  23722. static readonly WRAP_ADDRESSMODE: number;
  23723. /** Texture is repeating and mirrored */
  23724. static readonly MIRROR_ADDRESSMODE: number;
  23725. /**
  23726. * 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
  23727. */
  23728. static UseSerializedUrlIfAny: boolean;
  23729. /**
  23730. * Define the url of the texture.
  23731. */
  23732. url: Nullable<string>;
  23733. /**
  23734. * Define an offset on the texture to offset the u coordinates of the UVs
  23735. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23736. */
  23737. uOffset: number;
  23738. /**
  23739. * Define an offset on the texture to offset the v coordinates of the UVs
  23740. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23741. */
  23742. vOffset: number;
  23743. /**
  23744. * Define an offset on the texture to scale the u coordinates of the UVs
  23745. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23746. */
  23747. uScale: number;
  23748. /**
  23749. * Define an offset on the texture to scale the v coordinates of the UVs
  23750. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23751. */
  23752. vScale: number;
  23753. /**
  23754. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23755. * @see https://doc.babylonjs.com/how_to/more_materials
  23756. */
  23757. uAng: number;
  23758. /**
  23759. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23760. * @see https://doc.babylonjs.com/how_to/more_materials
  23761. */
  23762. vAng: number;
  23763. /**
  23764. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23765. * @see https://doc.babylonjs.com/how_to/more_materials
  23766. */
  23767. wAng: number;
  23768. /**
  23769. * Defines the center of rotation (U)
  23770. */
  23771. uRotationCenter: number;
  23772. /**
  23773. * Defines the center of rotation (V)
  23774. */
  23775. vRotationCenter: number;
  23776. /**
  23777. * Defines the center of rotation (W)
  23778. */
  23779. wRotationCenter: number;
  23780. /**
  23781. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23782. */
  23783. homogeneousRotationInUVTransform: boolean;
  23784. /**
  23785. * Are mip maps generated for this texture or not.
  23786. */
  23787. get noMipmap(): boolean;
  23788. /**
  23789. * List of inspectable custom properties (used by the Inspector)
  23790. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23791. */
  23792. inspectableCustomProperties: Nullable<IInspectable[]>;
  23793. private _noMipmap;
  23794. /** @hidden */
  23795. _invertY: boolean;
  23796. private _rowGenerationMatrix;
  23797. private _cachedTextureMatrix;
  23798. private _projectionModeMatrix;
  23799. private _t0;
  23800. private _t1;
  23801. private _t2;
  23802. private _cachedUOffset;
  23803. private _cachedVOffset;
  23804. private _cachedUScale;
  23805. private _cachedVScale;
  23806. private _cachedUAng;
  23807. private _cachedVAng;
  23808. private _cachedWAng;
  23809. private _cachedProjectionMatrixId;
  23810. private _cachedURotationCenter;
  23811. private _cachedVRotationCenter;
  23812. private _cachedWRotationCenter;
  23813. private _cachedHomogeneousRotationInUVTransform;
  23814. private _cachedCoordinatesMode;
  23815. /** @hidden */
  23816. protected _initialSamplingMode: number;
  23817. /** @hidden */
  23818. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23819. private _deleteBuffer;
  23820. protected _format: Nullable<number>;
  23821. private _delayedOnLoad;
  23822. private _delayedOnError;
  23823. private _mimeType?;
  23824. private _loaderOptions?;
  23825. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23826. get mimeType(): string | undefined;
  23827. /**
  23828. * Observable triggered once the texture has been loaded.
  23829. */
  23830. onLoadObservable: Observable<Texture>;
  23831. protected _isBlocking: boolean;
  23832. /**
  23833. * Is the texture preventing material to render while loading.
  23834. * If false, a default texture will be used instead of the loading one during the preparation step.
  23835. */
  23836. set isBlocking(value: boolean);
  23837. get isBlocking(): boolean;
  23838. /**
  23839. * Get the current sampling mode associated with the texture.
  23840. */
  23841. get samplingMode(): number;
  23842. /**
  23843. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23844. */
  23845. get invertY(): boolean;
  23846. /**
  23847. * Instantiates a new texture.
  23848. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23849. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23850. * @param url defines the url of the picture to load as a texture
  23851. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23852. * @param noMipmap defines if the texture will require mip maps or not
  23853. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23854. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23855. * @param onLoad defines a callback triggered when the texture has been loaded
  23856. * @param onError defines a callback triggered when an error occurred during the loading session
  23857. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23858. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23859. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23860. * @param mimeType defines an optional mime type information
  23861. * @param loaderOptions options to be passed to the loader
  23862. */
  23863. 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);
  23864. /**
  23865. * Update the url (and optional buffer) of this texture if url was null during construction.
  23866. * @param url the url of the texture
  23867. * @param buffer the buffer of the texture (defaults to null)
  23868. * @param onLoad callback called when the texture is loaded (defaults to null)
  23869. */
  23870. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23871. /**
  23872. * Finish the loading sequence of a texture flagged as delayed load.
  23873. * @hidden
  23874. */
  23875. delayLoad(): void;
  23876. private _prepareRowForTextureGeneration;
  23877. /**
  23878. * Checks if the texture has the same transform matrix than another texture
  23879. * @param texture texture to check against
  23880. * @returns true if the transforms are the same, else false
  23881. */
  23882. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23883. /**
  23884. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23885. * @returns the transform matrix of the texture.
  23886. */
  23887. getTextureMatrix(uBase?: number): Matrix;
  23888. /**
  23889. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23890. * @returns The reflection texture transform
  23891. */
  23892. getReflectionTextureMatrix(): Matrix;
  23893. /**
  23894. * Clones the texture.
  23895. * @returns the cloned texture
  23896. */
  23897. clone(): Texture;
  23898. /**
  23899. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23900. * @returns The JSON representation of the texture
  23901. */
  23902. serialize(): any;
  23903. /**
  23904. * Get the current class name of the texture useful for serialization or dynamic coding.
  23905. * @returns "Texture"
  23906. */
  23907. getClassName(): string;
  23908. /**
  23909. * Dispose the texture and release its associated resources.
  23910. */
  23911. dispose(): void;
  23912. /**
  23913. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23914. * @param parsedTexture Define the JSON representation of the texture
  23915. * @param scene Define the scene the parsed texture should be instantiated in
  23916. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23917. * @returns The parsed texture if successful
  23918. */
  23919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23920. /**
  23921. * Creates a texture from its base 64 representation.
  23922. * @param data Define the base64 payload without the data: prefix
  23923. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23924. * @param scene Define the scene the texture should belong to
  23925. * @param noMipmap Forces the texture to not create mip map information if true
  23926. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23927. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23928. * @param onLoad define a callback triggered when the texture has been loaded
  23929. * @param onError define a callback triggered when an error occurred during the loading session
  23930. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23931. * @returns the created texture
  23932. */
  23933. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23934. /**
  23935. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23936. * @param data Define the base64 payload without the data: prefix
  23937. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23938. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23939. * @param scene Define the scene the texture should belong to
  23940. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23941. * @param noMipmap Forces the texture to not create mip map information if true
  23942. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23943. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23944. * @param onLoad define a callback triggered when the texture has been loaded
  23945. * @param onError define a callback triggered when an error occurred during the loading session
  23946. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23947. * @returns the created texture
  23948. */
  23949. 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;
  23950. }
  23951. }
  23952. declare module BABYLON {
  23953. /**
  23954. * ThinSprite Class used to represent a thin sprite
  23955. * This is the base class for sprites but can also directly be used with ThinEngine
  23956. * @see https://doc.babylonjs.com/babylon101/sprites
  23957. */
  23958. export class ThinSprite {
  23959. /** Gets or sets the cell index in the sprite sheet */
  23960. cellIndex: number;
  23961. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23962. cellRef: string;
  23963. /** Gets or sets the current world position */
  23964. position: IVector3Like;
  23965. /** Gets or sets the main color */
  23966. color: IColor4Like;
  23967. /** Gets or sets the width */
  23968. width: number;
  23969. /** Gets or sets the height */
  23970. height: number;
  23971. /** Gets or sets rotation angle */
  23972. angle: number;
  23973. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23974. invertU: boolean;
  23975. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23976. invertV: boolean;
  23977. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23978. isVisible: boolean;
  23979. /**
  23980. * Returns a boolean indicating if the animation is started
  23981. */
  23982. get animationStarted(): boolean;
  23983. /** Gets the initial key for the animation (setting it will restart the animation) */
  23984. get fromIndex(): number;
  23985. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23986. get toIndex(): number;
  23987. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23988. get loopAnimation(): boolean;
  23989. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23990. get delay(): number;
  23991. /** @hidden */
  23992. _xOffset: number;
  23993. /** @hidden */
  23994. _yOffset: number;
  23995. /** @hidden */
  23996. _xSize: number;
  23997. /** @hidden */
  23998. _ySize: number;
  23999. private _animationStarted;
  24000. protected _loopAnimation: boolean;
  24001. protected _fromIndex: number;
  24002. protected _toIndex: number;
  24003. protected _delay: number;
  24004. private _direction;
  24005. private _time;
  24006. private _onBaseAnimationEnd;
  24007. /**
  24008. * Creates a new Thin Sprite
  24009. */
  24010. constructor();
  24011. /**
  24012. * Starts an animation
  24013. * @param from defines the initial key
  24014. * @param to defines the end key
  24015. * @param loop defines if the animation must loop
  24016. * @param delay defines the start delay (in ms)
  24017. * @param onAnimationEnd defines a callback for when the animation ends
  24018. */
  24019. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24020. /** Stops current animation (if any) */
  24021. stopAnimation(): void;
  24022. /** @hidden */
  24023. _animate(deltaTime: number): void;
  24024. }
  24025. }
  24026. declare module BABYLON {
  24027. /** @hidden */
  24028. export var imageProcessingCompatibility: {
  24029. name: string;
  24030. shader: string;
  24031. };
  24032. }
  24033. declare module BABYLON {
  24034. /** @hidden */
  24035. export var spritesPixelShader: {
  24036. name: string;
  24037. shader: string;
  24038. };
  24039. }
  24040. declare module BABYLON {
  24041. /** @hidden */
  24042. export var spritesVertexShader: {
  24043. name: string;
  24044. shader: string;
  24045. };
  24046. }
  24047. declare module BABYLON {
  24048. /**
  24049. * Class used to render sprites.
  24050. *
  24051. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24052. */
  24053. export class SpriteRenderer {
  24054. /**
  24055. * Defines the texture of the spritesheet
  24056. */
  24057. texture: Nullable<ThinTexture>;
  24058. /**
  24059. * Defines the default width of a cell in the spritesheet
  24060. */
  24061. cellWidth: number;
  24062. /**
  24063. * Defines the default height of a cell in the spritesheet
  24064. */
  24065. cellHeight: number;
  24066. /**
  24067. * Blend mode use to render the particle, it can be any of
  24068. * the static Constants.ALPHA_x properties provided in this class.
  24069. * Default value is Constants.ALPHA_COMBINE
  24070. */
  24071. blendMode: number;
  24072. /**
  24073. * Gets or sets a boolean indicating if alpha mode is automatically
  24074. * reset.
  24075. */
  24076. autoResetAlpha: boolean;
  24077. /**
  24078. * Disables writing to the depth buffer when rendering the sprites.
  24079. * It can be handy to disable depth writing when using textures without alpha channel
  24080. * and setting some specific blend modes.
  24081. */
  24082. disableDepthWrite: boolean;
  24083. /**
  24084. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24085. */
  24086. fogEnabled: boolean;
  24087. /**
  24088. * Gets the capacity of the manager
  24089. */
  24090. get capacity(): number;
  24091. private readonly _engine;
  24092. private readonly _useVAO;
  24093. private readonly _useInstancing;
  24094. private readonly _scene;
  24095. private readonly _capacity;
  24096. private readonly _epsilon;
  24097. private _vertexBufferSize;
  24098. private _vertexData;
  24099. private _buffer;
  24100. private _vertexBuffers;
  24101. private _spriteBuffer;
  24102. private _indexBuffer;
  24103. private _effectBase;
  24104. private _effectFog;
  24105. private _vertexArrayObject;
  24106. /**
  24107. * Creates a new sprite Renderer
  24108. * @param engine defines the engine the renderer works with
  24109. * @param capacity defines the maximum allowed number of sprites
  24110. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24111. * @param scene defines the hosting scene
  24112. */
  24113. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24114. /**
  24115. * Render all child sprites
  24116. * @param sprites defines the list of sprites to render
  24117. * @param deltaTime defines the time since last frame
  24118. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24119. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24120. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24121. */
  24122. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24123. private _appendSpriteVertex;
  24124. /**
  24125. * Release associated resources
  24126. */
  24127. dispose(): void;
  24128. }
  24129. }
  24130. declare module BABYLON {
  24131. /**
  24132. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24133. */
  24134. export interface ISpriteManager extends IDisposable {
  24135. /**
  24136. * Gets manager's name
  24137. */
  24138. name: string;
  24139. /**
  24140. * Restricts the camera to viewing objects with the same layerMask.
  24141. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24142. */
  24143. layerMask: number;
  24144. /**
  24145. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24146. */
  24147. isPickable: boolean;
  24148. /**
  24149. * Gets the hosting scene
  24150. */
  24151. scene: Scene;
  24152. /**
  24153. * Specifies the rendering group id for this mesh (0 by default)
  24154. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24155. */
  24156. renderingGroupId: number;
  24157. /**
  24158. * Defines the list of sprites managed by the manager.
  24159. */
  24160. sprites: Array<Sprite>;
  24161. /**
  24162. * Gets or sets the spritesheet texture
  24163. */
  24164. texture: Texture;
  24165. /** Defines the default width of a cell in the spritesheet */
  24166. cellWidth: number;
  24167. /** Defines the default height of a cell in the spritesheet */
  24168. cellHeight: number;
  24169. /**
  24170. * Tests the intersection of a sprite with a specific ray.
  24171. * @param ray The ray we are sending to test the collision
  24172. * @param camera The camera space we are sending rays in
  24173. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24174. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24175. * @returns picking info or null.
  24176. */
  24177. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24178. /**
  24179. * Intersects the sprites with a ray
  24180. * @param ray defines the ray to intersect with
  24181. * @param camera defines the current active camera
  24182. * @param predicate defines a predicate used to select candidate sprites
  24183. * @returns null if no hit or a PickingInfo array
  24184. */
  24185. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24186. /**
  24187. * Renders the list of sprites on screen.
  24188. */
  24189. render(): void;
  24190. }
  24191. /**
  24192. * Class used to manage multiple sprites on the same spritesheet
  24193. * @see https://doc.babylonjs.com/babylon101/sprites
  24194. */
  24195. export class SpriteManager implements ISpriteManager {
  24196. /** defines the manager's name */
  24197. name: string;
  24198. /** Define the Url to load snippets */
  24199. static SnippetUrl: string;
  24200. /** Snippet ID if the manager was created from the snippet server */
  24201. snippetId: string;
  24202. /** Gets the list of sprites */
  24203. sprites: Sprite[];
  24204. /** Gets or sets the rendering group id (0 by default) */
  24205. renderingGroupId: number;
  24206. /** Gets or sets camera layer mask */
  24207. layerMask: number;
  24208. /** Gets or sets a boolean indicating if the sprites are pickable */
  24209. isPickable: boolean;
  24210. /**
  24211. * An event triggered when the manager is disposed.
  24212. */
  24213. onDisposeObservable: Observable<SpriteManager>;
  24214. /**
  24215. * Callback called when the manager is disposed
  24216. */
  24217. set onDispose(callback: () => void);
  24218. /**
  24219. * Gets or sets the unique id of the sprite
  24220. */
  24221. uniqueId: number;
  24222. /**
  24223. * Gets the array of sprites
  24224. */
  24225. get children(): Sprite[];
  24226. /**
  24227. * Gets the hosting scene
  24228. */
  24229. get scene(): Scene;
  24230. /**
  24231. * Gets the capacity of the manager
  24232. */
  24233. get capacity(): number;
  24234. /**
  24235. * Gets or sets the spritesheet texture
  24236. */
  24237. get texture(): Texture;
  24238. set texture(value: Texture);
  24239. /** Defines the default width of a cell in the spritesheet */
  24240. get cellWidth(): number;
  24241. set cellWidth(value: number);
  24242. /** Defines the default height of a cell in the spritesheet */
  24243. get cellHeight(): number;
  24244. set cellHeight(value: number);
  24245. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24246. get fogEnabled(): boolean;
  24247. set fogEnabled(value: boolean);
  24248. /**
  24249. * Blend mode use to render the particle, it can be any of
  24250. * the static Constants.ALPHA_x properties provided in this class.
  24251. * Default value is Constants.ALPHA_COMBINE
  24252. */
  24253. get blendMode(): number;
  24254. set blendMode(blendMode: number);
  24255. /** Disables writing to the depth buffer when rendering the sprites.
  24256. * It can be handy to disable depth writing when using textures without alpha channel
  24257. * and setting some specific blend modes.
  24258. */
  24259. disableDepthWrite: boolean;
  24260. private _spriteRenderer;
  24261. /** Associative array from JSON sprite data file */
  24262. private _cellData;
  24263. /** Array of sprite names from JSON sprite data file */
  24264. private _spriteMap;
  24265. /** True when packed cell data from JSON file is ready*/
  24266. private _packedAndReady;
  24267. private _textureContent;
  24268. private _onDisposeObserver;
  24269. private _fromPacked;
  24270. private _scene;
  24271. /**
  24272. * Creates a new sprite manager
  24273. * @param name defines the manager's name
  24274. * @param imgUrl defines the sprite sheet url
  24275. * @param capacity defines the maximum allowed number of sprites
  24276. * @param cellSize defines the size of a sprite cell
  24277. * @param scene defines the hosting scene
  24278. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24279. * @param samplingMode defines the smapling mode to use with spritesheet
  24280. * @param fromPacked set to false; do not alter
  24281. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24282. */
  24283. constructor(
  24284. /** defines the manager's name */
  24285. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24286. /**
  24287. * Returns the string "SpriteManager"
  24288. * @returns "SpriteManager"
  24289. */
  24290. getClassName(): string;
  24291. private _makePacked;
  24292. private _checkTextureAlpha;
  24293. /**
  24294. * Intersects the sprites with a ray
  24295. * @param ray defines the ray to intersect with
  24296. * @param camera defines the current active camera
  24297. * @param predicate defines a predicate used to select candidate sprites
  24298. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24299. * @returns null if no hit or a PickingInfo
  24300. */
  24301. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24302. /**
  24303. * Intersects the sprites with a ray
  24304. * @param ray defines the ray to intersect with
  24305. * @param camera defines the current active camera
  24306. * @param predicate defines a predicate used to select candidate sprites
  24307. * @returns null if no hit or a PickingInfo array
  24308. */
  24309. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24310. /**
  24311. * Render all child sprites
  24312. */
  24313. render(): void;
  24314. private _customUpdate;
  24315. /**
  24316. * Release associated resources
  24317. */
  24318. dispose(): void;
  24319. /**
  24320. * Serializes the sprite manager to a JSON object
  24321. * @param serializeTexture defines if the texture must be serialized as well
  24322. * @returns the JSON object
  24323. */
  24324. serialize(serializeTexture?: boolean): any;
  24325. /**
  24326. * Parses a JSON object to create a new sprite manager.
  24327. * @param parsedManager The JSON object to parse
  24328. * @param scene The scene to create the sprite managerin
  24329. * @param rootUrl The root url to use to load external dependencies like texture
  24330. * @returns the new sprite manager
  24331. */
  24332. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24333. /**
  24334. * Creates a sprite manager from a snippet saved in a remote file
  24335. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24336. * @param url defines the url to load from
  24337. * @param scene defines the hosting scene
  24338. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24339. * @returns a promise that will resolve to the new sprite manager
  24340. */
  24341. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24342. /**
  24343. * Creates a sprite manager from a snippet saved by the sprite editor
  24344. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24345. * @param scene defines the hosting scene
  24346. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24347. * @returns a promise that will resolve to the new sprite manager
  24348. */
  24349. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24350. }
  24351. }
  24352. declare module BABYLON {
  24353. /**
  24354. * Class used to represent a sprite
  24355. * @see https://doc.babylonjs.com/babylon101/sprites
  24356. */
  24357. export class Sprite extends ThinSprite implements IAnimatable {
  24358. /** defines the name */
  24359. name: string;
  24360. /** Gets or sets the current world position */
  24361. position: Vector3;
  24362. /** Gets or sets the main color */
  24363. color: Color4;
  24364. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24365. disposeWhenFinishedAnimating: boolean;
  24366. /** Gets the list of attached animations */
  24367. animations: Nullable<Array<Animation>>;
  24368. /** Gets or sets a boolean indicating if the sprite can be picked */
  24369. isPickable: boolean;
  24370. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24371. useAlphaForPicking: boolean;
  24372. /**
  24373. * Gets or sets the associated action manager
  24374. */
  24375. actionManager: Nullable<ActionManager>;
  24376. /**
  24377. * An event triggered when the control has been disposed
  24378. */
  24379. onDisposeObservable: Observable<Sprite>;
  24380. private _manager;
  24381. private _onAnimationEnd;
  24382. /**
  24383. * Gets or sets the sprite size
  24384. */
  24385. get size(): number;
  24386. set size(value: number);
  24387. /**
  24388. * Gets or sets the unique id of the sprite
  24389. */
  24390. uniqueId: number;
  24391. /**
  24392. * Gets the manager of this sprite
  24393. */
  24394. get manager(): ISpriteManager;
  24395. /**
  24396. * Creates a new Sprite
  24397. * @param name defines the name
  24398. * @param manager defines the manager
  24399. */
  24400. constructor(
  24401. /** defines the name */
  24402. name: string, manager: ISpriteManager);
  24403. /**
  24404. * Returns the string "Sprite"
  24405. * @returns "Sprite"
  24406. */
  24407. getClassName(): string;
  24408. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24409. get fromIndex(): number;
  24410. set fromIndex(value: number);
  24411. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24412. get toIndex(): number;
  24413. set toIndex(value: number);
  24414. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24415. get loopAnimation(): boolean;
  24416. set loopAnimation(value: boolean);
  24417. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24418. get delay(): number;
  24419. set delay(value: number);
  24420. /**
  24421. * Starts an animation
  24422. * @param from defines the initial key
  24423. * @param to defines the end key
  24424. * @param loop defines if the animation must loop
  24425. * @param delay defines the start delay (in ms)
  24426. * @param onAnimationEnd defines a callback to call when animation ends
  24427. */
  24428. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24429. private _endAnimation;
  24430. /** Release associated resources */
  24431. dispose(): void;
  24432. /**
  24433. * Serializes the sprite to a JSON object
  24434. * @returns the JSON object
  24435. */
  24436. serialize(): any;
  24437. /**
  24438. * Parses a JSON object to create a new sprite
  24439. * @param parsedSprite The JSON object to parse
  24440. * @param manager defines the hosting manager
  24441. * @returns the new sprite
  24442. */
  24443. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24444. }
  24445. }
  24446. declare module BABYLON {
  24447. /**
  24448. * Information about the result of picking within a scene
  24449. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24450. */
  24451. export class PickingInfo {
  24452. /** @hidden */
  24453. _pickingUnavailable: boolean;
  24454. /**
  24455. * If the pick collided with an object
  24456. */
  24457. hit: boolean;
  24458. /**
  24459. * Distance away where the pick collided
  24460. */
  24461. distance: number;
  24462. /**
  24463. * The location of pick collision
  24464. */
  24465. pickedPoint: Nullable<Vector3>;
  24466. /**
  24467. * The mesh corresponding the the pick collision
  24468. */
  24469. pickedMesh: Nullable<AbstractMesh>;
  24470. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24471. bu: number;
  24472. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24473. bv: number;
  24474. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24475. faceId: number;
  24476. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24477. subMeshFaceId: number;
  24478. /** Id of the the submesh that was picked */
  24479. subMeshId: number;
  24480. /** If a sprite was picked, this will be the sprite the pick collided with */
  24481. pickedSprite: Nullable<Sprite>;
  24482. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24483. thinInstanceIndex: number;
  24484. /**
  24485. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24486. */
  24487. originMesh: Nullable<AbstractMesh>;
  24488. /**
  24489. * The ray that was used to perform the picking.
  24490. */
  24491. ray: Nullable<Ray>;
  24492. /**
  24493. * Gets the normal correspodning to the face the pick collided with
  24494. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24495. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24496. * @returns The normal correspodning to the face the pick collided with
  24497. */
  24498. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24499. /**
  24500. * Gets the texture coordinates of where the pick occured
  24501. * @returns the vector containing the coordnates of the texture
  24502. */
  24503. getTextureCoordinates(): Nullable<Vector2>;
  24504. }
  24505. }
  24506. declare module BABYLON {
  24507. /**
  24508. * Gather the list of pointer event types as constants.
  24509. */
  24510. export class PointerEventTypes {
  24511. /**
  24512. * 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.
  24513. */
  24514. static readonly POINTERDOWN: number;
  24515. /**
  24516. * The pointerup event is fired when a pointer is no longer active.
  24517. */
  24518. static readonly POINTERUP: number;
  24519. /**
  24520. * The pointermove event is fired when a pointer changes coordinates.
  24521. */
  24522. static readonly POINTERMOVE: number;
  24523. /**
  24524. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24525. */
  24526. static readonly POINTERWHEEL: number;
  24527. /**
  24528. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24529. */
  24530. static readonly POINTERPICK: number;
  24531. /**
  24532. * The pointertap event is fired when a the object has been touched and released without drag.
  24533. */
  24534. static readonly POINTERTAP: number;
  24535. /**
  24536. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24537. */
  24538. static readonly POINTERDOUBLETAP: number;
  24539. }
  24540. /**
  24541. * Base class of pointer info types.
  24542. */
  24543. export class PointerInfoBase {
  24544. /**
  24545. * Defines the type of event (PointerEventTypes)
  24546. */
  24547. type: number;
  24548. /**
  24549. * Defines the related dom event
  24550. */
  24551. event: PointerEvent | MouseWheelEvent;
  24552. /**
  24553. * Instantiates the base class of pointers info.
  24554. * @param type Defines the type of event (PointerEventTypes)
  24555. * @param event Defines the related dom event
  24556. */
  24557. constructor(
  24558. /**
  24559. * Defines the type of event (PointerEventTypes)
  24560. */
  24561. type: number,
  24562. /**
  24563. * Defines the related dom event
  24564. */
  24565. event: PointerEvent | MouseWheelEvent);
  24566. }
  24567. /**
  24568. * This class is used to store pointer related info for the onPrePointerObservable event.
  24569. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24570. */
  24571. export class PointerInfoPre extends PointerInfoBase {
  24572. /**
  24573. * Ray from a pointer if availible (eg. 6dof controller)
  24574. */
  24575. ray: Nullable<Ray>;
  24576. /**
  24577. * Defines the local position of the pointer on the canvas.
  24578. */
  24579. localPosition: Vector2;
  24580. /**
  24581. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24582. */
  24583. skipOnPointerObservable: boolean;
  24584. /**
  24585. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24586. * @param type Defines the type of event (PointerEventTypes)
  24587. * @param event Defines the related dom event
  24588. * @param localX Defines the local x coordinates of the pointer when the event occured
  24589. * @param localY Defines the local y coordinates of the pointer when the event occured
  24590. */
  24591. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24592. }
  24593. /**
  24594. * This type contains all the data related to a pointer event in Babylon.js.
  24595. * 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.
  24596. */
  24597. export class PointerInfo extends PointerInfoBase {
  24598. /**
  24599. * Defines the picking info associated to the info (if any)\
  24600. */
  24601. pickInfo: Nullable<PickingInfo>;
  24602. /**
  24603. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24604. * @param type Defines the type of event (PointerEventTypes)
  24605. * @param event Defines the related dom event
  24606. * @param pickInfo Defines the picking info associated to the info (if any)\
  24607. */
  24608. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24609. /**
  24610. * Defines the picking info associated to the info (if any)\
  24611. */
  24612. pickInfo: Nullable<PickingInfo>);
  24613. }
  24614. /**
  24615. * Data relating to a touch event on the screen.
  24616. */
  24617. export interface PointerTouch {
  24618. /**
  24619. * X coordinate of touch.
  24620. */
  24621. x: number;
  24622. /**
  24623. * Y coordinate of touch.
  24624. */
  24625. y: number;
  24626. /**
  24627. * Id of touch. Unique for each finger.
  24628. */
  24629. pointerId: number;
  24630. /**
  24631. * Event type passed from DOM.
  24632. */
  24633. type: any;
  24634. }
  24635. }
  24636. declare module BABYLON {
  24637. /**
  24638. * Manage the mouse inputs to control the movement of a free camera.
  24639. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24640. */
  24641. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24642. /**
  24643. * Define if touch is enabled in the mouse input
  24644. */
  24645. touchEnabled: boolean;
  24646. /**
  24647. * Defines the camera the input is attached to.
  24648. */
  24649. camera: FreeCamera;
  24650. /**
  24651. * Defines the buttons associated with the input to handle camera move.
  24652. */
  24653. buttons: number[];
  24654. /**
  24655. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24656. */
  24657. angularSensibility: number;
  24658. private _pointerInput;
  24659. private _onMouseMove;
  24660. private _observer;
  24661. private previousPosition;
  24662. /**
  24663. * Observable for when a pointer move event occurs containing the move offset
  24664. */
  24665. onPointerMovedObservable: Observable<{
  24666. offsetX: number;
  24667. offsetY: number;
  24668. }>;
  24669. /**
  24670. * @hidden
  24671. * If the camera should be rotated automatically based on pointer movement
  24672. */
  24673. _allowCameraRotation: boolean;
  24674. /**
  24675. * Manage the mouse inputs to control the movement of a free camera.
  24676. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24677. * @param touchEnabled Defines if touch is enabled or not
  24678. */
  24679. constructor(
  24680. /**
  24681. * Define if touch is enabled in the mouse input
  24682. */
  24683. touchEnabled?: boolean);
  24684. /**
  24685. * Attach the input controls to a specific dom element to get the input from.
  24686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24687. */
  24688. attachControl(noPreventDefault?: boolean): void;
  24689. /**
  24690. * Called on JS contextmenu event.
  24691. * Override this method to provide functionality.
  24692. */
  24693. protected onContextMenu(evt: PointerEvent): void;
  24694. /**
  24695. * Detach the current controls from the specified dom element.
  24696. */
  24697. detachControl(): void;
  24698. /**
  24699. * Gets the class name of the current intput.
  24700. * @returns the class name
  24701. */
  24702. getClassName(): string;
  24703. /**
  24704. * Get the friendly name associated with the input class.
  24705. * @returns the input friendly name
  24706. */
  24707. getSimpleName(): string;
  24708. }
  24709. }
  24710. declare module BABYLON {
  24711. /**
  24712. * Base class for mouse wheel input..
  24713. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24714. * for example usage.
  24715. */
  24716. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24717. /**
  24718. * Defines the camera the input is attached to.
  24719. */
  24720. abstract camera: Camera;
  24721. /**
  24722. * How fast is the camera moves in relation to X axis mouseWheel events.
  24723. * Use negative value to reverse direction.
  24724. */
  24725. wheelPrecisionX: number;
  24726. /**
  24727. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24728. * Use negative value to reverse direction.
  24729. */
  24730. wheelPrecisionY: number;
  24731. /**
  24732. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24733. * Use negative value to reverse direction.
  24734. */
  24735. wheelPrecisionZ: number;
  24736. /**
  24737. * Observable for when a mouse wheel move event occurs.
  24738. */
  24739. onChangedObservable: Observable<{
  24740. wheelDeltaX: number;
  24741. wheelDeltaY: number;
  24742. wheelDeltaZ: number;
  24743. }>;
  24744. private _wheel;
  24745. private _observer;
  24746. /**
  24747. * Attach the input controls to a specific dom element to get the input from.
  24748. * @param noPreventDefault Defines whether event caught by the controls
  24749. * should call preventdefault().
  24750. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24751. */
  24752. attachControl(noPreventDefault?: boolean): void;
  24753. /**
  24754. * Detach the current controls from the specified dom element.
  24755. */
  24756. detachControl(): void;
  24757. /**
  24758. * Called for each rendered frame.
  24759. */
  24760. checkInputs(): void;
  24761. /**
  24762. * Gets the class name of the current intput.
  24763. * @returns the class name
  24764. */
  24765. getClassName(): string;
  24766. /**
  24767. * Get the friendly name associated with the input class.
  24768. * @returns the input friendly name
  24769. */
  24770. getSimpleName(): string;
  24771. /**
  24772. * Incremental value of multiple mouse wheel movements of the X axis.
  24773. * Should be zero-ed when read.
  24774. */
  24775. protected _wheelDeltaX: number;
  24776. /**
  24777. * Incremental value of multiple mouse wheel movements of the Y axis.
  24778. * Should be zero-ed when read.
  24779. */
  24780. protected _wheelDeltaY: number;
  24781. /**
  24782. * Incremental value of multiple mouse wheel movements of the Z axis.
  24783. * Should be zero-ed when read.
  24784. */
  24785. protected _wheelDeltaZ: number;
  24786. /**
  24787. * Firefox uses a different scheme to report scroll distances to other
  24788. * browsers. Rather than use complicated methods to calculate the exact
  24789. * multiple we need to apply, let's just cheat and use a constant.
  24790. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24791. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24792. */
  24793. private readonly _ffMultiplier;
  24794. /**
  24795. * Different event attributes for wheel data fall into a few set ranges.
  24796. * Some relevant but dated date here:
  24797. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24798. */
  24799. private readonly _normalize;
  24800. }
  24801. }
  24802. declare module BABYLON {
  24803. /**
  24804. * Manage the mouse wheel inputs to control a free camera.
  24805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24806. */
  24807. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24808. /**
  24809. * Defines the camera the input is attached to.
  24810. */
  24811. camera: FreeCamera;
  24812. /**
  24813. * Gets the class name of the current input.
  24814. * @returns the class name
  24815. */
  24816. getClassName(): string;
  24817. /**
  24818. * Set which movement axis (relative to camera's orientation) the mouse
  24819. * wheel's X axis controls.
  24820. * @param axis The axis to be moved. Set null to clear.
  24821. */
  24822. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24823. /**
  24824. * Get the configured movement axis (relative to camera's orientation) the
  24825. * mouse wheel's X axis controls.
  24826. * @returns The configured axis or null if none.
  24827. */
  24828. get wheelXMoveRelative(): Nullable<Coordinate>;
  24829. /**
  24830. * Set which movement axis (relative to camera's orientation) the mouse
  24831. * wheel's Y axis controls.
  24832. * @param axis The axis to be moved. Set null to clear.
  24833. */
  24834. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24835. /**
  24836. * Get the configured movement axis (relative to camera's orientation) the
  24837. * mouse wheel's Y axis controls.
  24838. * @returns The configured axis or null if none.
  24839. */
  24840. get wheelYMoveRelative(): Nullable<Coordinate>;
  24841. /**
  24842. * Set which movement axis (relative to camera's orientation) the mouse
  24843. * wheel's Z axis controls.
  24844. * @param axis The axis to be moved. Set null to clear.
  24845. */
  24846. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24847. /**
  24848. * Get the configured movement axis (relative to camera's orientation) the
  24849. * mouse wheel's Z axis controls.
  24850. * @returns The configured axis or null if none.
  24851. */
  24852. get wheelZMoveRelative(): Nullable<Coordinate>;
  24853. /**
  24854. * Set which rotation axis (relative to camera's orientation) the mouse
  24855. * wheel's X axis controls.
  24856. * @param axis The axis to be moved. Set null to clear.
  24857. */
  24858. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24859. /**
  24860. * Get the configured rotation axis (relative to camera's orientation) the
  24861. * mouse wheel's X axis controls.
  24862. * @returns The configured axis or null if none.
  24863. */
  24864. get wheelXRotateRelative(): Nullable<Coordinate>;
  24865. /**
  24866. * Set which rotation axis (relative to camera's orientation) the mouse
  24867. * wheel's Y axis controls.
  24868. * @param axis The axis to be moved. Set null to clear.
  24869. */
  24870. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24871. /**
  24872. * Get the configured rotation axis (relative to camera's orientation) the
  24873. * mouse wheel's Y axis controls.
  24874. * @returns The configured axis or null if none.
  24875. */
  24876. get wheelYRotateRelative(): Nullable<Coordinate>;
  24877. /**
  24878. * Set which rotation axis (relative to camera's orientation) the mouse
  24879. * wheel's Z axis controls.
  24880. * @param axis The axis to be moved. Set null to clear.
  24881. */
  24882. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24883. /**
  24884. * Get the configured rotation axis (relative to camera's orientation) the
  24885. * mouse wheel's Z axis controls.
  24886. * @returns The configured axis or null if none.
  24887. */
  24888. get wheelZRotateRelative(): Nullable<Coordinate>;
  24889. /**
  24890. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24891. * controls.
  24892. * @param axis The axis to be moved. Set null to clear.
  24893. */
  24894. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24895. /**
  24896. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24897. * X axis controls.
  24898. * @returns The configured axis or null if none.
  24899. */
  24900. get wheelXMoveScene(): Nullable<Coordinate>;
  24901. /**
  24902. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24903. * controls.
  24904. * @param axis The axis to be moved. Set null to clear.
  24905. */
  24906. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24907. /**
  24908. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24909. * Y axis controls.
  24910. * @returns The configured axis or null if none.
  24911. */
  24912. get wheelYMoveScene(): Nullable<Coordinate>;
  24913. /**
  24914. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24915. * controls.
  24916. * @param axis The axis to be moved. Set null to clear.
  24917. */
  24918. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24919. /**
  24920. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24921. * Z axis controls.
  24922. * @returns The configured axis or null if none.
  24923. */
  24924. get wheelZMoveScene(): Nullable<Coordinate>;
  24925. /**
  24926. * Called for each rendered frame.
  24927. */
  24928. checkInputs(): void;
  24929. private _moveRelative;
  24930. private _rotateRelative;
  24931. private _moveScene;
  24932. /**
  24933. * These are set to the desired default behaviour.
  24934. */
  24935. private _wheelXAction;
  24936. private _wheelXActionCoordinate;
  24937. private _wheelYAction;
  24938. private _wheelYActionCoordinate;
  24939. private _wheelZAction;
  24940. private _wheelZActionCoordinate;
  24941. /**
  24942. * Update the camera according to any configured properties for the 3
  24943. * mouse-wheel axis.
  24944. */
  24945. private _updateCamera;
  24946. /**
  24947. * Update one property of the camera.
  24948. */
  24949. private _updateCameraProperty;
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * Manage the touch inputs to control the movement of a free camera.
  24955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24956. */
  24957. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24958. /**
  24959. * Define if mouse events can be treated as touch events
  24960. */
  24961. allowMouse: boolean;
  24962. /**
  24963. * Defines the camera the input is attached to.
  24964. */
  24965. camera: FreeCamera;
  24966. /**
  24967. * Defines the touch sensibility for rotation.
  24968. * The higher the faster.
  24969. */
  24970. touchAngularSensibility: number;
  24971. /**
  24972. * Defines the touch sensibility for move.
  24973. * The higher the faster.
  24974. */
  24975. touchMoveSensibility: number;
  24976. private _offsetX;
  24977. private _offsetY;
  24978. private _pointerPressed;
  24979. private _pointerInput?;
  24980. private _observer;
  24981. private _onLostFocus;
  24982. /**
  24983. * Manage the touch inputs to control the movement of a free camera.
  24984. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24985. * @param allowMouse Defines if mouse events can be treated as touch events
  24986. */
  24987. constructor(
  24988. /**
  24989. * Define if mouse events can be treated as touch events
  24990. */
  24991. allowMouse?: boolean);
  24992. /**
  24993. * Attach the input controls to a specific dom element to get the input from.
  24994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24995. */
  24996. attachControl(noPreventDefault?: boolean): void;
  24997. /**
  24998. * Detach the current controls from the specified dom element.
  24999. */
  25000. detachControl(): void;
  25001. /**
  25002. * Update the current camera state depending on the inputs that have been used this frame.
  25003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25004. */
  25005. checkInputs(): void;
  25006. /**
  25007. * Gets the class name of the current intput.
  25008. * @returns the class name
  25009. */
  25010. getClassName(): string;
  25011. /**
  25012. * Get the friendly name associated with the input class.
  25013. * @returns the input friendly name
  25014. */
  25015. getSimpleName(): string;
  25016. }
  25017. }
  25018. declare module BABYLON {
  25019. /**
  25020. * Default Inputs manager for the FreeCamera.
  25021. * It groups all the default supported inputs for ease of use.
  25022. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25023. */
  25024. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25025. /**
  25026. * @hidden
  25027. */
  25028. _mouseInput: Nullable<FreeCameraMouseInput>;
  25029. /**
  25030. * @hidden
  25031. */
  25032. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25033. /**
  25034. * Instantiates a new FreeCameraInputsManager.
  25035. * @param camera Defines the camera the inputs belong to
  25036. */
  25037. constructor(camera: FreeCamera);
  25038. /**
  25039. * Add keyboard input support to the input manager.
  25040. * @returns the current input manager
  25041. */
  25042. addKeyboard(): FreeCameraInputsManager;
  25043. /**
  25044. * Add mouse input support to the input manager.
  25045. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25046. * @returns the current input manager
  25047. */
  25048. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25049. /**
  25050. * Removes the mouse input support from the manager
  25051. * @returns the current input manager
  25052. */
  25053. removeMouse(): FreeCameraInputsManager;
  25054. /**
  25055. * Add mouse wheel input support to the input manager.
  25056. * @returns the current input manager
  25057. */
  25058. addMouseWheel(): FreeCameraInputsManager;
  25059. /**
  25060. * Removes the mouse wheel input support from the manager
  25061. * @returns the current input manager
  25062. */
  25063. removeMouseWheel(): FreeCameraInputsManager;
  25064. /**
  25065. * Add touch input support to the input manager.
  25066. * @returns the current input manager
  25067. */
  25068. addTouch(): FreeCameraInputsManager;
  25069. /**
  25070. * Remove all attached input methods from a camera
  25071. */
  25072. clear(): void;
  25073. }
  25074. }
  25075. declare module BABYLON {
  25076. /**
  25077. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25078. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25079. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25080. */
  25081. export class FreeCamera extends TargetCamera {
  25082. /**
  25083. * Define the collision ellipsoid of the camera.
  25084. * This is helpful to simulate a camera body like the player body around the camera
  25085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25086. */
  25087. ellipsoid: Vector3;
  25088. /**
  25089. * Define an offset for the position of the ellipsoid around the camera.
  25090. * This can be helpful to determine the center of the body near the gravity center of the body
  25091. * instead of its head.
  25092. */
  25093. ellipsoidOffset: Vector3;
  25094. /**
  25095. * Enable or disable collisions of the camera with the rest of the scene objects.
  25096. */
  25097. checkCollisions: boolean;
  25098. /**
  25099. * Enable or disable gravity on the camera.
  25100. */
  25101. applyGravity: boolean;
  25102. /**
  25103. * Define the input manager associated to the camera.
  25104. */
  25105. inputs: FreeCameraInputsManager;
  25106. /**
  25107. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25108. * Higher values reduce sensitivity.
  25109. */
  25110. get angularSensibility(): number;
  25111. /**
  25112. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25113. * Higher values reduce sensitivity.
  25114. */
  25115. set angularSensibility(value: number);
  25116. /**
  25117. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25118. */
  25119. get keysUp(): number[];
  25120. set keysUp(value: number[]);
  25121. /**
  25122. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25123. */
  25124. get keysUpward(): number[];
  25125. set keysUpward(value: number[]);
  25126. /**
  25127. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25128. */
  25129. get keysDown(): number[];
  25130. set keysDown(value: number[]);
  25131. /**
  25132. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25133. */
  25134. get keysDownward(): number[];
  25135. set keysDownward(value: number[]);
  25136. /**
  25137. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25138. */
  25139. get keysLeft(): number[];
  25140. set keysLeft(value: number[]);
  25141. /**
  25142. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25143. */
  25144. get keysRight(): number[];
  25145. set keysRight(value: number[]);
  25146. /**
  25147. * Event raised when the camera collide with a mesh in the scene.
  25148. */
  25149. onCollide: (collidedMesh: AbstractMesh) => void;
  25150. private _collider;
  25151. private _needMoveForGravity;
  25152. private _oldPosition;
  25153. private _diffPosition;
  25154. private _newPosition;
  25155. /** @hidden */
  25156. _localDirection: Vector3;
  25157. /** @hidden */
  25158. _transformedDirection: Vector3;
  25159. /**
  25160. * Instantiates a Free Camera.
  25161. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25162. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25163. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25164. * @param name Define the name of the camera in the scene
  25165. * @param position Define the start position of the camera in the scene
  25166. * @param scene Define the scene the camera belongs to
  25167. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25168. */
  25169. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25170. /**
  25171. * Attach the input controls to a specific dom element to get the input from.
  25172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25173. */
  25174. attachControl(noPreventDefault?: boolean): void;
  25175. /**
  25176. * Attach the input controls to a specific dom element to get the input from.
  25177. * @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
  25178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25179. * BACK COMPAT SIGNATURE ONLY.
  25180. */
  25181. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25182. /**
  25183. * Detach the current controls from the specified dom element.
  25184. */
  25185. detachControl(): void;
  25186. /**
  25187. * Detach the current controls from the specified dom element.
  25188. * @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
  25189. */
  25190. detachControl(ignored: any): void;
  25191. private _collisionMask;
  25192. /**
  25193. * Define a collision mask to limit the list of object the camera can collide with
  25194. */
  25195. get collisionMask(): number;
  25196. set collisionMask(mask: number);
  25197. /** @hidden */
  25198. _collideWithWorld(displacement: Vector3): void;
  25199. private _onCollisionPositionChange;
  25200. /** @hidden */
  25201. _checkInputs(): void;
  25202. /** @hidden */
  25203. _decideIfNeedsToMove(): boolean;
  25204. /** @hidden */
  25205. _updatePosition(): void;
  25206. /**
  25207. * Destroy the camera and release the current resources hold by it.
  25208. */
  25209. dispose(): void;
  25210. /**
  25211. * Gets the current object class name.
  25212. * @return the class name
  25213. */
  25214. getClassName(): string;
  25215. }
  25216. }
  25217. declare module BABYLON {
  25218. /**
  25219. * Represents a gamepad control stick position
  25220. */
  25221. export class StickValues {
  25222. /**
  25223. * The x component of the control stick
  25224. */
  25225. x: number;
  25226. /**
  25227. * The y component of the control stick
  25228. */
  25229. y: number;
  25230. /**
  25231. * Initializes the gamepad x and y control stick values
  25232. * @param x The x component of the gamepad control stick value
  25233. * @param y The y component of the gamepad control stick value
  25234. */
  25235. constructor(
  25236. /**
  25237. * The x component of the control stick
  25238. */
  25239. x: number,
  25240. /**
  25241. * The y component of the control stick
  25242. */
  25243. y: number);
  25244. }
  25245. /**
  25246. * An interface which manages callbacks for gamepad button changes
  25247. */
  25248. export interface GamepadButtonChanges {
  25249. /**
  25250. * Called when a gamepad has been changed
  25251. */
  25252. changed: boolean;
  25253. /**
  25254. * Called when a gamepad press event has been triggered
  25255. */
  25256. pressChanged: boolean;
  25257. /**
  25258. * Called when a touch event has been triggered
  25259. */
  25260. touchChanged: boolean;
  25261. /**
  25262. * Called when a value has changed
  25263. */
  25264. valueChanged: boolean;
  25265. }
  25266. /**
  25267. * Represents a gamepad
  25268. */
  25269. export class Gamepad {
  25270. /**
  25271. * The id of the gamepad
  25272. */
  25273. id: string;
  25274. /**
  25275. * The index of the gamepad
  25276. */
  25277. index: number;
  25278. /**
  25279. * The browser gamepad
  25280. */
  25281. browserGamepad: any;
  25282. /**
  25283. * Specifies what type of gamepad this represents
  25284. */
  25285. type: number;
  25286. private _leftStick;
  25287. private _rightStick;
  25288. /** @hidden */
  25289. _isConnected: boolean;
  25290. private _leftStickAxisX;
  25291. private _leftStickAxisY;
  25292. private _rightStickAxisX;
  25293. private _rightStickAxisY;
  25294. /**
  25295. * Triggered when the left control stick has been changed
  25296. */
  25297. private _onleftstickchanged;
  25298. /**
  25299. * Triggered when the right control stick has been changed
  25300. */
  25301. private _onrightstickchanged;
  25302. /**
  25303. * Represents a gamepad controller
  25304. */
  25305. static GAMEPAD: number;
  25306. /**
  25307. * Represents a generic controller
  25308. */
  25309. static GENERIC: number;
  25310. /**
  25311. * Represents an XBox controller
  25312. */
  25313. static XBOX: number;
  25314. /**
  25315. * Represents a pose-enabled controller
  25316. */
  25317. static POSE_ENABLED: number;
  25318. /**
  25319. * Represents an Dual Shock controller
  25320. */
  25321. static DUALSHOCK: number;
  25322. /**
  25323. * Specifies whether the left control stick should be Y-inverted
  25324. */
  25325. protected _invertLeftStickY: boolean;
  25326. /**
  25327. * Specifies if the gamepad has been connected
  25328. */
  25329. get isConnected(): boolean;
  25330. /**
  25331. * Initializes the gamepad
  25332. * @param id The id of the gamepad
  25333. * @param index The index of the gamepad
  25334. * @param browserGamepad The browser gamepad
  25335. * @param leftStickX The x component of the left joystick
  25336. * @param leftStickY The y component of the left joystick
  25337. * @param rightStickX The x component of the right joystick
  25338. * @param rightStickY The y component of the right joystick
  25339. */
  25340. constructor(
  25341. /**
  25342. * The id of the gamepad
  25343. */
  25344. id: string,
  25345. /**
  25346. * The index of the gamepad
  25347. */
  25348. index: number,
  25349. /**
  25350. * The browser gamepad
  25351. */
  25352. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25353. /**
  25354. * Callback triggered when the left joystick has changed
  25355. * @param callback
  25356. */
  25357. onleftstickchanged(callback: (values: StickValues) => void): void;
  25358. /**
  25359. * Callback triggered when the right joystick has changed
  25360. * @param callback
  25361. */
  25362. onrightstickchanged(callback: (values: StickValues) => void): void;
  25363. /**
  25364. * Gets the left joystick
  25365. */
  25366. get leftStick(): StickValues;
  25367. /**
  25368. * Sets the left joystick values
  25369. */
  25370. set leftStick(newValues: StickValues);
  25371. /**
  25372. * Gets the right joystick
  25373. */
  25374. get rightStick(): StickValues;
  25375. /**
  25376. * Sets the right joystick value
  25377. */
  25378. set rightStick(newValues: StickValues);
  25379. /**
  25380. * Updates the gamepad joystick positions
  25381. */
  25382. update(): void;
  25383. /**
  25384. * Disposes the gamepad
  25385. */
  25386. dispose(): void;
  25387. }
  25388. /**
  25389. * Represents a generic gamepad
  25390. */
  25391. export class GenericPad extends Gamepad {
  25392. private _buttons;
  25393. private _onbuttondown;
  25394. private _onbuttonup;
  25395. /**
  25396. * Observable triggered when a button has been pressed
  25397. */
  25398. onButtonDownObservable: Observable<number>;
  25399. /**
  25400. * Observable triggered when a button has been released
  25401. */
  25402. onButtonUpObservable: Observable<number>;
  25403. /**
  25404. * Callback triggered when a button has been pressed
  25405. * @param callback Called when a button has been pressed
  25406. */
  25407. onbuttondown(callback: (buttonPressed: number) => void): void;
  25408. /**
  25409. * Callback triggered when a button has been released
  25410. * @param callback Called when a button has been released
  25411. */
  25412. onbuttonup(callback: (buttonReleased: number) => void): void;
  25413. /**
  25414. * Initializes the generic gamepad
  25415. * @param id The id of the generic gamepad
  25416. * @param index The index of the generic gamepad
  25417. * @param browserGamepad The browser gamepad
  25418. */
  25419. constructor(id: string, index: number, browserGamepad: any);
  25420. private _setButtonValue;
  25421. /**
  25422. * Updates the generic gamepad
  25423. */
  25424. update(): void;
  25425. /**
  25426. * Disposes the generic gamepad
  25427. */
  25428. dispose(): void;
  25429. }
  25430. }
  25431. declare module BABYLON {
  25432. /**
  25433. * Defines a runtime animation
  25434. */
  25435. export class RuntimeAnimation {
  25436. private _events;
  25437. /**
  25438. * The current frame of the runtime animation
  25439. */
  25440. private _currentFrame;
  25441. /**
  25442. * The animation used by the runtime animation
  25443. */
  25444. private _animation;
  25445. /**
  25446. * The target of the runtime animation
  25447. */
  25448. private _target;
  25449. /**
  25450. * The initiating animatable
  25451. */
  25452. private _host;
  25453. /**
  25454. * The original value of the runtime animation
  25455. */
  25456. private _originalValue;
  25457. /**
  25458. * The original blend value of the runtime animation
  25459. */
  25460. private _originalBlendValue;
  25461. /**
  25462. * The offsets cache of the runtime animation
  25463. */
  25464. private _offsetsCache;
  25465. /**
  25466. * The high limits cache of the runtime animation
  25467. */
  25468. private _highLimitsCache;
  25469. /**
  25470. * Specifies if the runtime animation has been stopped
  25471. */
  25472. private _stopped;
  25473. /**
  25474. * The blending factor of the runtime animation
  25475. */
  25476. private _blendingFactor;
  25477. /**
  25478. * The BabylonJS scene
  25479. */
  25480. private _scene;
  25481. /**
  25482. * The current value of the runtime animation
  25483. */
  25484. private _currentValue;
  25485. /** @hidden */
  25486. _animationState: _IAnimationState;
  25487. /**
  25488. * The active target of the runtime animation
  25489. */
  25490. private _activeTargets;
  25491. private _currentActiveTarget;
  25492. private _directTarget;
  25493. /**
  25494. * The target path of the runtime animation
  25495. */
  25496. private _targetPath;
  25497. /**
  25498. * The weight of the runtime animation
  25499. */
  25500. private _weight;
  25501. /**
  25502. * The ratio offset of the runtime animation
  25503. */
  25504. private _ratioOffset;
  25505. /**
  25506. * The previous delay of the runtime animation
  25507. */
  25508. private _previousDelay;
  25509. /**
  25510. * The previous ratio of the runtime animation
  25511. */
  25512. private _previousRatio;
  25513. private _enableBlending;
  25514. private _keys;
  25515. private _minFrame;
  25516. private _maxFrame;
  25517. private _minValue;
  25518. private _maxValue;
  25519. private _targetIsArray;
  25520. /**
  25521. * Gets the current frame of the runtime animation
  25522. */
  25523. get currentFrame(): number;
  25524. /**
  25525. * Gets the weight of the runtime animation
  25526. */
  25527. get weight(): number;
  25528. /**
  25529. * Gets the current value of the runtime animation
  25530. */
  25531. get currentValue(): any;
  25532. /**
  25533. * Gets the target path of the runtime animation
  25534. */
  25535. get targetPath(): string;
  25536. /**
  25537. * Gets the actual target of the runtime animation
  25538. */
  25539. get target(): any;
  25540. /**
  25541. * Gets the additive state of the runtime animation
  25542. */
  25543. get isAdditive(): boolean;
  25544. /** @hidden */
  25545. _onLoop: () => void;
  25546. /**
  25547. * Create a new RuntimeAnimation object
  25548. * @param target defines the target of the animation
  25549. * @param animation defines the source animation object
  25550. * @param scene defines the hosting scene
  25551. * @param host defines the initiating Animatable
  25552. */
  25553. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25554. private _preparePath;
  25555. /**
  25556. * Gets the animation from the runtime animation
  25557. */
  25558. get animation(): Animation;
  25559. /**
  25560. * Resets the runtime animation to the beginning
  25561. * @param restoreOriginal defines whether to restore the target property to the original value
  25562. */
  25563. reset(restoreOriginal?: boolean): void;
  25564. /**
  25565. * Specifies if the runtime animation is stopped
  25566. * @returns Boolean specifying if the runtime animation is stopped
  25567. */
  25568. isStopped(): boolean;
  25569. /**
  25570. * Disposes of the runtime animation
  25571. */
  25572. dispose(): void;
  25573. /**
  25574. * Apply the interpolated value to the target
  25575. * @param currentValue defines the value computed by the animation
  25576. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25577. */
  25578. setValue(currentValue: any, weight: number): void;
  25579. private _getOriginalValues;
  25580. private _setValue;
  25581. /**
  25582. * Gets the loop pmode of the runtime animation
  25583. * @returns Loop Mode
  25584. */
  25585. private _getCorrectLoopMode;
  25586. /**
  25587. * Move the current animation to a given frame
  25588. * @param frame defines the frame to move to
  25589. */
  25590. goToFrame(frame: number): void;
  25591. /**
  25592. * @hidden Internal use only
  25593. */
  25594. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25595. /**
  25596. * Execute the current animation
  25597. * @param delay defines the delay to add to the current frame
  25598. * @param from defines the lower bound of the animation range
  25599. * @param to defines the upper bound of the animation range
  25600. * @param loop defines if the current animation must loop
  25601. * @param speedRatio defines the current speed ratio
  25602. * @param weight defines the weight of the animation (default is -1 so no weight)
  25603. * @param onLoop optional callback called when animation loops
  25604. * @returns a boolean indicating if the animation is running
  25605. */
  25606. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25607. }
  25608. }
  25609. declare module BABYLON {
  25610. /**
  25611. * Class used to store an actual running animation
  25612. */
  25613. export class Animatable {
  25614. /** defines the target object */
  25615. target: any;
  25616. /** defines the starting frame number (default is 0) */
  25617. fromFrame: number;
  25618. /** defines the ending frame number (default is 100) */
  25619. toFrame: number;
  25620. /** defines if the animation must loop (default is false) */
  25621. loopAnimation: boolean;
  25622. /** defines a callback to call when animation ends if it is not looping */
  25623. onAnimationEnd?: (() => void) | null | undefined;
  25624. /** defines a callback to call when animation loops */
  25625. onAnimationLoop?: (() => void) | null | undefined;
  25626. /** defines whether the animation should be evaluated additively */
  25627. isAdditive: boolean;
  25628. private _localDelayOffset;
  25629. private _pausedDelay;
  25630. private _runtimeAnimations;
  25631. private _paused;
  25632. private _scene;
  25633. private _speedRatio;
  25634. private _weight;
  25635. private _syncRoot;
  25636. /**
  25637. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25638. * This will only apply for non looping animation (default is true)
  25639. */
  25640. disposeOnEnd: boolean;
  25641. /**
  25642. * Gets a boolean indicating if the animation has started
  25643. */
  25644. animationStarted: boolean;
  25645. /**
  25646. * Observer raised when the animation ends
  25647. */
  25648. onAnimationEndObservable: Observable<Animatable>;
  25649. /**
  25650. * Observer raised when the animation loops
  25651. */
  25652. onAnimationLoopObservable: Observable<Animatable>;
  25653. /**
  25654. * Gets the root Animatable used to synchronize and normalize animations
  25655. */
  25656. get syncRoot(): Nullable<Animatable>;
  25657. /**
  25658. * Gets the current frame of the first RuntimeAnimation
  25659. * Used to synchronize Animatables
  25660. */
  25661. get masterFrame(): number;
  25662. /**
  25663. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25664. */
  25665. get weight(): number;
  25666. set weight(value: number);
  25667. /**
  25668. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25669. */
  25670. get speedRatio(): number;
  25671. set speedRatio(value: number);
  25672. /**
  25673. * Creates a new Animatable
  25674. * @param scene defines the hosting scene
  25675. * @param target defines the target object
  25676. * @param fromFrame defines the starting frame number (default is 0)
  25677. * @param toFrame defines the ending frame number (default is 100)
  25678. * @param loopAnimation defines if the animation must loop (default is false)
  25679. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25680. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25681. * @param animations defines a group of animation to add to the new Animatable
  25682. * @param onAnimationLoop defines a callback to call when animation loops
  25683. * @param isAdditive defines whether the animation should be evaluated additively
  25684. */
  25685. constructor(scene: Scene,
  25686. /** defines the target object */
  25687. target: any,
  25688. /** defines the starting frame number (default is 0) */
  25689. fromFrame?: number,
  25690. /** defines the ending frame number (default is 100) */
  25691. toFrame?: number,
  25692. /** defines if the animation must loop (default is false) */
  25693. loopAnimation?: boolean, speedRatio?: number,
  25694. /** defines a callback to call when animation ends if it is not looping */
  25695. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25696. /** defines a callback to call when animation loops */
  25697. onAnimationLoop?: (() => void) | null | undefined,
  25698. /** defines whether the animation should be evaluated additively */
  25699. isAdditive?: boolean);
  25700. /**
  25701. * Synchronize and normalize current Animatable with a source Animatable
  25702. * This is useful when using animation weights and when animations are not of the same length
  25703. * @param root defines the root Animatable to synchronize with
  25704. * @returns the current Animatable
  25705. */
  25706. syncWith(root: Animatable): Animatable;
  25707. /**
  25708. * Gets the list of runtime animations
  25709. * @returns an array of RuntimeAnimation
  25710. */
  25711. getAnimations(): RuntimeAnimation[];
  25712. /**
  25713. * Adds more animations to the current animatable
  25714. * @param target defines the target of the animations
  25715. * @param animations defines the new animations to add
  25716. */
  25717. appendAnimations(target: any, animations: Animation[]): void;
  25718. /**
  25719. * Gets the source animation for a specific property
  25720. * @param property defines the propertyu to look for
  25721. * @returns null or the source animation for the given property
  25722. */
  25723. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25724. /**
  25725. * Gets the runtime animation for a specific property
  25726. * @param property defines the propertyu to look for
  25727. * @returns null or the runtime animation for the given property
  25728. */
  25729. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25730. /**
  25731. * Resets the animatable to its original state
  25732. */
  25733. reset(): void;
  25734. /**
  25735. * Allows the animatable to blend with current running animations
  25736. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25737. * @param blendingSpeed defines the blending speed to use
  25738. */
  25739. enableBlending(blendingSpeed: number): void;
  25740. /**
  25741. * Disable animation blending
  25742. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25743. */
  25744. disableBlending(): void;
  25745. /**
  25746. * Jump directly to a given frame
  25747. * @param frame defines the frame to jump to
  25748. */
  25749. goToFrame(frame: number): void;
  25750. /**
  25751. * Pause the animation
  25752. */
  25753. pause(): void;
  25754. /**
  25755. * Restart the animation
  25756. */
  25757. restart(): void;
  25758. private _raiseOnAnimationEnd;
  25759. /**
  25760. * Stop and delete the current animation
  25761. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25762. * @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)
  25763. */
  25764. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25765. /**
  25766. * Wait asynchronously for the animation to end
  25767. * @returns a promise which will be fullfilled when the animation ends
  25768. */
  25769. waitAsync(): Promise<Animatable>;
  25770. /** @hidden */
  25771. _animate(delay: number): boolean;
  25772. }
  25773. interface Scene {
  25774. /** @hidden */
  25775. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25776. /** @hidden */
  25777. _processLateAnimationBindingsForMatrices(holder: {
  25778. totalWeight: number;
  25779. totalAdditiveWeight: number;
  25780. animations: RuntimeAnimation[];
  25781. additiveAnimations: RuntimeAnimation[];
  25782. originalValue: Matrix;
  25783. }): any;
  25784. /** @hidden */
  25785. _processLateAnimationBindingsForQuaternions(holder: {
  25786. totalWeight: number;
  25787. totalAdditiveWeight: number;
  25788. animations: RuntimeAnimation[];
  25789. additiveAnimations: RuntimeAnimation[];
  25790. originalValue: Quaternion;
  25791. }, refQuaternion: Quaternion): Quaternion;
  25792. /** @hidden */
  25793. _processLateAnimationBindings(): void;
  25794. /**
  25795. * Will start the animation sequence of a given target
  25796. * @param target defines the target
  25797. * @param from defines from which frame should animation start
  25798. * @param to defines until which frame should animation run.
  25799. * @param weight defines the weight to apply to the animation (1.0 by default)
  25800. * @param loop defines if the animation loops
  25801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25802. * @param onAnimationEnd defines the function to be executed when the animation ends
  25803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25804. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25805. * @param onAnimationLoop defines the callback to call when an animation loops
  25806. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25807. * @returns the animatable object created for this animation
  25808. */
  25809. 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;
  25810. /**
  25811. * Will start the animation sequence of a given target
  25812. * @param target defines the target
  25813. * @param from defines from which frame should animation start
  25814. * @param to defines until which frame should animation run.
  25815. * @param loop defines if the animation loops
  25816. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25817. * @param onAnimationEnd defines the function to be executed when the animation ends
  25818. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25819. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25820. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25821. * @param onAnimationLoop defines the callback to call when an animation loops
  25822. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25823. * @returns the animatable object created for this animation
  25824. */
  25825. 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;
  25826. /**
  25827. * Will start the animation sequence of a given target and its hierarchy
  25828. * @param target defines the target
  25829. * @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.
  25830. * @param from defines from which frame should animation start
  25831. * @param to defines until which frame should animation run.
  25832. * @param loop defines if the animation loops
  25833. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25834. * @param onAnimationEnd defines the function to be executed when the animation ends
  25835. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25836. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25837. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25838. * @param onAnimationLoop defines the callback to call when an animation loops
  25839. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25840. * @returns the list of created animatables
  25841. */
  25842. 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[];
  25843. /**
  25844. * Begin a new animation on a given node
  25845. * @param target defines the target where the animation will take place
  25846. * @param animations defines the list of animations to start
  25847. * @param from defines the initial value
  25848. * @param to defines the final value
  25849. * @param loop defines if you want animation to loop (off by default)
  25850. * @param speedRatio defines the speed ratio to apply to all animations
  25851. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25852. * @param onAnimationLoop defines the callback to call when an animation loops
  25853. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25854. * @returns the list of created animatables
  25855. */
  25856. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25857. /**
  25858. * Begin a new animation on a given node and its hierarchy
  25859. * @param target defines the root node where the animation will take place
  25860. * @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.
  25861. * @param animations defines the list of animations to start
  25862. * @param from defines the initial value
  25863. * @param to defines the final value
  25864. * @param loop defines if you want animation to loop (off by default)
  25865. * @param speedRatio defines the speed ratio to apply to all animations
  25866. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25867. * @param onAnimationLoop defines the callback to call when an animation loops
  25868. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25869. * @returns the list of animatables created for all nodes
  25870. */
  25871. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25872. /**
  25873. * Gets the animatable associated with a specific target
  25874. * @param target defines the target of the animatable
  25875. * @returns the required animatable if found
  25876. */
  25877. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25878. /**
  25879. * Gets all animatables associated with a given target
  25880. * @param target defines the target to look animatables for
  25881. * @returns an array of Animatables
  25882. */
  25883. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25884. /**
  25885. * Stops and removes all animations that have been applied to the scene
  25886. */
  25887. stopAllAnimations(): void;
  25888. /**
  25889. * Gets the current delta time used by animation engine
  25890. */
  25891. deltaTime: number;
  25892. }
  25893. interface Bone {
  25894. /**
  25895. * Copy an animation range from another bone
  25896. * @param source defines the source bone
  25897. * @param rangeName defines the range name to copy
  25898. * @param frameOffset defines the frame offset
  25899. * @param rescaleAsRequired defines if rescaling must be applied if required
  25900. * @param skelDimensionsRatio defines the scaling ratio
  25901. * @returns true if operation was successful
  25902. */
  25903. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25904. }
  25905. }
  25906. declare module BABYLON {
  25907. /**
  25908. * Class used to override all child animations of a given target
  25909. */
  25910. export class AnimationPropertiesOverride {
  25911. /**
  25912. * Gets or sets a value indicating if animation blending must be used
  25913. */
  25914. enableBlending: boolean;
  25915. /**
  25916. * Gets or sets the blending speed to use when enableBlending is true
  25917. */
  25918. blendingSpeed: number;
  25919. /**
  25920. * Gets or sets the default loop mode to use
  25921. */
  25922. loopMode: number;
  25923. }
  25924. }
  25925. declare module BABYLON {
  25926. /**
  25927. * Class used to handle skinning animations
  25928. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25929. */
  25930. export class Skeleton implements IAnimatable {
  25931. /** defines the skeleton name */
  25932. name: string;
  25933. /** defines the skeleton Id */
  25934. id: string;
  25935. /**
  25936. * Defines the list of child bones
  25937. */
  25938. bones: Bone[];
  25939. /**
  25940. * Defines an estimate of the dimension of the skeleton at rest
  25941. */
  25942. dimensionsAtRest: Vector3;
  25943. /**
  25944. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25945. */
  25946. needInitialSkinMatrix: boolean;
  25947. /**
  25948. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25949. */
  25950. overrideMesh: Nullable<AbstractMesh>;
  25951. /**
  25952. * Gets the list of animations attached to this skeleton
  25953. */
  25954. animations: Array<Animation>;
  25955. private _scene;
  25956. private _isDirty;
  25957. private _transformMatrices;
  25958. private _transformMatrixTexture;
  25959. private _meshesWithPoseMatrix;
  25960. private _animatables;
  25961. private _identity;
  25962. private _synchronizedWithMesh;
  25963. private _ranges;
  25964. private _lastAbsoluteTransformsUpdateId;
  25965. private _canUseTextureForBones;
  25966. private _uniqueId;
  25967. /** @hidden */
  25968. _numBonesWithLinkedTransformNode: number;
  25969. /** @hidden */
  25970. _hasWaitingData: Nullable<boolean>;
  25971. /** @hidden */
  25972. _waitingOverrideMeshId: Nullable<string>;
  25973. /**
  25974. * Specifies if the skeleton should be serialized
  25975. */
  25976. doNotSerialize: boolean;
  25977. private _useTextureToStoreBoneMatrices;
  25978. /**
  25979. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25980. * Please note that this option is not available if the hardware does not support it
  25981. */
  25982. get useTextureToStoreBoneMatrices(): boolean;
  25983. set useTextureToStoreBoneMatrices(value: boolean);
  25984. private _animationPropertiesOverride;
  25985. /**
  25986. * Gets or sets the animation properties override
  25987. */
  25988. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25989. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25990. /**
  25991. * List of inspectable custom properties (used by the Inspector)
  25992. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25993. */
  25994. inspectableCustomProperties: IInspectable[];
  25995. /**
  25996. * An observable triggered before computing the skeleton's matrices
  25997. */
  25998. onBeforeComputeObservable: Observable<Skeleton>;
  25999. /**
  26000. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26001. */
  26002. get isUsingTextureForMatrices(): boolean;
  26003. /**
  26004. * Gets the unique ID of this skeleton
  26005. */
  26006. get uniqueId(): number;
  26007. /**
  26008. * Creates a new skeleton
  26009. * @param name defines the skeleton name
  26010. * @param id defines the skeleton Id
  26011. * @param scene defines the hosting scene
  26012. */
  26013. constructor(
  26014. /** defines the skeleton name */
  26015. name: string,
  26016. /** defines the skeleton Id */
  26017. id: string, scene: Scene);
  26018. /**
  26019. * Gets the current object class name.
  26020. * @return the class name
  26021. */
  26022. getClassName(): string;
  26023. /**
  26024. * Returns an array containing the root bones
  26025. * @returns an array containing the root bones
  26026. */
  26027. getChildren(): Array<Bone>;
  26028. /**
  26029. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26030. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26031. * @returns a Float32Array containing matrices data
  26032. */
  26033. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26034. /**
  26035. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26036. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26037. * @returns a raw texture containing the data
  26038. */
  26039. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26040. /**
  26041. * Gets the current hosting scene
  26042. * @returns a scene object
  26043. */
  26044. getScene(): Scene;
  26045. /**
  26046. * Gets a string representing the current skeleton data
  26047. * @param fullDetails defines a boolean indicating if we want a verbose version
  26048. * @returns a string representing the current skeleton data
  26049. */
  26050. toString(fullDetails?: boolean): string;
  26051. /**
  26052. * Get bone's index searching by name
  26053. * @param name defines bone's name to search for
  26054. * @return the indice of the bone. Returns -1 if not found
  26055. */
  26056. getBoneIndexByName(name: string): number;
  26057. /**
  26058. * Creater a new animation range
  26059. * @param name defines the name of the range
  26060. * @param from defines the start key
  26061. * @param to defines the end key
  26062. */
  26063. createAnimationRange(name: string, from: number, to: number): void;
  26064. /**
  26065. * Delete a specific animation range
  26066. * @param name defines the name of the range
  26067. * @param deleteFrames defines if frames must be removed as well
  26068. */
  26069. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26070. /**
  26071. * Gets a specific animation range
  26072. * @param name defines the name of the range to look for
  26073. * @returns the requested animation range or null if not found
  26074. */
  26075. getAnimationRange(name: string): Nullable<AnimationRange>;
  26076. /**
  26077. * Gets the list of all animation ranges defined on this skeleton
  26078. * @returns an array
  26079. */
  26080. getAnimationRanges(): Nullable<AnimationRange>[];
  26081. /**
  26082. * Copy animation range from a source skeleton.
  26083. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26084. * @param source defines the source skeleton
  26085. * @param name defines the name of the range to copy
  26086. * @param rescaleAsRequired defines if rescaling must be applied if required
  26087. * @returns true if operation was successful
  26088. */
  26089. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26090. /**
  26091. * Forces the skeleton to go to rest pose
  26092. */
  26093. returnToRest(): void;
  26094. private _getHighestAnimationFrame;
  26095. /**
  26096. * Begin a specific animation range
  26097. * @param name defines the name of the range to start
  26098. * @param loop defines if looping must be turned on (false by default)
  26099. * @param speedRatio defines the speed ratio to apply (1 by default)
  26100. * @param onAnimationEnd defines a callback which will be called when animation will end
  26101. * @returns a new animatable
  26102. */
  26103. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26104. /**
  26105. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26106. * @param skeleton defines the Skeleton containing the animation range to convert
  26107. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26108. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26109. * @returns the original skeleton
  26110. */
  26111. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26112. /** @hidden */
  26113. _markAsDirty(): void;
  26114. /** @hidden */
  26115. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26116. /** @hidden */
  26117. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26118. private _computeTransformMatrices;
  26119. /**
  26120. * Build all resources required to render a skeleton
  26121. */
  26122. prepare(): void;
  26123. /**
  26124. * Gets the list of animatables currently running for this skeleton
  26125. * @returns an array of animatables
  26126. */
  26127. getAnimatables(): IAnimatable[];
  26128. /**
  26129. * Clone the current skeleton
  26130. * @param name defines the name of the new skeleton
  26131. * @param id defines the id of the new skeleton
  26132. * @returns the new skeleton
  26133. */
  26134. clone(name: string, id?: string): Skeleton;
  26135. /**
  26136. * Enable animation blending for this skeleton
  26137. * @param blendingSpeed defines the blending speed to apply
  26138. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26139. */
  26140. enableBlending(blendingSpeed?: number): void;
  26141. /**
  26142. * Releases all resources associated with the current skeleton
  26143. */
  26144. dispose(): void;
  26145. /**
  26146. * Serialize the skeleton in a JSON object
  26147. * @returns a JSON object
  26148. */
  26149. serialize(): any;
  26150. /**
  26151. * Creates a new skeleton from serialized data
  26152. * @param parsedSkeleton defines the serialized data
  26153. * @param scene defines the hosting scene
  26154. * @returns a new skeleton
  26155. */
  26156. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26157. /**
  26158. * Compute all node absolute transforms
  26159. * @param forceUpdate defines if computation must be done even if cache is up to date
  26160. */
  26161. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26162. /**
  26163. * Gets the root pose matrix
  26164. * @returns a matrix
  26165. */
  26166. getPoseMatrix(): Nullable<Matrix>;
  26167. /**
  26168. * Sorts bones per internal index
  26169. */
  26170. sortBones(): void;
  26171. private _sortBones;
  26172. /**
  26173. * Set the current local matrix as the restPose for all bones in the skeleton.
  26174. */
  26175. setCurrentPoseAsRest(): void;
  26176. }
  26177. }
  26178. declare module BABYLON {
  26179. /**
  26180. * Class used to store bone information
  26181. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26182. */
  26183. export class Bone extends Node {
  26184. /**
  26185. * defines the bone name
  26186. */
  26187. name: string;
  26188. private static _tmpVecs;
  26189. private static _tmpQuat;
  26190. private static _tmpMats;
  26191. /**
  26192. * Gets the list of child bones
  26193. */
  26194. children: Bone[];
  26195. /** Gets the animations associated with this bone */
  26196. animations: Animation[];
  26197. /**
  26198. * Gets or sets bone length
  26199. */
  26200. length: number;
  26201. /**
  26202. * @hidden Internal only
  26203. * Set this value to map this bone to a different index in the transform matrices
  26204. * Set this value to -1 to exclude the bone from the transform matrices
  26205. */
  26206. _index: Nullable<number>;
  26207. private _skeleton;
  26208. private _localMatrix;
  26209. private _restPose;
  26210. private _bindPose;
  26211. private _baseMatrix;
  26212. private _absoluteTransform;
  26213. private _invertedAbsoluteTransform;
  26214. private _parent;
  26215. private _scalingDeterminant;
  26216. private _worldTransform;
  26217. private _localScaling;
  26218. private _localRotation;
  26219. private _localPosition;
  26220. private _needToDecompose;
  26221. private _needToCompose;
  26222. /** @hidden */
  26223. _linkedTransformNode: Nullable<TransformNode>;
  26224. /** @hidden */
  26225. _waitingTransformNodeId: Nullable<string>;
  26226. /** @hidden */
  26227. get _matrix(): Matrix;
  26228. /** @hidden */
  26229. set _matrix(value: Matrix);
  26230. /**
  26231. * Create a new bone
  26232. * @param name defines the bone name
  26233. * @param skeleton defines the parent skeleton
  26234. * @param parentBone defines the parent (can be null if the bone is the root)
  26235. * @param localMatrix defines the local matrix
  26236. * @param restPose defines the rest pose matrix
  26237. * @param baseMatrix defines the base matrix
  26238. * @param index defines index of the bone in the hiearchy
  26239. */
  26240. constructor(
  26241. /**
  26242. * defines the bone name
  26243. */
  26244. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26245. /**
  26246. * Gets the current object class name.
  26247. * @return the class name
  26248. */
  26249. getClassName(): string;
  26250. /**
  26251. * Gets the parent skeleton
  26252. * @returns a skeleton
  26253. */
  26254. getSkeleton(): Skeleton;
  26255. /**
  26256. * Gets parent bone
  26257. * @returns a bone or null if the bone is the root of the bone hierarchy
  26258. */
  26259. getParent(): Nullable<Bone>;
  26260. /**
  26261. * Returns an array containing the root bones
  26262. * @returns an array containing the root bones
  26263. */
  26264. getChildren(): Array<Bone>;
  26265. /**
  26266. * Gets the node index in matrix array generated for rendering
  26267. * @returns the node index
  26268. */
  26269. getIndex(): number;
  26270. /**
  26271. * Sets the parent bone
  26272. * @param parent defines the parent (can be null if the bone is the root)
  26273. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26274. */
  26275. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26276. /**
  26277. * Gets the local matrix
  26278. * @returns a matrix
  26279. */
  26280. getLocalMatrix(): Matrix;
  26281. /**
  26282. * Gets the base matrix (initial matrix which remains unchanged)
  26283. * @returns a matrix
  26284. */
  26285. getBaseMatrix(): Matrix;
  26286. /**
  26287. * Gets the rest pose matrix
  26288. * @returns a matrix
  26289. */
  26290. getRestPose(): Matrix;
  26291. /**
  26292. * Sets the rest pose matrix
  26293. * @param matrix the local-space rest pose to set for this bone
  26294. */
  26295. setRestPose(matrix: Matrix): void;
  26296. /**
  26297. * Gets the bind pose matrix
  26298. * @returns the bind pose matrix
  26299. */
  26300. getBindPose(): Matrix;
  26301. /**
  26302. * Sets the bind pose matrix
  26303. * @param matrix the local-space bind pose to set for this bone
  26304. */
  26305. setBindPose(matrix: Matrix): void;
  26306. /**
  26307. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26308. */
  26309. getWorldMatrix(): Matrix;
  26310. /**
  26311. * Sets the local matrix to rest pose matrix
  26312. */
  26313. returnToRest(): void;
  26314. /**
  26315. * Gets the inverse of the absolute transform matrix.
  26316. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26317. * @returns a matrix
  26318. */
  26319. getInvertedAbsoluteTransform(): Matrix;
  26320. /**
  26321. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26322. * @returns a matrix
  26323. */
  26324. getAbsoluteTransform(): Matrix;
  26325. /**
  26326. * Links with the given transform node.
  26327. * The local matrix of this bone is copied from the transform node every frame.
  26328. * @param transformNode defines the transform node to link to
  26329. */
  26330. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26331. /**
  26332. * Gets the node used to drive the bone's transformation
  26333. * @returns a transform node or null
  26334. */
  26335. getTransformNode(): Nullable<TransformNode>;
  26336. /** Gets or sets current position (in local space) */
  26337. get position(): Vector3;
  26338. set position(newPosition: Vector3);
  26339. /** Gets or sets current rotation (in local space) */
  26340. get rotation(): Vector3;
  26341. set rotation(newRotation: Vector3);
  26342. /** Gets or sets current rotation quaternion (in local space) */
  26343. get rotationQuaternion(): Quaternion;
  26344. set rotationQuaternion(newRotation: Quaternion);
  26345. /** Gets or sets current scaling (in local space) */
  26346. get scaling(): Vector3;
  26347. set scaling(newScaling: Vector3);
  26348. /**
  26349. * Gets the animation properties override
  26350. */
  26351. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26352. private _decompose;
  26353. private _compose;
  26354. /**
  26355. * Update the base and local matrices
  26356. * @param matrix defines the new base or local matrix
  26357. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26358. * @param updateLocalMatrix defines if the local matrix should be updated
  26359. */
  26360. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26361. /** @hidden */
  26362. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26363. /**
  26364. * Flag the bone as dirty (Forcing it to update everything)
  26365. */
  26366. markAsDirty(): void;
  26367. /** @hidden */
  26368. _markAsDirtyAndCompose(): void;
  26369. private _markAsDirtyAndDecompose;
  26370. /**
  26371. * Translate the bone in local or world space
  26372. * @param vec The amount to translate the bone
  26373. * @param space The space that the translation is in
  26374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26375. */
  26376. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26377. /**
  26378. * Set the postion of the bone in local or world space
  26379. * @param position The position to set the bone
  26380. * @param space The space that the position is in
  26381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26382. */
  26383. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26384. /**
  26385. * Set the absolute position of the bone (world space)
  26386. * @param position The position to set the bone
  26387. * @param mesh The mesh that this bone is attached to
  26388. */
  26389. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26390. /**
  26391. * Scale the bone on the x, y and z axes (in local space)
  26392. * @param x The amount to scale the bone on the x axis
  26393. * @param y The amount to scale the bone on the y axis
  26394. * @param z The amount to scale the bone on the z axis
  26395. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26396. */
  26397. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26398. /**
  26399. * Set the bone scaling in local space
  26400. * @param scale defines the scaling vector
  26401. */
  26402. setScale(scale: Vector3): void;
  26403. /**
  26404. * Gets the current scaling in local space
  26405. * @returns the current scaling vector
  26406. */
  26407. getScale(): Vector3;
  26408. /**
  26409. * Gets the current scaling in local space and stores it in a target vector
  26410. * @param result defines the target vector
  26411. */
  26412. getScaleToRef(result: Vector3): void;
  26413. /**
  26414. * Set the yaw, pitch, and roll of the bone in local or world space
  26415. * @param yaw The rotation of the bone on the y axis
  26416. * @param pitch The rotation of the bone on the x axis
  26417. * @param roll The rotation of the bone on the z axis
  26418. * @param space The space that the axes of rotation are in
  26419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26420. */
  26421. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26422. /**
  26423. * Add a rotation to the bone on an axis in local or world space
  26424. * @param axis The axis to rotate the bone on
  26425. * @param amount The amount to rotate the bone
  26426. * @param space The space that the axis is in
  26427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26428. */
  26429. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26430. /**
  26431. * Set the rotation of the bone to a particular axis angle in local or world space
  26432. * @param axis The axis to rotate the bone on
  26433. * @param angle The angle that the bone should be rotated to
  26434. * @param space The space that the axis is in
  26435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26436. */
  26437. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26438. /**
  26439. * Set the euler rotation of the bone in local or world space
  26440. * @param rotation The euler rotation that the bone should be set to
  26441. * @param space The space that the rotation is in
  26442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26443. */
  26444. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26445. /**
  26446. * Set the quaternion rotation of the bone in local or world space
  26447. * @param quat The quaternion rotation that the bone should be set to
  26448. * @param space The space that the rotation is in
  26449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26450. */
  26451. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26452. /**
  26453. * Set the rotation matrix of the bone in local or world space
  26454. * @param rotMat The rotation matrix that the bone should be set to
  26455. * @param space The space that the rotation is in
  26456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26457. */
  26458. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26459. private _rotateWithMatrix;
  26460. private _getNegativeRotationToRef;
  26461. /**
  26462. * Get the position of the bone in local or world space
  26463. * @param space The space that the returned position is in
  26464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26465. * @returns The position of the bone
  26466. */
  26467. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26468. /**
  26469. * Copy the position of the bone to a vector3 in local or world space
  26470. * @param space The space that the returned position is in
  26471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26472. * @param result The vector3 to copy the position to
  26473. */
  26474. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26475. /**
  26476. * Get the absolute position of the bone (world space)
  26477. * @param mesh The mesh that this bone is attached to
  26478. * @returns The absolute position of the bone
  26479. */
  26480. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26481. /**
  26482. * Copy the absolute position of the bone (world space) to the result param
  26483. * @param mesh The mesh that this bone is attached to
  26484. * @param result The vector3 to copy the absolute position to
  26485. */
  26486. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26487. /**
  26488. * Compute the absolute transforms of this bone and its children
  26489. */
  26490. computeAbsoluteTransforms(): void;
  26491. /**
  26492. * Get the world direction from an axis that is in the local space of the bone
  26493. * @param localAxis The local direction that is used to compute the world direction
  26494. * @param mesh The mesh that this bone is attached to
  26495. * @returns The world direction
  26496. */
  26497. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26498. /**
  26499. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26500. * @param localAxis The local direction that is used to compute the world direction
  26501. * @param mesh The mesh that this bone is attached to
  26502. * @param result The vector3 that the world direction will be copied to
  26503. */
  26504. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26505. /**
  26506. * Get the euler rotation of the bone in local or world space
  26507. * @param space The space that the rotation should be in
  26508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26509. * @returns The euler rotation
  26510. */
  26511. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26512. /**
  26513. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26514. * @param space The space that the rotation should be in
  26515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26516. * @param result The vector3 that the rotation should be copied to
  26517. */
  26518. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26519. /**
  26520. * Get the quaternion rotation of the bone in either local or world space
  26521. * @param space The space that the rotation should be in
  26522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26523. * @returns The quaternion rotation
  26524. */
  26525. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26526. /**
  26527. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26528. * @param space The space that the rotation should be in
  26529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26530. * @param result The quaternion that the rotation should be copied to
  26531. */
  26532. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26533. /**
  26534. * Get the rotation matrix of the bone in local or world space
  26535. * @param space The space that the rotation should be in
  26536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26537. * @returns The rotation matrix
  26538. */
  26539. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26540. /**
  26541. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26542. * @param space The space that the rotation should be in
  26543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26544. * @param result The quaternion that the rotation should be copied to
  26545. */
  26546. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26547. /**
  26548. * Get the world position of a point that is in the local space of the bone
  26549. * @param position The local position
  26550. * @param mesh The mesh that this bone is attached to
  26551. * @returns The world position
  26552. */
  26553. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26554. /**
  26555. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26556. * @param position The local position
  26557. * @param mesh The mesh that this bone is attached to
  26558. * @param result The vector3 that the world position should be copied to
  26559. */
  26560. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26561. /**
  26562. * Get the local position of a point that is in world space
  26563. * @param position The world position
  26564. * @param mesh The mesh that this bone is attached to
  26565. * @returns The local position
  26566. */
  26567. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26568. /**
  26569. * Get the local position of a point that is in world space and copy it to the result param
  26570. * @param position The world position
  26571. * @param mesh The mesh that this bone is attached to
  26572. * @param result The vector3 that the local position should be copied to
  26573. */
  26574. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26575. /**
  26576. * Set the current local matrix as the restPose for this bone.
  26577. */
  26578. setCurrentPoseAsRest(): void;
  26579. }
  26580. }
  26581. declare module BABYLON {
  26582. /**
  26583. * 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.
  26584. * @see https://doc.babylonjs.com/how_to/transformnode
  26585. */
  26586. export class TransformNode extends Node {
  26587. /**
  26588. * Object will not rotate to face the camera
  26589. */
  26590. static BILLBOARDMODE_NONE: number;
  26591. /**
  26592. * Object will rotate to face the camera but only on the x axis
  26593. */
  26594. static BILLBOARDMODE_X: number;
  26595. /**
  26596. * Object will rotate to face the camera but only on the y axis
  26597. */
  26598. static BILLBOARDMODE_Y: number;
  26599. /**
  26600. * Object will rotate to face the camera but only on the z axis
  26601. */
  26602. static BILLBOARDMODE_Z: number;
  26603. /**
  26604. * Object will rotate to face the camera
  26605. */
  26606. static BILLBOARDMODE_ALL: number;
  26607. /**
  26608. * Object will rotate to face the camera's position instead of orientation
  26609. */
  26610. static BILLBOARDMODE_USE_POSITION: number;
  26611. private static _TmpRotation;
  26612. private static _TmpScaling;
  26613. private static _TmpTranslation;
  26614. private _forward;
  26615. private _forwardInverted;
  26616. private _up;
  26617. private _right;
  26618. private _rightInverted;
  26619. private _position;
  26620. private _rotation;
  26621. private _rotationQuaternion;
  26622. protected _scaling: Vector3;
  26623. protected _isDirty: boolean;
  26624. private _transformToBoneReferal;
  26625. private _isAbsoluteSynced;
  26626. private _billboardMode;
  26627. /**
  26628. * Gets or sets the billboard mode. Default is 0.
  26629. *
  26630. * | Value | Type | Description |
  26631. * | --- | --- | --- |
  26632. * | 0 | BILLBOARDMODE_NONE | |
  26633. * | 1 | BILLBOARDMODE_X | |
  26634. * | 2 | BILLBOARDMODE_Y | |
  26635. * | 4 | BILLBOARDMODE_Z | |
  26636. * | 7 | BILLBOARDMODE_ALL | |
  26637. *
  26638. */
  26639. get billboardMode(): number;
  26640. set billboardMode(value: number);
  26641. private _preserveParentRotationForBillboard;
  26642. /**
  26643. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26644. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26645. */
  26646. get preserveParentRotationForBillboard(): boolean;
  26647. set preserveParentRotationForBillboard(value: boolean);
  26648. /**
  26649. * 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
  26650. */
  26651. scalingDeterminant: number;
  26652. private _infiniteDistance;
  26653. /**
  26654. * Gets or sets the distance of the object to max, often used by skybox
  26655. */
  26656. get infiniteDistance(): boolean;
  26657. set infiniteDistance(value: boolean);
  26658. /**
  26659. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26660. * By default the system will update normals to compensate
  26661. */
  26662. ignoreNonUniformScaling: boolean;
  26663. /**
  26664. * 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
  26665. */
  26666. reIntegrateRotationIntoRotationQuaternion: boolean;
  26667. /** @hidden */
  26668. _poseMatrix: Nullable<Matrix>;
  26669. /** @hidden */
  26670. _localMatrix: Matrix;
  26671. private _usePivotMatrix;
  26672. private _absolutePosition;
  26673. private _absoluteScaling;
  26674. private _absoluteRotationQuaternion;
  26675. private _pivotMatrix;
  26676. private _pivotMatrixInverse;
  26677. /** @hidden */
  26678. _postMultiplyPivotMatrix: boolean;
  26679. protected _isWorldMatrixFrozen: boolean;
  26680. /** @hidden */
  26681. _indexInSceneTransformNodesArray: number;
  26682. /**
  26683. * An event triggered after the world matrix is updated
  26684. */
  26685. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26686. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26687. /**
  26688. * Gets a string identifying the name of the class
  26689. * @returns "TransformNode" string
  26690. */
  26691. getClassName(): string;
  26692. /**
  26693. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26694. */
  26695. get position(): Vector3;
  26696. set position(newPosition: Vector3);
  26697. /**
  26698. * 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)).
  26699. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26700. */
  26701. get rotation(): Vector3;
  26702. set rotation(newRotation: Vector3);
  26703. /**
  26704. * 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)).
  26705. */
  26706. get scaling(): Vector3;
  26707. set scaling(newScaling: Vector3);
  26708. /**
  26709. * 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).
  26710. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26711. */
  26712. get rotationQuaternion(): Nullable<Quaternion>;
  26713. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26714. /**
  26715. * The forward direction of that transform in world space.
  26716. */
  26717. get forward(): Vector3;
  26718. /**
  26719. * The up direction of that transform in world space.
  26720. */
  26721. get up(): Vector3;
  26722. /**
  26723. * The right direction of that transform in world space.
  26724. */
  26725. get right(): Vector3;
  26726. /**
  26727. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26728. * @param matrix the matrix to copy the pose from
  26729. * @returns this TransformNode.
  26730. */
  26731. updatePoseMatrix(matrix: Matrix): TransformNode;
  26732. /**
  26733. * Returns the mesh Pose matrix.
  26734. * @returns the pose matrix
  26735. */
  26736. getPoseMatrix(): Matrix;
  26737. /** @hidden */
  26738. _isSynchronized(): boolean;
  26739. /** @hidden */
  26740. _initCache(): void;
  26741. /**
  26742. * Flag the transform node as dirty (Forcing it to update everything)
  26743. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26744. * @returns this transform node
  26745. */
  26746. markAsDirty(property: string): TransformNode;
  26747. /**
  26748. * Returns the current mesh absolute position.
  26749. * Returns a Vector3.
  26750. */
  26751. get absolutePosition(): Vector3;
  26752. /**
  26753. * Returns the current mesh absolute scaling.
  26754. * Returns a Vector3.
  26755. */
  26756. get absoluteScaling(): Vector3;
  26757. /**
  26758. * Returns the current mesh absolute rotation.
  26759. * Returns a Quaternion.
  26760. */
  26761. get absoluteRotationQuaternion(): Quaternion;
  26762. /**
  26763. * Sets a new matrix to apply before all other transformation
  26764. * @param matrix defines the transform matrix
  26765. * @returns the current TransformNode
  26766. */
  26767. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26768. /**
  26769. * Sets a new pivot matrix to the current node
  26770. * @param matrix defines the new pivot matrix to use
  26771. * @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
  26772. * @returns the current TransformNode
  26773. */
  26774. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26775. /**
  26776. * Returns the mesh pivot matrix.
  26777. * Default : Identity.
  26778. * @returns the matrix
  26779. */
  26780. getPivotMatrix(): Matrix;
  26781. /**
  26782. * Instantiate (when possible) or clone that node with its hierarchy
  26783. * @param newParent defines the new parent to use for the instance (or clone)
  26784. * @param options defines options to configure how copy is done
  26785. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26786. * @returns an instance (or a clone) of the current node with its hiearchy
  26787. */
  26788. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26789. doNotInstantiate: boolean;
  26790. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26791. /**
  26792. * Prevents the World matrix to be computed any longer
  26793. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26794. * @returns the TransformNode.
  26795. */
  26796. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26797. /**
  26798. * Allows back the World matrix computation.
  26799. * @returns the TransformNode.
  26800. */
  26801. unfreezeWorldMatrix(): this;
  26802. /**
  26803. * True if the World matrix has been frozen.
  26804. */
  26805. get isWorldMatrixFrozen(): boolean;
  26806. /**
  26807. * Retuns the mesh absolute position in the World.
  26808. * @returns a Vector3.
  26809. */
  26810. getAbsolutePosition(): Vector3;
  26811. /**
  26812. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26813. * @param absolutePosition the absolute position to set
  26814. * @returns the TransformNode.
  26815. */
  26816. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26817. /**
  26818. * Sets the mesh position in its local space.
  26819. * @param vector3 the position to set in localspace
  26820. * @returns the TransformNode.
  26821. */
  26822. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26823. /**
  26824. * Returns the mesh position in the local space from the current World matrix values.
  26825. * @returns a new Vector3.
  26826. */
  26827. getPositionExpressedInLocalSpace(): Vector3;
  26828. /**
  26829. * Translates the mesh along the passed Vector3 in its local space.
  26830. * @param vector3 the distance to translate in localspace
  26831. * @returns the TransformNode.
  26832. */
  26833. locallyTranslate(vector3: Vector3): TransformNode;
  26834. private static _lookAtVectorCache;
  26835. /**
  26836. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26837. * @param targetPoint the position (must be in same space as current mesh) to look at
  26838. * @param yawCor optional yaw (y-axis) correction in radians
  26839. * @param pitchCor optional pitch (x-axis) correction in radians
  26840. * @param rollCor optional roll (z-axis) correction in radians
  26841. * @param space the choosen space of the target
  26842. * @returns the TransformNode.
  26843. */
  26844. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26845. /**
  26846. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26847. * This Vector3 is expressed in the World space.
  26848. * @param localAxis axis to rotate
  26849. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26850. */
  26851. getDirection(localAxis: Vector3): Vector3;
  26852. /**
  26853. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26854. * localAxis is expressed in the mesh local space.
  26855. * result is computed in the Wordl space from the mesh World matrix.
  26856. * @param localAxis axis to rotate
  26857. * @param result the resulting transformnode
  26858. * @returns this TransformNode.
  26859. */
  26860. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26861. /**
  26862. * Sets this transform node rotation to the given local axis.
  26863. * @param localAxis the axis in local space
  26864. * @param yawCor optional yaw (y-axis) correction in radians
  26865. * @param pitchCor optional pitch (x-axis) correction in radians
  26866. * @param rollCor optional roll (z-axis) correction in radians
  26867. * @returns this TransformNode
  26868. */
  26869. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26870. /**
  26871. * Sets a new pivot point to the current node
  26872. * @param point defines the new pivot point to use
  26873. * @param space defines if the point is in world or local space (local by default)
  26874. * @returns the current TransformNode
  26875. */
  26876. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26877. /**
  26878. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26879. * @returns the pivot point
  26880. */
  26881. getPivotPoint(): Vector3;
  26882. /**
  26883. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26884. * @param result the vector3 to store the result
  26885. * @returns this TransformNode.
  26886. */
  26887. getPivotPointToRef(result: Vector3): TransformNode;
  26888. /**
  26889. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26890. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26891. */
  26892. getAbsolutePivotPoint(): Vector3;
  26893. /**
  26894. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26895. * @param result vector3 to store the result
  26896. * @returns this TransformNode.
  26897. */
  26898. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26899. /**
  26900. * Defines the passed node as the parent of the current node.
  26901. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26902. * @see https://doc.babylonjs.com/how_to/parenting
  26903. * @param node the node ot set as the parent
  26904. * @returns this TransformNode.
  26905. */
  26906. setParent(node: Nullable<Node>): TransformNode;
  26907. private _nonUniformScaling;
  26908. /**
  26909. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26910. */
  26911. get nonUniformScaling(): boolean;
  26912. /** @hidden */
  26913. _updateNonUniformScalingState(value: boolean): boolean;
  26914. /**
  26915. * Attach the current TransformNode to another TransformNode associated with a bone
  26916. * @param bone Bone affecting the TransformNode
  26917. * @param affectedTransformNode TransformNode associated with the bone
  26918. * @returns this object
  26919. */
  26920. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26921. /**
  26922. * Detach the transform node if its associated with a bone
  26923. * @returns this object
  26924. */
  26925. detachFromBone(): TransformNode;
  26926. private static _rotationAxisCache;
  26927. /**
  26928. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26929. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26930. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26931. * The passed axis is also normalized.
  26932. * @param axis the axis to rotate around
  26933. * @param amount the amount to rotate in radians
  26934. * @param space Space to rotate in (Default: local)
  26935. * @returns the TransformNode.
  26936. */
  26937. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26938. /**
  26939. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26940. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26941. * The passed axis is also normalized. .
  26942. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26943. * @param point the point to rotate around
  26944. * @param axis the axis to rotate around
  26945. * @param amount the amount to rotate in radians
  26946. * @returns the TransformNode
  26947. */
  26948. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26949. /**
  26950. * Translates the mesh along the axis vector for the passed distance in the given space.
  26951. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26952. * @param axis the axis to translate in
  26953. * @param distance the distance to translate
  26954. * @param space Space to rotate in (Default: local)
  26955. * @returns the TransformNode.
  26956. */
  26957. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26958. /**
  26959. * Adds a rotation step to the mesh current rotation.
  26960. * x, y, z are Euler angles expressed in radians.
  26961. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26962. * This means this rotation is made in the mesh local space only.
  26963. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26964. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26965. * ```javascript
  26966. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26967. * ```
  26968. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26969. * 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.
  26970. * @param x Rotation to add
  26971. * @param y Rotation to add
  26972. * @param z Rotation to add
  26973. * @returns the TransformNode.
  26974. */
  26975. addRotation(x: number, y: number, z: number): TransformNode;
  26976. /**
  26977. * @hidden
  26978. */
  26979. protected _getEffectiveParent(): Nullable<Node>;
  26980. /**
  26981. * Computes the world matrix of the node
  26982. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26983. * @returns the world matrix
  26984. */
  26985. computeWorldMatrix(force?: boolean): Matrix;
  26986. /**
  26987. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26988. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26989. */
  26990. resetLocalMatrix(independentOfChildren?: boolean): void;
  26991. protected _afterComputeWorldMatrix(): void;
  26992. /**
  26993. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26994. * @param func callback function to add
  26995. *
  26996. * @returns the TransformNode.
  26997. */
  26998. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26999. /**
  27000. * Removes a registered callback function.
  27001. * @param func callback function to remove
  27002. * @returns the TransformNode.
  27003. */
  27004. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27005. /**
  27006. * Gets the position of the current mesh in camera space
  27007. * @param camera defines the camera to use
  27008. * @returns a position
  27009. */
  27010. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27011. /**
  27012. * Returns the distance from the mesh to the active camera
  27013. * @param camera defines the camera to use
  27014. * @returns the distance
  27015. */
  27016. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27017. /**
  27018. * Clone the current transform node
  27019. * @param name Name of the new clone
  27020. * @param newParent New parent for the clone
  27021. * @param doNotCloneChildren Do not clone children hierarchy
  27022. * @returns the new transform node
  27023. */
  27024. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27025. /**
  27026. * Serializes the objects information.
  27027. * @param currentSerializationObject defines the object to serialize in
  27028. * @returns the serialized object
  27029. */
  27030. serialize(currentSerializationObject?: any): any;
  27031. /**
  27032. * Returns a new TransformNode object parsed from the source provided.
  27033. * @param parsedTransformNode is the source.
  27034. * @param scene the scne the object belongs to
  27035. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27036. * @returns a new TransformNode object parsed from the source provided.
  27037. */
  27038. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27039. /**
  27040. * Get all child-transformNodes of this node
  27041. * @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
  27042. * @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
  27043. * @returns an array of TransformNode
  27044. */
  27045. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27046. /**
  27047. * Releases resources associated with this transform node.
  27048. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27049. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27050. */
  27051. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27052. /**
  27053. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27054. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27055. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27056. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27057. * @returns the current mesh
  27058. */
  27059. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27060. private _syncAbsoluteScalingAndRotation;
  27061. }
  27062. }
  27063. declare module BABYLON {
  27064. /**
  27065. * Defines the types of pose enabled controllers that are supported
  27066. */
  27067. export enum PoseEnabledControllerType {
  27068. /**
  27069. * HTC Vive
  27070. */
  27071. VIVE = 0,
  27072. /**
  27073. * Oculus Rift
  27074. */
  27075. OCULUS = 1,
  27076. /**
  27077. * Windows mixed reality
  27078. */
  27079. WINDOWS = 2,
  27080. /**
  27081. * Samsung gear VR
  27082. */
  27083. GEAR_VR = 3,
  27084. /**
  27085. * Google Daydream
  27086. */
  27087. DAYDREAM = 4,
  27088. /**
  27089. * Generic
  27090. */
  27091. GENERIC = 5
  27092. }
  27093. /**
  27094. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27095. */
  27096. export interface MutableGamepadButton {
  27097. /**
  27098. * Value of the button/trigger
  27099. */
  27100. value: number;
  27101. /**
  27102. * If the button/trigger is currently touched
  27103. */
  27104. touched: boolean;
  27105. /**
  27106. * If the button/trigger is currently pressed
  27107. */
  27108. pressed: boolean;
  27109. }
  27110. /**
  27111. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27112. * @hidden
  27113. */
  27114. export interface ExtendedGamepadButton extends GamepadButton {
  27115. /**
  27116. * If the button/trigger is currently pressed
  27117. */
  27118. readonly pressed: boolean;
  27119. /**
  27120. * If the button/trigger is currently touched
  27121. */
  27122. readonly touched: boolean;
  27123. /**
  27124. * Value of the button/trigger
  27125. */
  27126. readonly value: number;
  27127. }
  27128. /** @hidden */
  27129. export interface _GamePadFactory {
  27130. /**
  27131. * Returns whether or not the current gamepad can be created for this type of controller.
  27132. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27133. * @returns true if it can be created, otherwise false
  27134. */
  27135. canCreate(gamepadInfo: any): boolean;
  27136. /**
  27137. * Creates a new instance of the Gamepad.
  27138. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27139. * @returns the new gamepad instance
  27140. */
  27141. create(gamepadInfo: any): Gamepad;
  27142. }
  27143. /**
  27144. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27145. */
  27146. export class PoseEnabledControllerHelper {
  27147. /** @hidden */
  27148. static _ControllerFactories: _GamePadFactory[];
  27149. /** @hidden */
  27150. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27151. /**
  27152. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27153. * @param vrGamepad the gamepad to initialized
  27154. * @returns a vr controller of the type the gamepad identified as
  27155. */
  27156. static InitiateController(vrGamepad: any): Gamepad;
  27157. }
  27158. /**
  27159. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27160. */
  27161. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27162. /**
  27163. * If the controller is used in a webXR session
  27164. */
  27165. isXR: boolean;
  27166. private _deviceRoomPosition;
  27167. private _deviceRoomRotationQuaternion;
  27168. /**
  27169. * The device position in babylon space
  27170. */
  27171. devicePosition: Vector3;
  27172. /**
  27173. * The device rotation in babylon space
  27174. */
  27175. deviceRotationQuaternion: Quaternion;
  27176. /**
  27177. * The scale factor of the device in babylon space
  27178. */
  27179. deviceScaleFactor: number;
  27180. /**
  27181. * (Likely devicePosition should be used instead) The device position in its room space
  27182. */
  27183. position: Vector3;
  27184. /**
  27185. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27186. */
  27187. rotationQuaternion: Quaternion;
  27188. /**
  27189. * The type of controller (Eg. Windows mixed reality)
  27190. */
  27191. controllerType: PoseEnabledControllerType;
  27192. protected _calculatedPosition: Vector3;
  27193. private _calculatedRotation;
  27194. /**
  27195. * The raw pose from the device
  27196. */
  27197. rawPose: DevicePose;
  27198. private _trackPosition;
  27199. private _maxRotationDistFromHeadset;
  27200. private _draggedRoomRotation;
  27201. /**
  27202. * @hidden
  27203. */
  27204. _disableTrackPosition(fixedPosition: Vector3): void;
  27205. /**
  27206. * Internal, the mesh attached to the controller
  27207. * @hidden
  27208. */
  27209. _mesh: Nullable<AbstractMesh>;
  27210. private _poseControlledCamera;
  27211. private _leftHandSystemQuaternion;
  27212. /**
  27213. * Internal, matrix used to convert room space to babylon space
  27214. * @hidden
  27215. */
  27216. _deviceToWorld: Matrix;
  27217. /**
  27218. * Node to be used when casting a ray from the controller
  27219. * @hidden
  27220. */
  27221. _pointingPoseNode: Nullable<TransformNode>;
  27222. /**
  27223. * Name of the child mesh that can be used to cast a ray from the controller
  27224. */
  27225. static readonly POINTING_POSE: string;
  27226. /**
  27227. * Creates a new PoseEnabledController from a gamepad
  27228. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27229. */
  27230. constructor(browserGamepad: any);
  27231. private _workingMatrix;
  27232. /**
  27233. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27234. */
  27235. update(): void;
  27236. /**
  27237. * Updates only the pose device and mesh without doing any button event checking
  27238. */
  27239. protected _updatePoseAndMesh(): void;
  27240. /**
  27241. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27242. * @param poseData raw pose fromthe device
  27243. */
  27244. updateFromDevice(poseData: DevicePose): void;
  27245. /**
  27246. * @hidden
  27247. */
  27248. _meshAttachedObservable: Observable<AbstractMesh>;
  27249. /**
  27250. * Attaches a mesh to the controller
  27251. * @param mesh the mesh to be attached
  27252. */
  27253. attachToMesh(mesh: AbstractMesh): void;
  27254. /**
  27255. * Attaches the controllers mesh to a camera
  27256. * @param camera the camera the mesh should be attached to
  27257. */
  27258. attachToPoseControlledCamera(camera: TargetCamera): void;
  27259. /**
  27260. * Disposes of the controller
  27261. */
  27262. dispose(): void;
  27263. /**
  27264. * The mesh that is attached to the controller
  27265. */
  27266. get mesh(): Nullable<AbstractMesh>;
  27267. /**
  27268. * Gets the ray of the controller in the direction the controller is pointing
  27269. * @param length the length the resulting ray should be
  27270. * @returns a ray in the direction the controller is pointing
  27271. */
  27272. getForwardRay(length?: number): Ray;
  27273. }
  27274. }
  27275. declare module BABYLON {
  27276. /**
  27277. * Defines the WebVRController object that represents controllers tracked in 3D space
  27278. */
  27279. export abstract class WebVRController extends PoseEnabledController {
  27280. /**
  27281. * Internal, the default controller model for the controller
  27282. */
  27283. protected _defaultModel: Nullable<AbstractMesh>;
  27284. /**
  27285. * Fired when the trigger state has changed
  27286. */
  27287. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27288. /**
  27289. * Fired when the main button state has changed
  27290. */
  27291. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27292. /**
  27293. * Fired when the secondary button state has changed
  27294. */
  27295. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27296. /**
  27297. * Fired when the pad state has changed
  27298. */
  27299. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27300. /**
  27301. * Fired when controllers stick values have changed
  27302. */
  27303. onPadValuesChangedObservable: Observable<StickValues>;
  27304. /**
  27305. * Array of button availible on the controller
  27306. */
  27307. protected _buttons: Array<MutableGamepadButton>;
  27308. private _onButtonStateChange;
  27309. /**
  27310. * Fired when a controller button's state has changed
  27311. * @param callback the callback containing the button that was modified
  27312. */
  27313. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27314. /**
  27315. * X and Y axis corresponding to the controllers joystick
  27316. */
  27317. pad: StickValues;
  27318. /**
  27319. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27320. */
  27321. hand: string;
  27322. /**
  27323. * The default controller model for the controller
  27324. */
  27325. get defaultModel(): Nullable<AbstractMesh>;
  27326. /**
  27327. * Creates a new WebVRController from a gamepad
  27328. * @param vrGamepad the gamepad that the WebVRController should be created from
  27329. */
  27330. constructor(vrGamepad: any);
  27331. /**
  27332. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27333. */
  27334. update(): void;
  27335. /**
  27336. * Function to be called when a button is modified
  27337. */
  27338. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27339. /**
  27340. * Loads a mesh and attaches it to the controller
  27341. * @param scene the scene the mesh should be added to
  27342. * @param meshLoaded callback for when the mesh has been loaded
  27343. */
  27344. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27345. private _setButtonValue;
  27346. private _changes;
  27347. private _checkChanges;
  27348. /**
  27349. * Disposes of th webVRCOntroller
  27350. */
  27351. dispose(): void;
  27352. }
  27353. }
  27354. declare module BABYLON {
  27355. /**
  27356. * The HemisphericLight simulates the ambient environment light,
  27357. * so the passed direction is the light reflection direction, not the incoming direction.
  27358. */
  27359. export class HemisphericLight extends Light {
  27360. /**
  27361. * The groundColor is the light in the opposite direction to the one specified during creation.
  27362. * 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.
  27363. */
  27364. groundColor: Color3;
  27365. /**
  27366. * The light reflection direction, not the incoming direction.
  27367. */
  27368. direction: Vector3;
  27369. /**
  27370. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27371. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27372. * The HemisphericLight can't cast shadows.
  27373. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27374. * @param name The friendly name of the light
  27375. * @param direction The direction of the light reflection
  27376. * @param scene The scene the light belongs to
  27377. */
  27378. constructor(name: string, direction: Vector3, scene: Scene);
  27379. protected _buildUniformLayout(): void;
  27380. /**
  27381. * Returns the string "HemisphericLight".
  27382. * @return The class name
  27383. */
  27384. getClassName(): string;
  27385. /**
  27386. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27387. * Returns the updated direction.
  27388. * @param target The target the direction should point to
  27389. * @return The computed direction
  27390. */
  27391. setDirectionToTarget(target: Vector3): Vector3;
  27392. /**
  27393. * Returns the shadow generator associated to the light.
  27394. * @returns Always null for hemispheric lights because it does not support shadows.
  27395. */
  27396. getShadowGenerator(): Nullable<IShadowGenerator>;
  27397. /**
  27398. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27399. * @param effect The effect to update
  27400. * @param lightIndex The index of the light in the effect to update
  27401. * @returns The hemispheric light
  27402. */
  27403. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27404. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27405. /**
  27406. * Computes the world matrix of the node
  27407. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27408. * @param useWasUpdatedFlag defines a reserved property
  27409. * @returns the world matrix
  27410. */
  27411. computeWorldMatrix(): Matrix;
  27412. /**
  27413. * Returns the integer 3.
  27414. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27415. */
  27416. getTypeID(): number;
  27417. /**
  27418. * Prepares the list of defines specific to the light type.
  27419. * @param defines the list of defines
  27420. * @param lightIndex defines the index of the light for the effect
  27421. */
  27422. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27423. }
  27424. }
  27425. declare module BABYLON {
  27426. /** @hidden */
  27427. export var vrMultiviewToSingleviewPixelShader: {
  27428. name: string;
  27429. shader: string;
  27430. };
  27431. }
  27432. declare module BABYLON {
  27433. /**
  27434. * Renders to multiple views with a single draw call
  27435. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27436. */
  27437. export class MultiviewRenderTarget extends RenderTargetTexture {
  27438. /**
  27439. * Creates a multiview render target
  27440. * @param scene scene used with the render target
  27441. * @param size the size of the render target (used for each view)
  27442. */
  27443. constructor(scene: Scene, size?: number | {
  27444. width: number;
  27445. height: number;
  27446. } | {
  27447. ratio: number;
  27448. });
  27449. /**
  27450. * @hidden
  27451. * @param faceIndex the face index, if its a cube texture
  27452. */
  27453. _bindFrameBuffer(faceIndex?: number): void;
  27454. /**
  27455. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27456. * @returns the view count
  27457. */
  27458. getViewCount(): number;
  27459. }
  27460. }
  27461. declare module BABYLON {
  27462. interface Engine {
  27463. /**
  27464. * Creates a new multiview render target
  27465. * @param width defines the width of the texture
  27466. * @param height defines the height of the texture
  27467. * @returns the created multiview texture
  27468. */
  27469. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27470. /**
  27471. * Binds a multiview framebuffer to be drawn to
  27472. * @param multiviewTexture texture to bind
  27473. */
  27474. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27475. }
  27476. interface Camera {
  27477. /**
  27478. * @hidden
  27479. * 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)
  27480. */
  27481. _useMultiviewToSingleView: boolean;
  27482. /**
  27483. * @hidden
  27484. * 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)
  27485. */
  27486. _multiviewTexture: Nullable<RenderTargetTexture>;
  27487. /**
  27488. * @hidden
  27489. * ensures the multiview texture of the camera exists and has the specified width/height
  27490. * @param width height to set on the multiview texture
  27491. * @param height width to set on the multiview texture
  27492. */
  27493. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27494. }
  27495. interface Scene {
  27496. /** @hidden */
  27497. _transformMatrixR: Matrix;
  27498. /** @hidden */
  27499. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27500. /** @hidden */
  27501. _createMultiviewUbo(): void;
  27502. /** @hidden */
  27503. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27504. /** @hidden */
  27505. _renderMultiviewToSingleView(camera: Camera): void;
  27506. }
  27507. }
  27508. declare module BABYLON {
  27509. /**
  27510. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27511. * This will not be used for webXR as it supports displaying texture arrays directly
  27512. */
  27513. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27514. /**
  27515. * Gets a string identifying the name of the class
  27516. * @returns "VRMultiviewToSingleviewPostProcess" string
  27517. */
  27518. getClassName(): string;
  27519. /**
  27520. * Initializes a VRMultiviewToSingleview
  27521. * @param name name of the post process
  27522. * @param camera camera to be applied to
  27523. * @param scaleFactor scaling factor to the size of the output texture
  27524. */
  27525. constructor(name: string, camera: Camera, scaleFactor: number);
  27526. }
  27527. }
  27528. declare module BABYLON {
  27529. /**
  27530. * Interface used to define additional presentation attributes
  27531. */
  27532. export interface IVRPresentationAttributes {
  27533. /**
  27534. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27535. */
  27536. highRefreshRate: boolean;
  27537. /**
  27538. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27539. */
  27540. foveationLevel: number;
  27541. }
  27542. interface Engine {
  27543. /** @hidden */
  27544. _vrDisplay: any;
  27545. /** @hidden */
  27546. _vrSupported: boolean;
  27547. /** @hidden */
  27548. _oldSize: Size;
  27549. /** @hidden */
  27550. _oldHardwareScaleFactor: number;
  27551. /** @hidden */
  27552. _vrExclusivePointerMode: boolean;
  27553. /** @hidden */
  27554. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27555. /** @hidden */
  27556. _onVRDisplayPointerRestricted: () => void;
  27557. /** @hidden */
  27558. _onVRDisplayPointerUnrestricted: () => void;
  27559. /** @hidden */
  27560. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27561. /** @hidden */
  27562. _onVrDisplayDisconnect: Nullable<() => void>;
  27563. /** @hidden */
  27564. _onVrDisplayPresentChange: Nullable<() => void>;
  27565. /**
  27566. * Observable signaled when VR display mode changes
  27567. */
  27568. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27569. /**
  27570. * Observable signaled when VR request present is complete
  27571. */
  27572. onVRRequestPresentComplete: Observable<boolean>;
  27573. /**
  27574. * Observable signaled when VR request present starts
  27575. */
  27576. onVRRequestPresentStart: Observable<Engine>;
  27577. /**
  27578. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27579. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27580. */
  27581. isInVRExclusivePointerMode: boolean;
  27582. /**
  27583. * Gets a boolean indicating if a webVR device was detected
  27584. * @returns true if a webVR device was detected
  27585. */
  27586. isVRDevicePresent(): boolean;
  27587. /**
  27588. * Gets the current webVR device
  27589. * @returns the current webVR device (or null)
  27590. */
  27591. getVRDevice(): any;
  27592. /**
  27593. * Initializes a webVR display and starts listening to display change events
  27594. * The onVRDisplayChangedObservable will be notified upon these changes
  27595. * @returns A promise containing a VRDisplay and if vr is supported
  27596. */
  27597. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27598. /** @hidden */
  27599. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27600. /**
  27601. * Gets or sets the presentation attributes used to configure VR rendering
  27602. */
  27603. vrPresentationAttributes?: IVRPresentationAttributes;
  27604. /**
  27605. * Call this function to switch to webVR mode
  27606. * Will do nothing if webVR is not supported or if there is no webVR device
  27607. * @param options the webvr options provided to the camera. mainly used for multiview
  27608. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27609. */
  27610. enableVR(options: WebVROptions): void;
  27611. /** @hidden */
  27612. _onVRFullScreenTriggered(): void;
  27613. }
  27614. }
  27615. declare module BABYLON {
  27616. /**
  27617. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27618. * IMPORTANT!! The data is right-hand data.
  27619. * @export
  27620. * @interface DevicePose
  27621. */
  27622. export interface DevicePose {
  27623. /**
  27624. * The position of the device, values in array are [x,y,z].
  27625. */
  27626. readonly position: Nullable<Float32Array>;
  27627. /**
  27628. * The linearVelocity of the device, values in array are [x,y,z].
  27629. */
  27630. readonly linearVelocity: Nullable<Float32Array>;
  27631. /**
  27632. * The linearAcceleration of the device, values in array are [x,y,z].
  27633. */
  27634. readonly linearAcceleration: Nullable<Float32Array>;
  27635. /**
  27636. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27637. */
  27638. readonly orientation: Nullable<Float32Array>;
  27639. /**
  27640. * The angularVelocity of the device, values in array are [x,y,z].
  27641. */
  27642. readonly angularVelocity: Nullable<Float32Array>;
  27643. /**
  27644. * The angularAcceleration of the device, values in array are [x,y,z].
  27645. */
  27646. readonly angularAcceleration: Nullable<Float32Array>;
  27647. }
  27648. /**
  27649. * Interface representing a pose controlled object in Babylon.
  27650. * A pose controlled object has both regular pose values as well as pose values
  27651. * from an external device such as a VR head mounted display
  27652. */
  27653. export interface PoseControlled {
  27654. /**
  27655. * The position of the object in babylon space.
  27656. */
  27657. position: Vector3;
  27658. /**
  27659. * The rotation quaternion of the object in babylon space.
  27660. */
  27661. rotationQuaternion: Quaternion;
  27662. /**
  27663. * The position of the device in babylon space.
  27664. */
  27665. devicePosition?: Vector3;
  27666. /**
  27667. * The rotation quaternion of the device in babylon space.
  27668. */
  27669. deviceRotationQuaternion: Quaternion;
  27670. /**
  27671. * The raw pose coming from the device.
  27672. */
  27673. rawPose: Nullable<DevicePose>;
  27674. /**
  27675. * The scale of the device to be used when translating from device space to babylon space.
  27676. */
  27677. deviceScaleFactor: number;
  27678. /**
  27679. * Updates the poseControlled values based on the input device pose.
  27680. * @param poseData the pose data to update the object with
  27681. */
  27682. updateFromDevice(poseData: DevicePose): void;
  27683. }
  27684. /**
  27685. * Set of options to customize the webVRCamera
  27686. */
  27687. export interface WebVROptions {
  27688. /**
  27689. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27690. */
  27691. trackPosition?: boolean;
  27692. /**
  27693. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27694. */
  27695. positionScale?: number;
  27696. /**
  27697. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27698. */
  27699. displayName?: string;
  27700. /**
  27701. * Should the native controller meshes be initialized. (default: true)
  27702. */
  27703. controllerMeshes?: boolean;
  27704. /**
  27705. * Creating a default HemiLight only on controllers. (default: true)
  27706. */
  27707. defaultLightingOnControllers?: boolean;
  27708. /**
  27709. * If you don't want to use the default VR button of the helper. (default: false)
  27710. */
  27711. useCustomVRButton?: boolean;
  27712. /**
  27713. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27714. */
  27715. customVRButton?: HTMLButtonElement;
  27716. /**
  27717. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27718. */
  27719. rayLength?: number;
  27720. /**
  27721. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27722. */
  27723. defaultHeight?: number;
  27724. /**
  27725. * If multiview should be used if availible (default: false)
  27726. */
  27727. useMultiview?: boolean;
  27728. }
  27729. /**
  27730. * This represents a WebVR camera.
  27731. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27732. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27733. */
  27734. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27735. private webVROptions;
  27736. /**
  27737. * @hidden
  27738. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27739. */
  27740. _vrDevice: any;
  27741. /**
  27742. * The rawPose of the vrDevice.
  27743. */
  27744. rawPose: Nullable<DevicePose>;
  27745. private _onVREnabled;
  27746. private _specsVersion;
  27747. private _attached;
  27748. private _frameData;
  27749. protected _descendants: Array<Node>;
  27750. private _deviceRoomPosition;
  27751. /** @hidden */
  27752. _deviceRoomRotationQuaternion: Quaternion;
  27753. private _standingMatrix;
  27754. /**
  27755. * Represents device position in babylon space.
  27756. */
  27757. devicePosition: Vector3;
  27758. /**
  27759. * Represents device rotation in babylon space.
  27760. */
  27761. deviceRotationQuaternion: Quaternion;
  27762. /**
  27763. * The scale of the device to be used when translating from device space to babylon space.
  27764. */
  27765. deviceScaleFactor: number;
  27766. private _deviceToWorld;
  27767. private _worldToDevice;
  27768. /**
  27769. * References to the webVR controllers for the vrDevice.
  27770. */
  27771. controllers: Array<WebVRController>;
  27772. /**
  27773. * Emits an event when a controller is attached.
  27774. */
  27775. onControllersAttachedObservable: Observable<WebVRController[]>;
  27776. /**
  27777. * Emits an event when a controller's mesh has been loaded;
  27778. */
  27779. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27780. /**
  27781. * Emits an event when the HMD's pose has been updated.
  27782. */
  27783. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27784. private _poseSet;
  27785. /**
  27786. * If the rig cameras be used as parent instead of this camera.
  27787. */
  27788. rigParenting: boolean;
  27789. private _lightOnControllers;
  27790. private _defaultHeight?;
  27791. /**
  27792. * Instantiates a WebVRFreeCamera.
  27793. * @param name The name of the WebVRFreeCamera
  27794. * @param position The starting anchor position for the camera
  27795. * @param scene The scene the camera belongs to
  27796. * @param webVROptions a set of customizable options for the webVRCamera
  27797. */
  27798. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27799. /**
  27800. * Gets the device distance from the ground in meters.
  27801. * @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.
  27802. */
  27803. deviceDistanceToRoomGround(): number;
  27804. /**
  27805. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27806. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27807. */
  27808. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27809. /**
  27810. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27811. * @returns A promise with a boolean set to if the standing matrix is supported.
  27812. */
  27813. useStandingMatrixAsync(): Promise<boolean>;
  27814. /**
  27815. * Disposes the camera
  27816. */
  27817. dispose(): void;
  27818. /**
  27819. * Gets a vrController by name.
  27820. * @param name The name of the controller to retreive
  27821. * @returns the controller matching the name specified or null if not found
  27822. */
  27823. getControllerByName(name: string): Nullable<WebVRController>;
  27824. private _leftController;
  27825. /**
  27826. * The controller corresponding to the users left hand.
  27827. */
  27828. get leftController(): Nullable<WebVRController>;
  27829. private _rightController;
  27830. /**
  27831. * The controller corresponding to the users right hand.
  27832. */
  27833. get rightController(): Nullable<WebVRController>;
  27834. /**
  27835. * Casts a ray forward from the vrCamera's gaze.
  27836. * @param length Length of the ray (default: 100)
  27837. * @returns the ray corresponding to the gaze
  27838. */
  27839. getForwardRay(length?: number): Ray;
  27840. /**
  27841. * @hidden
  27842. * Updates the camera based on device's frame data
  27843. */
  27844. _checkInputs(): void;
  27845. /**
  27846. * Updates the poseControlled values based on the input device pose.
  27847. * @param poseData Pose coming from the device
  27848. */
  27849. updateFromDevice(poseData: DevicePose): void;
  27850. private _detachIfAttached;
  27851. /**
  27852. * WebVR's attach control will start broadcasting frames to the device.
  27853. * Note that in certain browsers (chrome for example) this function must be called
  27854. * within a user-interaction callback. Example:
  27855. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27856. *
  27857. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27858. */
  27859. attachControl(noPreventDefault?: boolean): void;
  27860. /**
  27861. * Detach the current controls from the specified dom element.
  27862. */
  27863. detachControl(): void;
  27864. /**
  27865. * @returns the name of this class
  27866. */
  27867. getClassName(): string;
  27868. /**
  27869. * Calls resetPose on the vrDisplay
  27870. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27871. */
  27872. resetToCurrentRotation(): void;
  27873. /**
  27874. * @hidden
  27875. * Updates the rig cameras (left and right eye)
  27876. */
  27877. _updateRigCameras(): void;
  27878. private _workingVector;
  27879. private _oneVector;
  27880. private _workingMatrix;
  27881. private updateCacheCalled;
  27882. private _correctPositionIfNotTrackPosition;
  27883. /**
  27884. * @hidden
  27885. * Updates the cached values of the camera
  27886. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27887. */
  27888. _updateCache(ignoreParentClass?: boolean): void;
  27889. /**
  27890. * @hidden
  27891. * Get current device position in babylon world
  27892. */
  27893. _computeDevicePosition(): void;
  27894. /**
  27895. * Updates the current device position and rotation in the babylon world
  27896. */
  27897. update(): void;
  27898. /**
  27899. * @hidden
  27900. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27901. * @returns an identity matrix
  27902. */
  27903. _getViewMatrix(): Matrix;
  27904. private _tmpMatrix;
  27905. /**
  27906. * This function is called by the two RIG cameras.
  27907. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27908. * @hidden
  27909. */
  27910. _getWebVRViewMatrix(): Matrix;
  27911. /** @hidden */
  27912. _getWebVRProjectionMatrix(): Matrix;
  27913. private _onGamepadConnectedObserver;
  27914. private _onGamepadDisconnectedObserver;
  27915. private _updateCacheWhenTrackingDisabledObserver;
  27916. /**
  27917. * Initializes the controllers and their meshes
  27918. */
  27919. initControllers(): void;
  27920. }
  27921. }
  27922. declare module BABYLON {
  27923. /**
  27924. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27925. *
  27926. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27927. *
  27928. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27929. */
  27930. export class MaterialHelper {
  27931. /**
  27932. * Bind the current view position to an effect.
  27933. * @param effect The effect to be bound
  27934. * @param scene The scene the eyes position is used from
  27935. * @param variableName name of the shader variable that will hold the eye position
  27936. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27937. * @return the computed eye position
  27938. */
  27939. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27940. /**
  27941. * Helps preparing the defines values about the UVs in used in the effect.
  27942. * UVs are shared as much as we can accross channels in the shaders.
  27943. * @param texture The texture we are preparing the UVs for
  27944. * @param defines The defines to update
  27945. * @param key The channel key "diffuse", "specular"... used in the shader
  27946. */
  27947. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27948. /**
  27949. * Binds a texture matrix value to its corrsponding uniform
  27950. * @param texture The texture to bind the matrix for
  27951. * @param uniformBuffer The uniform buffer receivin the data
  27952. * @param key The channel key "diffuse", "specular"... used in the shader
  27953. */
  27954. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27955. /**
  27956. * Gets the current status of the fog (should it be enabled?)
  27957. * @param mesh defines the mesh to evaluate for fog support
  27958. * @param scene defines the hosting scene
  27959. * @returns true if fog must be enabled
  27960. */
  27961. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27962. /**
  27963. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27964. * @param mesh defines the current mesh
  27965. * @param scene defines the current scene
  27966. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27967. * @param pointsCloud defines if point cloud rendering has to be turned on
  27968. * @param fogEnabled defines if fog has to be turned on
  27969. * @param alphaTest defines if alpha testing has to be turned on
  27970. * @param defines defines the current list of defines
  27971. */
  27972. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27973. /**
  27974. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27975. * @param scene defines the current scene
  27976. * @param engine defines the current engine
  27977. * @param defines specifies the list of active defines
  27978. * @param useInstances defines if instances have to be turned on
  27979. * @param useClipPlane defines if clip plane have to be turned on
  27980. * @param useInstances defines if instances have to be turned on
  27981. * @param useThinInstances defines if thin instances have to be turned on
  27982. */
  27983. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27984. /**
  27985. * Prepares the defines for bones
  27986. * @param mesh The mesh containing the geometry data we will draw
  27987. * @param defines The defines to update
  27988. */
  27989. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27990. /**
  27991. * Prepares the defines for morph targets
  27992. * @param mesh The mesh containing the geometry data we will draw
  27993. * @param defines The defines to update
  27994. */
  27995. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27996. /**
  27997. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27998. * @param mesh The mesh containing the geometry data we will draw
  27999. * @param defines The defines to update
  28000. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28001. * @param useBones Precise whether bones should be used or not (override mesh info)
  28002. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28003. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28004. * @returns false if defines are considered not dirty and have not been checked
  28005. */
  28006. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28007. /**
  28008. * Prepares the defines related to multiview
  28009. * @param scene The scene we are intending to draw
  28010. * @param defines The defines to update
  28011. */
  28012. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28013. /**
  28014. * Prepares the defines related to the prepass
  28015. * @param scene The scene we are intending to draw
  28016. * @param defines The defines to update
  28017. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28018. */
  28019. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28020. /**
  28021. * Prepares the defines related to the light information passed in parameter
  28022. * @param scene The scene we are intending to draw
  28023. * @param mesh The mesh the effect is compiling for
  28024. * @param light The light the effect is compiling for
  28025. * @param lightIndex The index of the light
  28026. * @param defines The defines to update
  28027. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28028. * @param state Defines the current state regarding what is needed (normals, etc...)
  28029. */
  28030. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28031. needNormals: boolean;
  28032. needRebuild: boolean;
  28033. shadowEnabled: boolean;
  28034. specularEnabled: boolean;
  28035. lightmapMode: boolean;
  28036. }): void;
  28037. /**
  28038. * Prepares the defines related to the light information passed in parameter
  28039. * @param scene The scene we are intending to draw
  28040. * @param mesh The mesh the effect is compiling for
  28041. * @param defines The defines to update
  28042. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28043. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28044. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28045. * @returns true if normals will be required for the rest of the effect
  28046. */
  28047. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28048. /**
  28049. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28050. * @param lightIndex defines the light index
  28051. * @param uniformsList The uniform list
  28052. * @param samplersList The sampler list
  28053. * @param projectedLightTexture defines if projected texture must be used
  28054. * @param uniformBuffersList defines an optional list of uniform buffers
  28055. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28056. */
  28057. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28058. /**
  28059. * Prepares the uniforms and samplers list to be used in the effect
  28060. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28061. * @param samplersList The sampler list
  28062. * @param defines The defines helping in the list generation
  28063. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28064. */
  28065. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28066. /**
  28067. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28068. * @param defines The defines to update while falling back
  28069. * @param fallbacks The authorized effect fallbacks
  28070. * @param maxSimultaneousLights The maximum number of lights allowed
  28071. * @param rank the current rank of the Effect
  28072. * @returns The newly affected rank
  28073. */
  28074. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28075. private static _TmpMorphInfluencers;
  28076. /**
  28077. * Prepares the list of attributes required for morph targets according to the effect defines.
  28078. * @param attribs The current list of supported attribs
  28079. * @param mesh The mesh to prepare the morph targets attributes for
  28080. * @param influencers The number of influencers
  28081. */
  28082. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28083. /**
  28084. * Prepares the list of attributes required for morph targets according to the effect defines.
  28085. * @param attribs The current list of supported attribs
  28086. * @param mesh The mesh to prepare the morph targets attributes for
  28087. * @param defines The current Defines of the effect
  28088. */
  28089. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28090. /**
  28091. * Prepares the list of attributes required for bones according to the effect defines.
  28092. * @param attribs The current list of supported attribs
  28093. * @param mesh The mesh to prepare the bones attributes for
  28094. * @param defines The current Defines of the effect
  28095. * @param fallbacks The current efffect fallback strategy
  28096. */
  28097. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28098. /**
  28099. * Check and prepare the list of attributes required for instances according to the effect defines.
  28100. * @param attribs The current list of supported attribs
  28101. * @param defines The current MaterialDefines of the effect
  28102. */
  28103. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28104. /**
  28105. * Add the list of attributes required for instances to the attribs array.
  28106. * @param attribs The current list of supported attribs
  28107. */
  28108. static PushAttributesForInstances(attribs: string[]): void;
  28109. /**
  28110. * Binds the light information to the effect.
  28111. * @param light The light containing the generator
  28112. * @param effect The effect we are binding the data to
  28113. * @param lightIndex The light index in the effect used to render
  28114. */
  28115. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28116. /**
  28117. * Binds the lights information from the scene to the effect for the given mesh.
  28118. * @param light Light to bind
  28119. * @param lightIndex Light index
  28120. * @param scene The scene where the light belongs to
  28121. * @param effect The effect we are binding the data to
  28122. * @param useSpecular Defines if specular is supported
  28123. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28124. */
  28125. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28126. /**
  28127. * Binds the lights information from the scene to the effect for the given mesh.
  28128. * @param scene The scene the lights belongs to
  28129. * @param mesh The mesh we are binding the information to render
  28130. * @param effect The effect we are binding the data to
  28131. * @param defines The generated defines for the effect
  28132. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28133. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28134. */
  28135. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28136. private static _tempFogColor;
  28137. /**
  28138. * Binds the fog information from the scene to the effect for the given mesh.
  28139. * @param scene The scene the lights belongs to
  28140. * @param mesh The mesh we are binding the information to render
  28141. * @param effect The effect we are binding the data to
  28142. * @param linearSpace Defines if the fog effect is applied in linear space
  28143. */
  28144. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28145. /**
  28146. * Binds the bones information from the mesh to the effect.
  28147. * @param mesh The mesh we are binding the information to render
  28148. * @param effect The effect we are binding the data to
  28149. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28150. */
  28151. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28152. private static _CopyBonesTransformationMatrices;
  28153. /**
  28154. * Binds the morph targets information from the mesh to the effect.
  28155. * @param abstractMesh The mesh we are binding the information to render
  28156. * @param effect The effect we are binding the data to
  28157. */
  28158. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28159. /**
  28160. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28161. * @param defines The generated defines used in the effect
  28162. * @param effect The effect we are binding the data to
  28163. * @param scene The scene we are willing to render with logarithmic scale for
  28164. */
  28165. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28166. /**
  28167. * Binds the clip plane information from the scene to the effect.
  28168. * @param scene The scene the clip plane information are extracted from
  28169. * @param effect The effect we are binding the data to
  28170. */
  28171. static BindClipPlane(effect: Effect, scene: Scene): void;
  28172. }
  28173. }
  28174. declare module BABYLON {
  28175. /** @hidden */
  28176. export var bayerDitherFunctions: {
  28177. name: string;
  28178. shader: string;
  28179. };
  28180. }
  28181. declare module BABYLON {
  28182. /** @hidden */
  28183. export var shadowMapFragmentDeclaration: {
  28184. name: string;
  28185. shader: string;
  28186. };
  28187. }
  28188. declare module BABYLON {
  28189. /** @hidden */
  28190. export var shadowMapFragment: {
  28191. name: string;
  28192. shader: string;
  28193. };
  28194. }
  28195. declare module BABYLON {
  28196. /** @hidden */
  28197. export var shadowMapPixelShader: {
  28198. name: string;
  28199. shader: string;
  28200. };
  28201. }
  28202. declare module BABYLON {
  28203. /** @hidden */
  28204. export var shadowMapVertexDeclaration: {
  28205. name: string;
  28206. shader: string;
  28207. };
  28208. }
  28209. declare module BABYLON {
  28210. /** @hidden */
  28211. export var shadowMapVertexNormalBias: {
  28212. name: string;
  28213. shader: string;
  28214. };
  28215. }
  28216. declare module BABYLON {
  28217. /** @hidden */
  28218. export var shadowMapVertexMetric: {
  28219. name: string;
  28220. shader: string;
  28221. };
  28222. }
  28223. declare module BABYLON {
  28224. /** @hidden */
  28225. export var shadowMapVertexShader: {
  28226. name: string;
  28227. shader: string;
  28228. };
  28229. }
  28230. declare module BABYLON {
  28231. /** @hidden */
  28232. export var depthBoxBlurPixelShader: {
  28233. name: string;
  28234. shader: string;
  28235. };
  28236. }
  28237. declare module BABYLON {
  28238. /** @hidden */
  28239. export var shadowMapFragmentSoftTransparentShadow: {
  28240. name: string;
  28241. shader: string;
  28242. };
  28243. }
  28244. declare module BABYLON {
  28245. /**
  28246. * Creates an instance based on a source mesh.
  28247. */
  28248. export class InstancedMesh extends AbstractMesh {
  28249. private _sourceMesh;
  28250. private _currentLOD;
  28251. /** @hidden */
  28252. _indexInSourceMeshInstanceArray: number;
  28253. constructor(name: string, source: Mesh);
  28254. /**
  28255. * Returns the string "InstancedMesh".
  28256. */
  28257. getClassName(): string;
  28258. /** Gets the list of lights affecting that mesh */
  28259. get lightSources(): Light[];
  28260. _resyncLightSources(): void;
  28261. _resyncLightSource(light: Light): void;
  28262. _removeLightSource(light: Light, dispose: boolean): void;
  28263. /**
  28264. * If the source mesh receives shadows
  28265. */
  28266. get receiveShadows(): boolean;
  28267. /**
  28268. * The material of the source mesh
  28269. */
  28270. get material(): Nullable<Material>;
  28271. /**
  28272. * Visibility of the source mesh
  28273. */
  28274. get visibility(): number;
  28275. /**
  28276. * Skeleton of the source mesh
  28277. */
  28278. get skeleton(): Nullable<Skeleton>;
  28279. /**
  28280. * Rendering ground id of the source mesh
  28281. */
  28282. get renderingGroupId(): number;
  28283. set renderingGroupId(value: number);
  28284. /**
  28285. * Returns the total number of vertices (integer).
  28286. */
  28287. getTotalVertices(): number;
  28288. /**
  28289. * Returns a positive integer : the total number of indices in this mesh geometry.
  28290. * @returns the numner of indices or zero if the mesh has no geometry.
  28291. */
  28292. getTotalIndices(): number;
  28293. /**
  28294. * The source mesh of the instance
  28295. */
  28296. get sourceMesh(): Mesh;
  28297. /**
  28298. * Creates a new InstancedMesh object from the mesh model.
  28299. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28300. * @param name defines the name of the new instance
  28301. * @returns a new InstancedMesh
  28302. */
  28303. createInstance(name: string): InstancedMesh;
  28304. /**
  28305. * Is this node ready to be used/rendered
  28306. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28307. * @return {boolean} is it ready
  28308. */
  28309. isReady(completeCheck?: boolean): boolean;
  28310. /**
  28311. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28312. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28313. * @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.
  28314. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28315. */
  28316. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28317. /**
  28318. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28319. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28320. * The `data` are either a numeric array either a Float32Array.
  28321. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28322. * 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).
  28323. * Note that a new underlying VertexBuffer object is created each call.
  28324. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28325. *
  28326. * Possible `kind` values :
  28327. * - VertexBuffer.PositionKind
  28328. * - VertexBuffer.UVKind
  28329. * - VertexBuffer.UV2Kind
  28330. * - VertexBuffer.UV3Kind
  28331. * - VertexBuffer.UV4Kind
  28332. * - VertexBuffer.UV5Kind
  28333. * - VertexBuffer.UV6Kind
  28334. * - VertexBuffer.ColorKind
  28335. * - VertexBuffer.MatricesIndicesKind
  28336. * - VertexBuffer.MatricesIndicesExtraKind
  28337. * - VertexBuffer.MatricesWeightsKind
  28338. * - VertexBuffer.MatricesWeightsExtraKind
  28339. *
  28340. * Returns the Mesh.
  28341. */
  28342. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28343. /**
  28344. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28345. * If the mesh has no geometry, it is simply returned as it is.
  28346. * The `data` are either a numeric array either a Float32Array.
  28347. * No new underlying VertexBuffer object is created.
  28348. * 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.
  28349. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28350. *
  28351. * Possible `kind` values :
  28352. * - VertexBuffer.PositionKind
  28353. * - VertexBuffer.UVKind
  28354. * - VertexBuffer.UV2Kind
  28355. * - VertexBuffer.UV3Kind
  28356. * - VertexBuffer.UV4Kind
  28357. * - VertexBuffer.UV5Kind
  28358. * - VertexBuffer.UV6Kind
  28359. * - VertexBuffer.ColorKind
  28360. * - VertexBuffer.MatricesIndicesKind
  28361. * - VertexBuffer.MatricesIndicesExtraKind
  28362. * - VertexBuffer.MatricesWeightsKind
  28363. * - VertexBuffer.MatricesWeightsExtraKind
  28364. *
  28365. * Returns the Mesh.
  28366. */
  28367. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28368. /**
  28369. * Sets the mesh indices.
  28370. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28371. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28372. * This method creates a new index buffer each call.
  28373. * Returns the Mesh.
  28374. */
  28375. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28376. /**
  28377. * Boolean : True if the mesh owns the requested kind of data.
  28378. */
  28379. isVerticesDataPresent(kind: string): boolean;
  28380. /**
  28381. * Returns an array of indices (IndicesArray).
  28382. */
  28383. getIndices(): Nullable<IndicesArray>;
  28384. get _positions(): Nullable<Vector3[]>;
  28385. /**
  28386. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28387. * This means the mesh underlying bounding box and sphere are recomputed.
  28388. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28389. * @returns the current mesh
  28390. */
  28391. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28392. /** @hidden */
  28393. _preActivate(): InstancedMesh;
  28394. /** @hidden */
  28395. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28396. /** @hidden */
  28397. _postActivate(): void;
  28398. getWorldMatrix(): Matrix;
  28399. get isAnInstance(): boolean;
  28400. /**
  28401. * Returns the current associated LOD AbstractMesh.
  28402. */
  28403. getLOD(camera: Camera): AbstractMesh;
  28404. /** @hidden */
  28405. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28406. /** @hidden */
  28407. _syncSubMeshes(): InstancedMesh;
  28408. /** @hidden */
  28409. _generatePointsArray(): boolean;
  28410. /** @hidden */
  28411. _updateBoundingInfo(): AbstractMesh;
  28412. /**
  28413. * Creates a new InstancedMesh from the current mesh.
  28414. * - name (string) : the cloned mesh name
  28415. * - newParent (optional Node) : the optional Node to parent the clone to.
  28416. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28417. *
  28418. * Returns the clone.
  28419. */
  28420. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28421. /**
  28422. * Disposes the InstancedMesh.
  28423. * Returns nothing.
  28424. */
  28425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28426. }
  28427. interface Mesh {
  28428. /**
  28429. * Register a custom buffer that will be instanced
  28430. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28431. * @param kind defines the buffer kind
  28432. * @param stride defines the stride in floats
  28433. */
  28434. registerInstancedBuffer(kind: string, stride: number): void;
  28435. /**
  28436. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28437. */
  28438. _invalidateInstanceVertexArrayObject(): void;
  28439. /**
  28440. * true to use the edge renderer for all instances of this mesh
  28441. */
  28442. edgesShareWithInstances: boolean;
  28443. /** @hidden */
  28444. _userInstancedBuffersStorage: {
  28445. data: {
  28446. [key: string]: Float32Array;
  28447. };
  28448. sizes: {
  28449. [key: string]: number;
  28450. };
  28451. vertexBuffers: {
  28452. [key: string]: Nullable<VertexBuffer>;
  28453. };
  28454. strides: {
  28455. [key: string]: number;
  28456. };
  28457. vertexArrayObjects?: {
  28458. [key: string]: WebGLVertexArrayObject;
  28459. };
  28460. };
  28461. }
  28462. interface AbstractMesh {
  28463. /**
  28464. * Object used to store instanced buffers defined by user
  28465. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28466. */
  28467. instancedBuffers: {
  28468. [key: string]: any;
  28469. };
  28470. }
  28471. }
  28472. declare module BABYLON {
  28473. /**
  28474. * Defines the options associated with the creation of a shader material.
  28475. */
  28476. export interface IShaderMaterialOptions {
  28477. /**
  28478. * Does the material work in alpha blend mode
  28479. */
  28480. needAlphaBlending: boolean;
  28481. /**
  28482. * Does the material work in alpha test mode
  28483. */
  28484. needAlphaTesting: boolean;
  28485. /**
  28486. * The list of attribute names used in the shader
  28487. */
  28488. attributes: string[];
  28489. /**
  28490. * The list of unifrom names used in the shader
  28491. */
  28492. uniforms: string[];
  28493. /**
  28494. * The list of UBO names used in the shader
  28495. */
  28496. uniformBuffers: string[];
  28497. /**
  28498. * The list of sampler names used in the shader
  28499. */
  28500. samplers: string[];
  28501. /**
  28502. * The list of defines used in the shader
  28503. */
  28504. defines: string[];
  28505. }
  28506. /**
  28507. * 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.
  28508. *
  28509. * This returned material effects how the mesh will look based on the code in the shaders.
  28510. *
  28511. * @see https://doc.babylonjs.com/how_to/shader_material
  28512. */
  28513. export class ShaderMaterial extends Material {
  28514. private _shaderPath;
  28515. private _options;
  28516. private _textures;
  28517. private _textureArrays;
  28518. private _floats;
  28519. private _ints;
  28520. private _floatsArrays;
  28521. private _colors3;
  28522. private _colors3Arrays;
  28523. private _colors4;
  28524. private _colors4Arrays;
  28525. private _vectors2;
  28526. private _vectors3;
  28527. private _vectors4;
  28528. private _matrices;
  28529. private _matrixArrays;
  28530. private _matrices3x3;
  28531. private _matrices2x2;
  28532. private _vectors2Arrays;
  28533. private _vectors3Arrays;
  28534. private _vectors4Arrays;
  28535. private _cachedWorldViewMatrix;
  28536. private _cachedWorldViewProjectionMatrix;
  28537. private _renderId;
  28538. private _multiview;
  28539. private _cachedDefines;
  28540. /** Define the Url to load snippets */
  28541. static SnippetUrl: string;
  28542. /** Snippet ID if the material was created from the snippet server */
  28543. snippetId: string;
  28544. /**
  28545. * Instantiate a new shader material.
  28546. * 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.
  28547. * This returned material effects how the mesh will look based on the code in the shaders.
  28548. * @see https://doc.babylonjs.com/how_to/shader_material
  28549. * @param name Define the name of the material in the scene
  28550. * @param scene Define the scene the material belongs to
  28551. * @param shaderPath Defines the route to the shader code in one of three ways:
  28552. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28553. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28554. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28555. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28556. * @param options Define the options used to create the shader
  28557. */
  28558. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28559. /**
  28560. * Gets the shader path used to define the shader code
  28561. * It can be modified to trigger a new compilation
  28562. */
  28563. get shaderPath(): any;
  28564. /**
  28565. * Sets the shader path used to define the shader code
  28566. * It can be modified to trigger a new compilation
  28567. */
  28568. set shaderPath(shaderPath: any);
  28569. /**
  28570. * Gets the options used to compile the shader.
  28571. * They can be modified to trigger a new compilation
  28572. */
  28573. get options(): IShaderMaterialOptions;
  28574. /**
  28575. * Gets the current class name of the material e.g. "ShaderMaterial"
  28576. * Mainly use in serialization.
  28577. * @returns the class name
  28578. */
  28579. getClassName(): string;
  28580. /**
  28581. * Specifies if the material will require alpha blending
  28582. * @returns a boolean specifying if alpha blending is needed
  28583. */
  28584. needAlphaBlending(): boolean;
  28585. /**
  28586. * Specifies if this material should be rendered in alpha test mode
  28587. * @returns a boolean specifying if an alpha test is needed.
  28588. */
  28589. needAlphaTesting(): boolean;
  28590. private _checkUniform;
  28591. /**
  28592. * Set a texture in the shader.
  28593. * @param name Define the name of the uniform samplers as defined in the shader
  28594. * @param texture Define the texture to bind to this sampler
  28595. * @return the material itself allowing "fluent" like uniform updates
  28596. */
  28597. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28598. /**
  28599. * Set a texture array in the shader.
  28600. * @param name Define the name of the uniform sampler array as defined in the shader
  28601. * @param textures Define the list of textures to bind to this sampler
  28602. * @return the material itself allowing "fluent" like uniform updates
  28603. */
  28604. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28605. /**
  28606. * Set a float in the shader.
  28607. * @param name Define the name of the uniform as defined in the shader
  28608. * @param value Define the value to give to the uniform
  28609. * @return the material itself allowing "fluent" like uniform updates
  28610. */
  28611. setFloat(name: string, value: number): ShaderMaterial;
  28612. /**
  28613. * Set a int in the shader.
  28614. * @param name Define the name of the uniform as defined in the shader
  28615. * @param value Define the value to give to the uniform
  28616. * @return the material itself allowing "fluent" like uniform updates
  28617. */
  28618. setInt(name: string, value: number): ShaderMaterial;
  28619. /**
  28620. * Set an array of floats in the shader.
  28621. * @param name Define the name of the uniform as defined in the shader
  28622. * @param value Define the value to give to the uniform
  28623. * @return the material itself allowing "fluent" like uniform updates
  28624. */
  28625. setFloats(name: string, value: number[]): ShaderMaterial;
  28626. /**
  28627. * Set a vec3 in the shader from a Color3.
  28628. * @param name Define the name of the uniform as defined in the shader
  28629. * @param value Define the value to give to the uniform
  28630. * @return the material itself allowing "fluent" like uniform updates
  28631. */
  28632. setColor3(name: string, value: Color3): ShaderMaterial;
  28633. /**
  28634. * Set a vec3 array in the shader from a Color3 array.
  28635. * @param name Define the name of the uniform as defined in the shader
  28636. * @param value Define the value to give to the uniform
  28637. * @return the material itself allowing "fluent" like uniform updates
  28638. */
  28639. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28640. /**
  28641. * Set a vec4 in the shader from a Color4.
  28642. * @param name Define the name of the uniform as defined in the shader
  28643. * @param value Define the value to give to the uniform
  28644. * @return the material itself allowing "fluent" like uniform updates
  28645. */
  28646. setColor4(name: string, value: Color4): ShaderMaterial;
  28647. /**
  28648. * Set a vec4 array in the shader from a Color4 array.
  28649. * @param name Define the name of the uniform as defined in the shader
  28650. * @param value Define the value to give to the uniform
  28651. * @return the material itself allowing "fluent" like uniform updates
  28652. */
  28653. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28654. /**
  28655. * Set a vec2 in the shader from a Vector2.
  28656. * @param name Define the name of the uniform as defined in the shader
  28657. * @param value Define the value to give to the uniform
  28658. * @return the material itself allowing "fluent" like uniform updates
  28659. */
  28660. setVector2(name: string, value: Vector2): ShaderMaterial;
  28661. /**
  28662. * Set a vec3 in the shader from a Vector3.
  28663. * @param name Define the name of the uniform as defined in the shader
  28664. * @param value Define the value to give to the uniform
  28665. * @return the material itself allowing "fluent" like uniform updates
  28666. */
  28667. setVector3(name: string, value: Vector3): ShaderMaterial;
  28668. /**
  28669. * Set a vec4 in the shader from a Vector4.
  28670. * @param name Define the name of the uniform as defined in the shader
  28671. * @param value Define the value to give to the uniform
  28672. * @return the material itself allowing "fluent" like uniform updates
  28673. */
  28674. setVector4(name: string, value: Vector4): ShaderMaterial;
  28675. /**
  28676. * Set a mat4 in the shader from a Matrix.
  28677. * @param name Define the name of the uniform as defined in the shader
  28678. * @param value Define the value to give to the uniform
  28679. * @return the material itself allowing "fluent" like uniform updates
  28680. */
  28681. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28682. /**
  28683. * Set a float32Array in the shader from a matrix array.
  28684. * @param name Define the name of the uniform as defined in the shader
  28685. * @param value Define the value to give to the uniform
  28686. * @return the material itself allowing "fluent" like uniform updates
  28687. */
  28688. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28689. /**
  28690. * Set a mat3 in the shader from a Float32Array.
  28691. * @param name Define the name of the uniform as defined in the shader
  28692. * @param value Define the value to give to the uniform
  28693. * @return the material itself allowing "fluent" like uniform updates
  28694. */
  28695. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28696. /**
  28697. * Set a mat2 in the shader from a Float32Array.
  28698. * @param name Define the name of the uniform as defined in the shader
  28699. * @param value Define the value to give to the uniform
  28700. * @return the material itself allowing "fluent" like uniform updates
  28701. */
  28702. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28703. /**
  28704. * Set a vec2 array in the shader from a number array.
  28705. * @param name Define the name of the uniform as defined in the shader
  28706. * @param value Define the value to give to the uniform
  28707. * @return the material itself allowing "fluent" like uniform updates
  28708. */
  28709. setArray2(name: string, value: number[]): ShaderMaterial;
  28710. /**
  28711. * Set a vec3 array in the shader from a number array.
  28712. * @param name Define the name of the uniform as defined in the shader
  28713. * @param value Define the value to give to the uniform
  28714. * @return the material itself allowing "fluent" like uniform updates
  28715. */
  28716. setArray3(name: string, value: number[]): ShaderMaterial;
  28717. /**
  28718. * Set a vec4 array in the shader from a number array.
  28719. * @param name Define the name of the uniform as defined in the shader
  28720. * @param value Define the value to give to the uniform
  28721. * @return the material itself allowing "fluent" like uniform updates
  28722. */
  28723. setArray4(name: string, value: number[]): ShaderMaterial;
  28724. private _checkCache;
  28725. /**
  28726. * Specifies that the submesh is ready to be used
  28727. * @param mesh defines the mesh to check
  28728. * @param subMesh defines which submesh to check
  28729. * @param useInstances specifies that instances should be used
  28730. * @returns a boolean indicating that the submesh is ready or not
  28731. */
  28732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28733. /**
  28734. * Checks if the material is ready to render the requested mesh
  28735. * @param mesh Define the mesh to render
  28736. * @param useInstances Define whether or not the material is used with instances
  28737. * @returns true if ready, otherwise false
  28738. */
  28739. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28740. /**
  28741. * Binds the world matrix to the material
  28742. * @param world defines the world transformation matrix
  28743. * @param effectOverride - If provided, use this effect instead of internal effect
  28744. */
  28745. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28746. /**
  28747. * Binds the submesh to this material by preparing the effect and shader to draw
  28748. * @param world defines the world transformation matrix
  28749. * @param mesh defines the mesh containing the submesh
  28750. * @param subMesh defines the submesh to bind the material to
  28751. */
  28752. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28753. /**
  28754. * Binds the material to the mesh
  28755. * @param world defines the world transformation matrix
  28756. * @param mesh defines the mesh to bind the material to
  28757. * @param effectOverride - If provided, use this effect instead of internal effect
  28758. */
  28759. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28760. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28761. /**
  28762. * Gets the active textures from the material
  28763. * @returns an array of textures
  28764. */
  28765. getActiveTextures(): BaseTexture[];
  28766. /**
  28767. * Specifies if the material uses a texture
  28768. * @param texture defines the texture to check against the material
  28769. * @returns a boolean specifying if the material uses the texture
  28770. */
  28771. hasTexture(texture: BaseTexture): boolean;
  28772. /**
  28773. * Makes a duplicate of the material, and gives it a new name
  28774. * @param name defines the new name for the duplicated material
  28775. * @returns the cloned material
  28776. */
  28777. clone(name: string): ShaderMaterial;
  28778. /**
  28779. * Disposes the material
  28780. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28781. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28782. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28783. */
  28784. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28785. /**
  28786. * Serializes this material in a JSON representation
  28787. * @returns the serialized material object
  28788. */
  28789. serialize(): any;
  28790. /**
  28791. * Creates a shader material from parsed shader material data
  28792. * @param source defines the JSON represnetation of the material
  28793. * @param scene defines the hosting scene
  28794. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28795. * @returns a new material
  28796. */
  28797. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28798. /**
  28799. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28800. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28801. * @param url defines the url to load from
  28802. * @param scene defines the hosting scene
  28803. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28804. * @returns a promise that will resolve to the new ShaderMaterial
  28805. */
  28806. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28807. /**
  28808. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28809. * @param snippetId defines the snippet to load
  28810. * @param scene defines the hosting scene
  28811. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28812. * @returns a promise that will resolve to the new ShaderMaterial
  28813. */
  28814. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28815. }
  28816. }
  28817. declare module BABYLON {
  28818. /** @hidden */
  28819. export var colorPixelShader: {
  28820. name: string;
  28821. shader: string;
  28822. };
  28823. }
  28824. declare module BABYLON {
  28825. /** @hidden */
  28826. export var colorVertexShader: {
  28827. name: string;
  28828. shader: string;
  28829. };
  28830. }
  28831. declare module BABYLON {
  28832. /**
  28833. * Line mesh
  28834. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28835. */
  28836. export class LinesMesh extends Mesh {
  28837. /**
  28838. * If vertex color should be applied to the mesh
  28839. */
  28840. readonly useVertexColor?: boolean | undefined;
  28841. /**
  28842. * If vertex alpha should be applied to the mesh
  28843. */
  28844. readonly useVertexAlpha?: boolean | undefined;
  28845. /**
  28846. * Color of the line (Default: White)
  28847. */
  28848. color: Color3;
  28849. /**
  28850. * Alpha of the line (Default: 1)
  28851. */
  28852. alpha: number;
  28853. /**
  28854. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28855. * This margin is expressed in world space coordinates, so its value may vary.
  28856. * Default value is 0.1
  28857. */
  28858. intersectionThreshold: number;
  28859. private _colorShader;
  28860. private color4;
  28861. /**
  28862. * Creates a new LinesMesh
  28863. * @param name defines the name
  28864. * @param scene defines the hosting scene
  28865. * @param parent defines the parent mesh if any
  28866. * @param source defines the optional source LinesMesh used to clone data from
  28867. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28868. * When false, achieved by calling a clone(), also passing False.
  28869. * This will make creation of children, recursive.
  28870. * @param useVertexColor defines if this LinesMesh supports vertex color
  28871. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28872. */
  28873. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28874. /**
  28875. * If vertex color should be applied to the mesh
  28876. */
  28877. useVertexColor?: boolean | undefined,
  28878. /**
  28879. * If vertex alpha should be applied to the mesh
  28880. */
  28881. useVertexAlpha?: boolean | undefined);
  28882. private _addClipPlaneDefine;
  28883. private _removeClipPlaneDefine;
  28884. isReady(): boolean;
  28885. /**
  28886. * Returns the string "LineMesh"
  28887. */
  28888. getClassName(): string;
  28889. /**
  28890. * @hidden
  28891. */
  28892. get material(): Material;
  28893. /**
  28894. * @hidden
  28895. */
  28896. set material(value: Material);
  28897. /**
  28898. * @hidden
  28899. */
  28900. get checkCollisions(): boolean;
  28901. set checkCollisions(value: boolean);
  28902. /** @hidden */
  28903. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28904. /** @hidden */
  28905. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28906. /**
  28907. * Disposes of the line mesh
  28908. * @param doNotRecurse If children should be disposed
  28909. */
  28910. dispose(doNotRecurse?: boolean): void;
  28911. /**
  28912. * Returns a new LineMesh object cloned from the current one.
  28913. */
  28914. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28915. /**
  28916. * Creates a new InstancedLinesMesh object from the mesh model.
  28917. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28918. * @param name defines the name of the new instance
  28919. * @returns a new InstancedLinesMesh
  28920. */
  28921. createInstance(name: string): InstancedLinesMesh;
  28922. }
  28923. /**
  28924. * Creates an instance based on a source LinesMesh
  28925. */
  28926. export class InstancedLinesMesh extends InstancedMesh {
  28927. /**
  28928. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28929. * This margin is expressed in world space coordinates, so its value may vary.
  28930. * Initilized with the intersectionThreshold value of the source LinesMesh
  28931. */
  28932. intersectionThreshold: number;
  28933. constructor(name: string, source: LinesMesh);
  28934. /**
  28935. * Returns the string "InstancedLinesMesh".
  28936. */
  28937. getClassName(): string;
  28938. }
  28939. }
  28940. declare module BABYLON {
  28941. /** @hidden */
  28942. export var linePixelShader: {
  28943. name: string;
  28944. shader: string;
  28945. };
  28946. }
  28947. declare module BABYLON {
  28948. /** @hidden */
  28949. export var lineVertexShader: {
  28950. name: string;
  28951. shader: string;
  28952. };
  28953. }
  28954. declare module BABYLON {
  28955. interface Scene {
  28956. /** @hidden */
  28957. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28958. }
  28959. interface AbstractMesh {
  28960. /**
  28961. * Gets the edgesRenderer associated with the mesh
  28962. */
  28963. edgesRenderer: Nullable<EdgesRenderer>;
  28964. }
  28965. interface LinesMesh {
  28966. /**
  28967. * Enables the edge rendering mode on the mesh.
  28968. * This mode makes the mesh edges visible
  28969. * @param epsilon defines the maximal distance between two angles to detect a face
  28970. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28971. * @returns the currentAbstractMesh
  28972. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28973. */
  28974. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28975. }
  28976. interface InstancedLinesMesh {
  28977. /**
  28978. * Enables the edge rendering mode on the mesh.
  28979. * This mode makes the mesh edges visible
  28980. * @param epsilon defines the maximal distance between two angles to detect a face
  28981. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28982. * @returns the current InstancedLinesMesh
  28983. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28984. */
  28985. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28986. }
  28987. /**
  28988. * Defines the minimum contract an Edges renderer should follow.
  28989. */
  28990. export interface IEdgesRenderer extends IDisposable {
  28991. /**
  28992. * Gets or sets a boolean indicating if the edgesRenderer is active
  28993. */
  28994. isEnabled: boolean;
  28995. /**
  28996. * Renders the edges of the attached mesh,
  28997. */
  28998. render(): void;
  28999. /**
  29000. * Checks wether or not the edges renderer is ready to render.
  29001. * @return true if ready, otherwise false.
  29002. */
  29003. isReady(): boolean;
  29004. /**
  29005. * List of instances to render in case the source mesh has instances
  29006. */
  29007. customInstances: SmartArray<Matrix>;
  29008. }
  29009. /**
  29010. * Defines the additional options of the edges renderer
  29011. */
  29012. export interface IEdgesRendererOptions {
  29013. /**
  29014. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29015. * If not defined, the default value is true
  29016. */
  29017. useAlternateEdgeFinder?: boolean;
  29018. /**
  29019. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29020. * If not defined, the default value is true.
  29021. * 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)
  29022. * This option is used only if useAlternateEdgeFinder = true
  29023. */
  29024. useFastVertexMerger?: boolean;
  29025. /**
  29026. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29027. * The default value is 1e-6
  29028. * This option is used only if useAlternateEdgeFinder = true
  29029. */
  29030. epsilonVertexMerge?: number;
  29031. /**
  29032. * 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
  29033. * 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.
  29034. * This option is used only if useAlternateEdgeFinder = true
  29035. */
  29036. applyTessellation?: boolean;
  29037. /**
  29038. * 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
  29039. * The default value is 1e-6
  29040. * This option is used only if useAlternateEdgeFinder = true
  29041. */
  29042. epsilonVertexAligned?: number;
  29043. }
  29044. /**
  29045. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29046. */
  29047. export class EdgesRenderer implements IEdgesRenderer {
  29048. /**
  29049. * Define the size of the edges with an orthographic camera
  29050. */
  29051. edgesWidthScalerForOrthographic: number;
  29052. /**
  29053. * Define the size of the edges with a perspective camera
  29054. */
  29055. edgesWidthScalerForPerspective: number;
  29056. protected _source: AbstractMesh;
  29057. protected _linesPositions: number[];
  29058. protected _linesNormals: number[];
  29059. protected _linesIndices: number[];
  29060. protected _epsilon: number;
  29061. protected _indicesCount: number;
  29062. protected _lineShader: ShaderMaterial;
  29063. protected _ib: DataBuffer;
  29064. protected _buffers: {
  29065. [key: string]: Nullable<VertexBuffer>;
  29066. };
  29067. protected _buffersForInstances: {
  29068. [key: string]: Nullable<VertexBuffer>;
  29069. };
  29070. protected _checkVerticesInsteadOfIndices: boolean;
  29071. protected _options: Nullable<IEdgesRendererOptions>;
  29072. private _meshRebuildObserver;
  29073. private _meshDisposeObserver;
  29074. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29075. isEnabled: boolean;
  29076. /** Gets the vertices generated by the edge renderer */
  29077. get linesPositions(): Immutable<Array<number>>;
  29078. /** Gets the normals generated by the edge renderer */
  29079. get linesNormals(): Immutable<Array<number>>;
  29080. /** Gets the indices generated by the edge renderer */
  29081. get linesIndices(): Immutable<Array<number>>;
  29082. /**
  29083. * List of instances to render in case the source mesh has instances
  29084. */
  29085. customInstances: SmartArray<Matrix>;
  29086. private static GetShader;
  29087. /**
  29088. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29089. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29090. * @param source Mesh used to create edges
  29091. * @param epsilon sum of angles in adjacency to check for edge
  29092. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29093. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29094. * @param options The options to apply when generating the edges
  29095. */
  29096. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29097. protected _prepareRessources(): void;
  29098. /** @hidden */
  29099. _rebuild(): void;
  29100. /**
  29101. * Releases the required resources for the edges renderer
  29102. */
  29103. dispose(): void;
  29104. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29105. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29106. /**
  29107. * Checks if the pair of p0 and p1 is en edge
  29108. * @param faceIndex
  29109. * @param edge
  29110. * @param faceNormals
  29111. * @param p0
  29112. * @param p1
  29113. * @private
  29114. */
  29115. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29116. /**
  29117. * push line into the position, normal and index buffer
  29118. * @protected
  29119. */
  29120. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29121. /**
  29122. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29123. */
  29124. private _tessellateTriangle;
  29125. private _generateEdgesLinesAlternate;
  29126. /**
  29127. * Generates lines edges from adjacencjes
  29128. * @private
  29129. */
  29130. _generateEdgesLines(): void;
  29131. /**
  29132. * Checks wether or not the edges renderer is ready to render.
  29133. * @return true if ready, otherwise false.
  29134. */
  29135. isReady(): boolean;
  29136. /**
  29137. * Renders the edges of the attached mesh,
  29138. */
  29139. render(): void;
  29140. }
  29141. /**
  29142. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29143. */
  29144. export class LineEdgesRenderer extends EdgesRenderer {
  29145. /**
  29146. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29147. * @param source LineMesh used to generate edges
  29148. * @param epsilon not important (specified angle for edge detection)
  29149. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29150. */
  29151. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29152. /**
  29153. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29154. */
  29155. _generateEdgesLines(): void;
  29156. }
  29157. }
  29158. declare module BABYLON {
  29159. /**
  29160. * This represents the object necessary to create a rendering group.
  29161. * This is exclusively used and created by the rendering manager.
  29162. * To modify the behavior, you use the available helpers in your scene or meshes.
  29163. * @hidden
  29164. */
  29165. export class RenderingGroup {
  29166. index: number;
  29167. private static _zeroVector;
  29168. private _scene;
  29169. private _opaqueSubMeshes;
  29170. private _transparentSubMeshes;
  29171. private _alphaTestSubMeshes;
  29172. private _depthOnlySubMeshes;
  29173. private _particleSystems;
  29174. private _spriteManagers;
  29175. private _opaqueSortCompareFn;
  29176. private _alphaTestSortCompareFn;
  29177. private _transparentSortCompareFn;
  29178. private _renderOpaque;
  29179. private _renderAlphaTest;
  29180. private _renderTransparent;
  29181. /** @hidden */
  29182. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29183. onBeforeTransparentRendering: () => void;
  29184. /**
  29185. * Set the opaque sort comparison function.
  29186. * If null the sub meshes will be render in the order they were created
  29187. */
  29188. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29189. /**
  29190. * Set the alpha test sort comparison function.
  29191. * If null the sub meshes will be render in the order they were created
  29192. */
  29193. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29194. /**
  29195. * Set the transparent sort comparison function.
  29196. * If null the sub meshes will be render in the order they were created
  29197. */
  29198. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29199. /**
  29200. * Creates a new rendering group.
  29201. * @param index The rendering group index
  29202. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29203. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29204. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29205. */
  29206. 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>);
  29207. /**
  29208. * Render all the sub meshes contained in the group.
  29209. * @param customRenderFunction Used to override the default render behaviour of the group.
  29210. * @returns true if rendered some submeshes.
  29211. */
  29212. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29213. /**
  29214. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29215. * @param subMeshes The submeshes to render
  29216. */
  29217. private renderOpaqueSorted;
  29218. /**
  29219. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29220. * @param subMeshes The submeshes to render
  29221. */
  29222. private renderAlphaTestSorted;
  29223. /**
  29224. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29225. * @param subMeshes The submeshes to render
  29226. */
  29227. private renderTransparentSorted;
  29228. /**
  29229. * Renders the submeshes in a specified order.
  29230. * @param subMeshes The submeshes to sort before render
  29231. * @param sortCompareFn The comparison function use to sort
  29232. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29233. * @param transparent Specifies to activate blending if true
  29234. */
  29235. private static renderSorted;
  29236. /**
  29237. * Renders the submeshes in the order they were dispatched (no sort applied).
  29238. * @param subMeshes The submeshes to render
  29239. */
  29240. private static renderUnsorted;
  29241. /**
  29242. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29243. * are rendered back to front if in the same alpha index.
  29244. *
  29245. * @param a The first submesh
  29246. * @param b The second submesh
  29247. * @returns The result of the comparison
  29248. */
  29249. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29250. /**
  29251. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29252. * are rendered back to front.
  29253. *
  29254. * @param a The first submesh
  29255. * @param b The second submesh
  29256. * @returns The result of the comparison
  29257. */
  29258. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29259. /**
  29260. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29261. * are rendered front to back (prevent overdraw).
  29262. *
  29263. * @param a The first submesh
  29264. * @param b The second submesh
  29265. * @returns The result of the comparison
  29266. */
  29267. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29268. /**
  29269. * Resets the different lists of submeshes to prepare a new frame.
  29270. */
  29271. prepare(): void;
  29272. dispose(): void;
  29273. /**
  29274. * Inserts the submesh in its correct queue depending on its material.
  29275. * @param subMesh The submesh to dispatch
  29276. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29277. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29278. */
  29279. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29280. dispatchSprites(spriteManager: ISpriteManager): void;
  29281. dispatchParticles(particleSystem: IParticleSystem): void;
  29282. private _renderParticles;
  29283. private _renderSprites;
  29284. }
  29285. }
  29286. declare module BABYLON {
  29287. /**
  29288. * Interface describing the different options available in the rendering manager
  29289. * regarding Auto Clear between groups.
  29290. */
  29291. export interface IRenderingManagerAutoClearSetup {
  29292. /**
  29293. * Defines whether or not autoclear is enable.
  29294. */
  29295. autoClear: boolean;
  29296. /**
  29297. * Defines whether or not to autoclear the depth buffer.
  29298. */
  29299. depth: boolean;
  29300. /**
  29301. * Defines whether or not to autoclear the stencil buffer.
  29302. */
  29303. stencil: boolean;
  29304. }
  29305. /**
  29306. * This class is used by the onRenderingGroupObservable
  29307. */
  29308. export class RenderingGroupInfo {
  29309. /**
  29310. * The Scene that being rendered
  29311. */
  29312. scene: Scene;
  29313. /**
  29314. * The camera currently used for the rendering pass
  29315. */
  29316. camera: Nullable<Camera>;
  29317. /**
  29318. * The ID of the renderingGroup being processed
  29319. */
  29320. renderingGroupId: number;
  29321. }
  29322. /**
  29323. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29324. * It is enable to manage the different groups as well as the different necessary sort functions.
  29325. * This should not be used directly aside of the few static configurations
  29326. */
  29327. export class RenderingManager {
  29328. /**
  29329. * The max id used for rendering groups (not included)
  29330. */
  29331. static MAX_RENDERINGGROUPS: number;
  29332. /**
  29333. * The min id used for rendering groups (included)
  29334. */
  29335. static MIN_RENDERINGGROUPS: number;
  29336. /**
  29337. * Used to globally prevent autoclearing scenes.
  29338. */
  29339. static AUTOCLEAR: boolean;
  29340. /**
  29341. * @hidden
  29342. */
  29343. _useSceneAutoClearSetup: boolean;
  29344. private _scene;
  29345. private _renderingGroups;
  29346. private _depthStencilBufferAlreadyCleaned;
  29347. private _autoClearDepthStencil;
  29348. private _customOpaqueSortCompareFn;
  29349. private _customAlphaTestSortCompareFn;
  29350. private _customTransparentSortCompareFn;
  29351. private _renderingGroupInfo;
  29352. /**
  29353. * Instantiates a new rendering group for a particular scene
  29354. * @param scene Defines the scene the groups belongs to
  29355. */
  29356. constructor(scene: Scene);
  29357. private _clearDepthStencilBuffer;
  29358. /**
  29359. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29360. * @hidden
  29361. */
  29362. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29363. /**
  29364. * Resets the different information of the group to prepare a new frame
  29365. * @hidden
  29366. */
  29367. reset(): void;
  29368. /**
  29369. * Dispose and release the group and its associated resources.
  29370. * @hidden
  29371. */
  29372. dispose(): void;
  29373. /**
  29374. * Clear the info related to rendering groups preventing retention points during dispose.
  29375. */
  29376. freeRenderingGroups(): void;
  29377. private _prepareRenderingGroup;
  29378. /**
  29379. * Add a sprite manager to the rendering manager in order to render it this frame.
  29380. * @param spriteManager Define the sprite manager to render
  29381. */
  29382. dispatchSprites(spriteManager: ISpriteManager): void;
  29383. /**
  29384. * Add a particle system to the rendering manager in order to render it this frame.
  29385. * @param particleSystem Define the particle system to render
  29386. */
  29387. dispatchParticles(particleSystem: IParticleSystem): void;
  29388. /**
  29389. * Add a submesh to the manager in order to render it this frame
  29390. * @param subMesh The submesh to dispatch
  29391. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29392. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29393. */
  29394. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29395. /**
  29396. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29397. * This allowed control for front to back rendering or reversly depending of the special needs.
  29398. *
  29399. * @param renderingGroupId The rendering group id corresponding to its index
  29400. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29401. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29402. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29403. */
  29404. 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;
  29405. /**
  29406. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29407. *
  29408. * @param renderingGroupId The rendering group id corresponding to its index
  29409. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29410. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29411. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29412. */
  29413. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29414. /**
  29415. * Gets the current auto clear configuration for one rendering group of the rendering
  29416. * manager.
  29417. * @param index the rendering group index to get the information for
  29418. * @returns The auto clear setup for the requested rendering group
  29419. */
  29420. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29421. }
  29422. }
  29423. declare module BABYLON {
  29424. /**
  29425. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29426. */
  29427. export interface ICustomShaderOptions {
  29428. /**
  29429. * Gets or sets the custom shader name to use
  29430. */
  29431. shaderName: string;
  29432. /**
  29433. * The list of attribute names used in the shader
  29434. */
  29435. attributes?: string[];
  29436. /**
  29437. * The list of unifrom names used in the shader
  29438. */
  29439. uniforms?: string[];
  29440. /**
  29441. * The list of sampler names used in the shader
  29442. */
  29443. samplers?: string[];
  29444. /**
  29445. * The list of defines used in the shader
  29446. */
  29447. defines?: string[];
  29448. }
  29449. /**
  29450. * Interface to implement to create a shadow generator compatible with BJS.
  29451. */
  29452. export interface IShadowGenerator {
  29453. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29454. id: string;
  29455. /**
  29456. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29457. * @returns The render target texture if present otherwise, null
  29458. */
  29459. getShadowMap(): Nullable<RenderTargetTexture>;
  29460. /**
  29461. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29462. * @param subMesh The submesh we want to render in the shadow map
  29463. * @param useInstances Defines wether will draw in the map using instances
  29464. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29465. * @returns true if ready otherwise, false
  29466. */
  29467. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29468. /**
  29469. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29470. * @param defines Defines of the material we want to update
  29471. * @param lightIndex Index of the light in the enabled light list of the material
  29472. */
  29473. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29474. /**
  29475. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29476. * defined in the generator but impacting the effect).
  29477. * It implies the unifroms available on the materials are the standard BJS ones.
  29478. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29479. * @param effect The effect we are binfing the information for
  29480. */
  29481. bindShadowLight(lightIndex: string, effect: Effect): void;
  29482. /**
  29483. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29484. * (eq to shadow prjection matrix * light transform matrix)
  29485. * @returns The transform matrix used to create the shadow map
  29486. */
  29487. getTransformMatrix(): Matrix;
  29488. /**
  29489. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29490. * Cube and 2D textures for instance.
  29491. */
  29492. recreateShadowMap(): void;
  29493. /**
  29494. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29495. * @param onCompiled Callback triggered at the and of the effects compilation
  29496. * @param options Sets of optional options forcing the compilation with different modes
  29497. */
  29498. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29499. useInstances: boolean;
  29500. }>): void;
  29501. /**
  29502. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29503. * @param options Sets of optional options forcing the compilation with different modes
  29504. * @returns A promise that resolves when the compilation completes
  29505. */
  29506. forceCompilationAsync(options?: Partial<{
  29507. useInstances: boolean;
  29508. }>): Promise<void>;
  29509. /**
  29510. * Serializes the shadow generator setup to a json object.
  29511. * @returns The serialized JSON object
  29512. */
  29513. serialize(): any;
  29514. /**
  29515. * Disposes the Shadow map and related Textures and effects.
  29516. */
  29517. dispose(): void;
  29518. }
  29519. /**
  29520. * Default implementation IShadowGenerator.
  29521. * This is the main object responsible of generating shadows in the framework.
  29522. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29523. */
  29524. export class ShadowGenerator implements IShadowGenerator {
  29525. private static _Counter;
  29526. /**
  29527. * Name of the shadow generator class
  29528. */
  29529. static CLASSNAME: string;
  29530. /**
  29531. * Shadow generator mode None: no filtering applied.
  29532. */
  29533. static readonly FILTER_NONE: number;
  29534. /**
  29535. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29536. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29537. */
  29538. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29539. /**
  29540. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29541. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29542. */
  29543. static readonly FILTER_POISSONSAMPLING: number;
  29544. /**
  29545. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29546. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29547. */
  29548. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29549. /**
  29550. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29551. * edge artifacts on steep falloff.
  29552. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29553. */
  29554. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29555. /**
  29556. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29557. * edge artifacts on steep falloff.
  29558. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29559. */
  29560. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29561. /**
  29562. * Shadow generator mode PCF: Percentage Closer Filtering
  29563. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29564. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29565. */
  29566. static readonly FILTER_PCF: number;
  29567. /**
  29568. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29569. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29570. * Contact Hardening
  29571. */
  29572. static readonly FILTER_PCSS: number;
  29573. /**
  29574. * Reserved for PCF and PCSS
  29575. * Highest Quality.
  29576. *
  29577. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29578. *
  29579. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29580. */
  29581. static readonly QUALITY_HIGH: number;
  29582. /**
  29583. * Reserved for PCF and PCSS
  29584. * Good tradeoff for quality/perf cross devices
  29585. *
  29586. * Execute PCF on a 3*3 kernel.
  29587. *
  29588. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29589. */
  29590. static readonly QUALITY_MEDIUM: number;
  29591. /**
  29592. * Reserved for PCF and PCSS
  29593. * The lowest quality but the fastest.
  29594. *
  29595. * Execute PCF on a 1*1 kernel.
  29596. *
  29597. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29598. */
  29599. static readonly QUALITY_LOW: number;
  29600. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29601. id: string;
  29602. /** Gets or sets the custom shader name to use */
  29603. customShaderOptions: ICustomShaderOptions;
  29604. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29605. customAllowRendering: (subMesh: SubMesh) => boolean;
  29606. /**
  29607. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29608. */
  29609. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29610. /**
  29611. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29612. */
  29613. onAfterShadowMapRenderObservable: Observable<Effect>;
  29614. /**
  29615. * Observable triggered before a mesh is rendered in the shadow map.
  29616. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29617. */
  29618. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29619. /**
  29620. * Observable triggered after a mesh is rendered in the shadow map.
  29621. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29622. */
  29623. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29624. protected _bias: number;
  29625. /**
  29626. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29627. */
  29628. get bias(): number;
  29629. /**
  29630. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29631. */
  29632. set bias(bias: number);
  29633. protected _normalBias: number;
  29634. /**
  29635. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29636. */
  29637. get normalBias(): number;
  29638. /**
  29639. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29640. */
  29641. set normalBias(normalBias: number);
  29642. protected _blurBoxOffset: number;
  29643. /**
  29644. * Gets the blur box offset: offset applied during the blur pass.
  29645. * Only useful if useKernelBlur = false
  29646. */
  29647. get blurBoxOffset(): number;
  29648. /**
  29649. * Sets the blur box offset: offset applied during the blur pass.
  29650. * Only useful if useKernelBlur = false
  29651. */
  29652. set blurBoxOffset(value: number);
  29653. protected _blurScale: number;
  29654. /**
  29655. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29656. * 2 means half of the size.
  29657. */
  29658. get blurScale(): number;
  29659. /**
  29660. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29661. * 2 means half of the size.
  29662. */
  29663. set blurScale(value: number);
  29664. protected _blurKernel: number;
  29665. /**
  29666. * Gets the blur kernel: kernel size of the blur pass.
  29667. * Only useful if useKernelBlur = true
  29668. */
  29669. get blurKernel(): number;
  29670. /**
  29671. * Sets the blur kernel: kernel size of the blur pass.
  29672. * Only useful if useKernelBlur = true
  29673. */
  29674. set blurKernel(value: number);
  29675. protected _useKernelBlur: boolean;
  29676. /**
  29677. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29678. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29679. */
  29680. get useKernelBlur(): boolean;
  29681. /**
  29682. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29683. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29684. */
  29685. set useKernelBlur(value: boolean);
  29686. protected _depthScale: number;
  29687. /**
  29688. * Gets the depth scale used in ESM mode.
  29689. */
  29690. get depthScale(): number;
  29691. /**
  29692. * Sets the depth scale used in ESM mode.
  29693. * This can override the scale stored on the light.
  29694. */
  29695. set depthScale(value: number);
  29696. protected _validateFilter(filter: number): number;
  29697. protected _filter: number;
  29698. /**
  29699. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29700. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29701. */
  29702. get filter(): number;
  29703. /**
  29704. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29705. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29706. */
  29707. set filter(value: number);
  29708. /**
  29709. * Gets if the current filter is set to Poisson Sampling.
  29710. */
  29711. get usePoissonSampling(): boolean;
  29712. /**
  29713. * Sets the current filter to Poisson Sampling.
  29714. */
  29715. set usePoissonSampling(value: boolean);
  29716. /**
  29717. * Gets if the current filter is set to ESM.
  29718. */
  29719. get useExponentialShadowMap(): boolean;
  29720. /**
  29721. * Sets the current filter is to ESM.
  29722. */
  29723. set useExponentialShadowMap(value: boolean);
  29724. /**
  29725. * Gets if the current filter is set to filtered ESM.
  29726. */
  29727. get useBlurExponentialShadowMap(): boolean;
  29728. /**
  29729. * Gets if the current filter is set to filtered ESM.
  29730. */
  29731. set useBlurExponentialShadowMap(value: boolean);
  29732. /**
  29733. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29734. * exponential to prevent steep falloff artifacts).
  29735. */
  29736. get useCloseExponentialShadowMap(): boolean;
  29737. /**
  29738. * Sets the current filter to "close ESM" (using the inverse of the
  29739. * exponential to prevent steep falloff artifacts).
  29740. */
  29741. set useCloseExponentialShadowMap(value: boolean);
  29742. /**
  29743. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29744. * exponential to prevent steep falloff artifacts).
  29745. */
  29746. get useBlurCloseExponentialShadowMap(): boolean;
  29747. /**
  29748. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29749. * exponential to prevent steep falloff artifacts).
  29750. */
  29751. set useBlurCloseExponentialShadowMap(value: boolean);
  29752. /**
  29753. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29754. */
  29755. get usePercentageCloserFiltering(): boolean;
  29756. /**
  29757. * Sets the current filter to "PCF" (percentage closer filtering).
  29758. */
  29759. set usePercentageCloserFiltering(value: boolean);
  29760. protected _filteringQuality: number;
  29761. /**
  29762. * Gets the PCF or PCSS Quality.
  29763. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29764. */
  29765. get filteringQuality(): number;
  29766. /**
  29767. * Sets the PCF or PCSS Quality.
  29768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29769. */
  29770. set filteringQuality(filteringQuality: number);
  29771. /**
  29772. * Gets if the current filter is set to "PCSS" (contact hardening).
  29773. */
  29774. get useContactHardeningShadow(): boolean;
  29775. /**
  29776. * Sets the current filter to "PCSS" (contact hardening).
  29777. */
  29778. set useContactHardeningShadow(value: boolean);
  29779. protected _contactHardeningLightSizeUVRatio: number;
  29780. /**
  29781. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29782. * Using a ratio helps keeping shape stability independently of the map size.
  29783. *
  29784. * It does not account for the light projection as it was having too much
  29785. * instability during the light setup or during light position changes.
  29786. *
  29787. * Only valid if useContactHardeningShadow is true.
  29788. */
  29789. get contactHardeningLightSizeUVRatio(): number;
  29790. /**
  29791. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29792. * Using a ratio helps keeping shape stability independently of the map size.
  29793. *
  29794. * It does not account for the light projection as it was having too much
  29795. * instability during the light setup or during light position changes.
  29796. *
  29797. * Only valid if useContactHardeningShadow is true.
  29798. */
  29799. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29800. protected _darkness: number;
  29801. /** Gets or sets the actual darkness of a shadow */
  29802. get darkness(): number;
  29803. set darkness(value: number);
  29804. /**
  29805. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29806. * 0 means strongest and 1 would means no shadow.
  29807. * @returns the darkness.
  29808. */
  29809. getDarkness(): number;
  29810. /**
  29811. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29812. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29813. * @returns the shadow generator allowing fluent coding.
  29814. */
  29815. setDarkness(darkness: number): ShadowGenerator;
  29816. protected _transparencyShadow: boolean;
  29817. /** Gets or sets the ability to have transparent shadow */
  29818. get transparencyShadow(): boolean;
  29819. set transparencyShadow(value: boolean);
  29820. /**
  29821. * Sets the ability to have transparent shadow (boolean).
  29822. * @param transparent True if transparent else False
  29823. * @returns the shadow generator allowing fluent coding
  29824. */
  29825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29826. /**
  29827. * Enables or disables shadows with varying strength based on the transparency
  29828. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29829. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29830. * mesh.visibility * alphaTexture.a
  29831. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29832. */
  29833. enableSoftTransparentShadow: boolean;
  29834. protected _shadowMap: Nullable<RenderTargetTexture>;
  29835. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29836. /**
  29837. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29838. * @returns The render target texture if present otherwise, null
  29839. */
  29840. getShadowMap(): Nullable<RenderTargetTexture>;
  29841. /**
  29842. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29843. * @returns The render target texture if the shadow map is present otherwise, null
  29844. */
  29845. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29846. /**
  29847. * Gets the class name of that object
  29848. * @returns "ShadowGenerator"
  29849. */
  29850. getClassName(): string;
  29851. /**
  29852. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29853. * @param mesh Mesh to add
  29854. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29855. * @returns the Shadow Generator itself
  29856. */
  29857. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29858. /**
  29859. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29860. * @param mesh Mesh to remove
  29861. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29862. * @returns the Shadow Generator itself
  29863. */
  29864. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29865. /**
  29866. * Controls the extent to which the shadows fade out at the edge of the frustum
  29867. */
  29868. frustumEdgeFalloff: number;
  29869. protected _light: IShadowLight;
  29870. /**
  29871. * Returns the associated light object.
  29872. * @returns the light generating the shadow
  29873. */
  29874. getLight(): IShadowLight;
  29875. /**
  29876. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29877. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29878. * It might on the other hand introduce peter panning.
  29879. */
  29880. forceBackFacesOnly: boolean;
  29881. protected _scene: Scene;
  29882. protected _lightDirection: Vector3;
  29883. protected _viewMatrix: Matrix;
  29884. protected _projectionMatrix: Matrix;
  29885. protected _transformMatrix: Matrix;
  29886. protected _cachedPosition: Vector3;
  29887. protected _cachedDirection: Vector3;
  29888. protected _cachedDefines: string;
  29889. protected _currentRenderID: number;
  29890. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29891. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29892. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29893. protected _blurPostProcesses: PostProcess[];
  29894. protected _mapSize: number;
  29895. protected _currentFaceIndex: number;
  29896. protected _currentFaceIndexCache: number;
  29897. protected _textureType: number;
  29898. protected _defaultTextureMatrix: Matrix;
  29899. protected _storedUniqueId: Nullable<number>;
  29900. protected _nameForCustomEffect: string;
  29901. /** @hidden */
  29902. static _SceneComponentInitialization: (scene: Scene) => void;
  29903. /**
  29904. * Gets or sets the size of the texture what stores the shadows
  29905. */
  29906. get mapSize(): number;
  29907. set mapSize(size: number);
  29908. /**
  29909. * Creates a ShadowGenerator object.
  29910. * A ShadowGenerator is the required tool to use the shadows.
  29911. * Each light casting shadows needs to use its own ShadowGenerator.
  29912. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29913. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29914. * @param light The light object generating the shadows.
  29915. * @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.
  29916. */
  29917. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29918. protected _initializeGenerator(): void;
  29919. protected _createTargetRenderTexture(): void;
  29920. protected _initializeShadowMap(): void;
  29921. protected _initializeBlurRTTAndPostProcesses(): void;
  29922. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29923. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29924. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29925. protected _applyFilterValues(): void;
  29926. /**
  29927. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29928. * @param onCompiled Callback triggered at the and of the effects compilation
  29929. * @param options Sets of optional options forcing the compilation with different modes
  29930. */
  29931. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29932. useInstances: boolean;
  29933. }>): void;
  29934. /**
  29935. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29936. * @param options Sets of optional options forcing the compilation with different modes
  29937. * @returns A promise that resolves when the compilation completes
  29938. */
  29939. forceCompilationAsync(options?: Partial<{
  29940. useInstances: boolean;
  29941. }>): Promise<void>;
  29942. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29943. private _prepareShadowDefines;
  29944. /**
  29945. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29946. * @param subMesh The submesh we want to render in the shadow map
  29947. * @param useInstances Defines wether will draw in the map using instances
  29948. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29949. * @returns true if ready otherwise, false
  29950. */
  29951. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29952. /**
  29953. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29954. * @param defines Defines of the material we want to update
  29955. * @param lightIndex Index of the light in the enabled light list of the material
  29956. */
  29957. prepareDefines(defines: any, lightIndex: number): void;
  29958. /**
  29959. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29960. * defined in the generator but impacting the effect).
  29961. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29962. * @param effect The effect we are binfing the information for
  29963. */
  29964. bindShadowLight(lightIndex: string, effect: Effect): void;
  29965. /**
  29966. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29967. * (eq to shadow prjection matrix * light transform matrix)
  29968. * @returns The transform matrix used to create the shadow map
  29969. */
  29970. getTransformMatrix(): Matrix;
  29971. /**
  29972. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29973. * Cube and 2D textures for instance.
  29974. */
  29975. recreateShadowMap(): void;
  29976. protected _disposeBlurPostProcesses(): void;
  29977. protected _disposeRTTandPostProcesses(): void;
  29978. /**
  29979. * Disposes the ShadowGenerator.
  29980. * Returns nothing.
  29981. */
  29982. dispose(): void;
  29983. /**
  29984. * Serializes the shadow generator setup to a json object.
  29985. * @returns The serialized JSON object
  29986. */
  29987. serialize(): any;
  29988. /**
  29989. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29990. * @param parsedShadowGenerator The JSON object to parse
  29991. * @param scene The scene to create the shadow map for
  29992. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29993. * @returns The parsed shadow generator
  29994. */
  29995. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. /**
  30000. * Options to be used when creating a shadow depth material
  30001. */
  30002. export interface IIOptionShadowDepthMaterial {
  30003. /** Variables in the vertex shader code that need to have their names remapped.
  30004. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30005. * "var_name" should be either: worldPos or vNormalW
  30006. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30007. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30008. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30009. */
  30010. remappedVariables?: string[];
  30011. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30012. standalone?: boolean;
  30013. }
  30014. /**
  30015. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30016. */
  30017. export class ShadowDepthWrapper {
  30018. private _scene;
  30019. private _options?;
  30020. private _baseMaterial;
  30021. private _onEffectCreatedObserver;
  30022. private _subMeshToEffect;
  30023. private _subMeshToDepthEffect;
  30024. private _meshes;
  30025. /** @hidden */
  30026. _matriceNames: any;
  30027. /** Gets the standalone status of the wrapper */
  30028. get standalone(): boolean;
  30029. /** Gets the base material the wrapper is built upon */
  30030. get baseMaterial(): Material;
  30031. /**
  30032. * Instantiate a new shadow depth wrapper.
  30033. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30034. * generate the shadow depth map. For more information, please refer to the documentation:
  30035. * https://doc.babylonjs.com/babylon101/shadows
  30036. * @param baseMaterial Material to wrap
  30037. * @param scene Define the scene the material belongs to
  30038. * @param options Options used to create the wrapper
  30039. */
  30040. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30041. /**
  30042. * Gets the effect to use to generate the depth map
  30043. * @param subMesh subMesh to get the effect for
  30044. * @param shadowGenerator shadow generator to get the effect for
  30045. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30046. */
  30047. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30048. /**
  30049. * Specifies that the submesh is ready to be used for depth rendering
  30050. * @param subMesh submesh to check
  30051. * @param defines the list of defines to take into account when checking the effect
  30052. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30053. * @param useInstances specifies that instances should be used
  30054. * @returns a boolean indicating that the submesh is ready or not
  30055. */
  30056. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30057. /**
  30058. * Disposes the resources
  30059. */
  30060. dispose(): void;
  30061. private _makeEffect;
  30062. }
  30063. }
  30064. declare module BABYLON {
  30065. /**
  30066. * Options for compiling materials.
  30067. */
  30068. export interface IMaterialCompilationOptions {
  30069. /**
  30070. * Defines whether clip planes are enabled.
  30071. */
  30072. clipPlane: boolean;
  30073. /**
  30074. * Defines whether instances are enabled.
  30075. */
  30076. useInstances: boolean;
  30077. }
  30078. /**
  30079. * Options passed when calling customShaderNameResolve
  30080. */
  30081. export interface ICustomShaderNameResolveOptions {
  30082. /**
  30083. * 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
  30084. */
  30085. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30086. }
  30087. /**
  30088. * Base class for the main features of a material in Babylon.js
  30089. */
  30090. export class Material implements IAnimatable {
  30091. /**
  30092. * Returns the triangle fill mode
  30093. */
  30094. static readonly TriangleFillMode: number;
  30095. /**
  30096. * Returns the wireframe mode
  30097. */
  30098. static readonly WireFrameFillMode: number;
  30099. /**
  30100. * Returns the point fill mode
  30101. */
  30102. static readonly PointFillMode: number;
  30103. /**
  30104. * Returns the point list draw mode
  30105. */
  30106. static readonly PointListDrawMode: number;
  30107. /**
  30108. * Returns the line list draw mode
  30109. */
  30110. static readonly LineListDrawMode: number;
  30111. /**
  30112. * Returns the line loop draw mode
  30113. */
  30114. static readonly LineLoopDrawMode: number;
  30115. /**
  30116. * Returns the line strip draw mode
  30117. */
  30118. static readonly LineStripDrawMode: number;
  30119. /**
  30120. * Returns the triangle strip draw mode
  30121. */
  30122. static readonly TriangleStripDrawMode: number;
  30123. /**
  30124. * Returns the triangle fan draw mode
  30125. */
  30126. static readonly TriangleFanDrawMode: number;
  30127. /**
  30128. * Stores the clock-wise side orientation
  30129. */
  30130. static readonly ClockWiseSideOrientation: number;
  30131. /**
  30132. * Stores the counter clock-wise side orientation
  30133. */
  30134. static readonly CounterClockWiseSideOrientation: number;
  30135. /**
  30136. * The dirty texture flag value
  30137. */
  30138. static readonly TextureDirtyFlag: number;
  30139. /**
  30140. * The dirty light flag value
  30141. */
  30142. static readonly LightDirtyFlag: number;
  30143. /**
  30144. * The dirty fresnel flag value
  30145. */
  30146. static readonly FresnelDirtyFlag: number;
  30147. /**
  30148. * The dirty attribute flag value
  30149. */
  30150. static readonly AttributesDirtyFlag: number;
  30151. /**
  30152. * The dirty misc flag value
  30153. */
  30154. static readonly MiscDirtyFlag: number;
  30155. /**
  30156. * The dirty prepass flag value
  30157. */
  30158. static readonly PrePassDirtyFlag: number;
  30159. /**
  30160. * The all dirty flag value
  30161. */
  30162. static readonly AllDirtyFlag: number;
  30163. /**
  30164. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30165. */
  30166. static readonly MATERIAL_OPAQUE: number;
  30167. /**
  30168. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30169. */
  30170. static readonly MATERIAL_ALPHATEST: number;
  30171. /**
  30172. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30173. */
  30174. static readonly MATERIAL_ALPHABLEND: number;
  30175. /**
  30176. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30177. * They are also discarded below the alpha cutoff threshold to improve performances.
  30178. */
  30179. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30180. /**
  30181. * The Whiteout method is used to blend normals.
  30182. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30183. */
  30184. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30185. /**
  30186. * The Reoriented Normal Mapping method is used to blend normals.
  30187. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30188. */
  30189. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30190. /**
  30191. * Custom callback helping to override the default shader used in the material.
  30192. */
  30193. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30194. /**
  30195. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30196. */
  30197. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30198. /**
  30199. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30200. * This means that the material can keep using a previous shader while a new one is being compiled.
  30201. * This is mostly used when shader parallel compilation is supported (true by default)
  30202. */
  30203. allowShaderHotSwapping: boolean;
  30204. /**
  30205. * The ID of the material
  30206. */
  30207. id: string;
  30208. /**
  30209. * Gets or sets the unique id of the material
  30210. */
  30211. uniqueId: number;
  30212. /**
  30213. * The name of the material
  30214. */
  30215. name: string;
  30216. /**
  30217. * Gets or sets user defined metadata
  30218. */
  30219. metadata: any;
  30220. /**
  30221. * For internal use only. Please do not use.
  30222. */
  30223. reservedDataStore: any;
  30224. /**
  30225. * Specifies if the ready state should be checked on each call
  30226. */
  30227. checkReadyOnEveryCall: boolean;
  30228. /**
  30229. * Specifies if the ready state should be checked once
  30230. */
  30231. checkReadyOnlyOnce: boolean;
  30232. /**
  30233. * The state of the material
  30234. */
  30235. state: string;
  30236. /**
  30237. * If the material can be rendered to several textures with MRT extension
  30238. */
  30239. get canRenderToMRT(): boolean;
  30240. /**
  30241. * The alpha value of the material
  30242. */
  30243. protected _alpha: number;
  30244. /**
  30245. * List of inspectable custom properties (used by the Inspector)
  30246. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30247. */
  30248. inspectableCustomProperties: IInspectable[];
  30249. /**
  30250. * Sets the alpha value of the material
  30251. */
  30252. set alpha(value: number);
  30253. /**
  30254. * Gets the alpha value of the material
  30255. */
  30256. get alpha(): number;
  30257. /**
  30258. * Specifies if back face culling is enabled
  30259. */
  30260. protected _backFaceCulling: boolean;
  30261. /**
  30262. * Sets the back-face culling state
  30263. */
  30264. set backFaceCulling(value: boolean);
  30265. /**
  30266. * Gets the back-face culling state
  30267. */
  30268. get backFaceCulling(): boolean;
  30269. /**
  30270. * Stores the value for side orientation
  30271. */
  30272. sideOrientation: number;
  30273. /**
  30274. * Callback triggered when the material is compiled
  30275. */
  30276. onCompiled: Nullable<(effect: Effect) => void>;
  30277. /**
  30278. * Callback triggered when an error occurs
  30279. */
  30280. onError: Nullable<(effect: Effect, errors: string) => void>;
  30281. /**
  30282. * Callback triggered to get the render target textures
  30283. */
  30284. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30285. /**
  30286. * Gets a boolean indicating that current material needs to register RTT
  30287. */
  30288. get hasRenderTargetTextures(): boolean;
  30289. /**
  30290. * Specifies if the material should be serialized
  30291. */
  30292. doNotSerialize: boolean;
  30293. /**
  30294. * @hidden
  30295. */
  30296. _storeEffectOnSubMeshes: boolean;
  30297. /**
  30298. * Stores the animations for the material
  30299. */
  30300. animations: Nullable<Array<Animation>>;
  30301. /**
  30302. * An event triggered when the material is disposed
  30303. */
  30304. onDisposeObservable: Observable<Material>;
  30305. /**
  30306. * An observer which watches for dispose events
  30307. */
  30308. private _onDisposeObserver;
  30309. private _onUnBindObservable;
  30310. /**
  30311. * Called during a dispose event
  30312. */
  30313. set onDispose(callback: () => void);
  30314. private _onBindObservable;
  30315. /**
  30316. * An event triggered when the material is bound
  30317. */
  30318. get onBindObservable(): Observable<AbstractMesh>;
  30319. /**
  30320. * An observer which watches for bind events
  30321. */
  30322. private _onBindObserver;
  30323. /**
  30324. * Called during a bind event
  30325. */
  30326. set onBind(callback: (Mesh: AbstractMesh) => void);
  30327. /**
  30328. * An event triggered when the material is unbound
  30329. */
  30330. get onUnBindObservable(): Observable<Material>;
  30331. protected _onEffectCreatedObservable: Nullable<Observable<{
  30332. effect: Effect;
  30333. subMesh: Nullable<SubMesh>;
  30334. }>>;
  30335. /**
  30336. * An event triggered when the effect is (re)created
  30337. */
  30338. get onEffectCreatedObservable(): Observable<{
  30339. effect: Effect;
  30340. subMesh: Nullable<SubMesh>;
  30341. }>;
  30342. /**
  30343. * Stores the value of the alpha mode
  30344. */
  30345. private _alphaMode;
  30346. /**
  30347. * Sets the value of the alpha mode.
  30348. *
  30349. * | Value | Type | Description |
  30350. * | --- | --- | --- |
  30351. * | 0 | ALPHA_DISABLE | |
  30352. * | 1 | ALPHA_ADD | |
  30353. * | 2 | ALPHA_COMBINE | |
  30354. * | 3 | ALPHA_SUBTRACT | |
  30355. * | 4 | ALPHA_MULTIPLY | |
  30356. * | 5 | ALPHA_MAXIMIZED | |
  30357. * | 6 | ALPHA_ONEONE | |
  30358. * | 7 | ALPHA_PREMULTIPLIED | |
  30359. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30360. * | 9 | ALPHA_INTERPOLATE | |
  30361. * | 10 | ALPHA_SCREENMODE | |
  30362. *
  30363. */
  30364. set alphaMode(value: number);
  30365. /**
  30366. * Gets the value of the alpha mode
  30367. */
  30368. get alphaMode(): number;
  30369. /**
  30370. * Stores the state of the need depth pre-pass value
  30371. */
  30372. private _needDepthPrePass;
  30373. /**
  30374. * Sets the need depth pre-pass value
  30375. */
  30376. set needDepthPrePass(value: boolean);
  30377. /**
  30378. * Gets the depth pre-pass value
  30379. */
  30380. get needDepthPrePass(): boolean;
  30381. /**
  30382. * Specifies if depth writing should be disabled
  30383. */
  30384. disableDepthWrite: boolean;
  30385. /**
  30386. * Specifies if color writing should be disabled
  30387. */
  30388. disableColorWrite: boolean;
  30389. /**
  30390. * Specifies if depth writing should be forced
  30391. */
  30392. forceDepthWrite: boolean;
  30393. /**
  30394. * Specifies the depth function that should be used. 0 means the default engine function
  30395. */
  30396. depthFunction: number;
  30397. /**
  30398. * Specifies if there should be a separate pass for culling
  30399. */
  30400. separateCullingPass: boolean;
  30401. /**
  30402. * Stores the state specifing if fog should be enabled
  30403. */
  30404. private _fogEnabled;
  30405. /**
  30406. * Sets the state for enabling fog
  30407. */
  30408. set fogEnabled(value: boolean);
  30409. /**
  30410. * Gets the value of the fog enabled state
  30411. */
  30412. get fogEnabled(): boolean;
  30413. /**
  30414. * Stores the size of points
  30415. */
  30416. pointSize: number;
  30417. /**
  30418. * Stores the z offset value
  30419. */
  30420. zOffset: number;
  30421. get wireframe(): boolean;
  30422. /**
  30423. * Sets the state of wireframe mode
  30424. */
  30425. set wireframe(value: boolean);
  30426. /**
  30427. * Gets the value specifying if point clouds are enabled
  30428. */
  30429. get pointsCloud(): boolean;
  30430. /**
  30431. * Sets the state of point cloud mode
  30432. */
  30433. set pointsCloud(value: boolean);
  30434. /**
  30435. * Gets the material fill mode
  30436. */
  30437. get fillMode(): number;
  30438. /**
  30439. * Sets the material fill mode
  30440. */
  30441. set fillMode(value: number);
  30442. /**
  30443. * @hidden
  30444. * Stores the effects for the material
  30445. */
  30446. _effect: Nullable<Effect>;
  30447. /**
  30448. * Specifies if uniform buffers should be used
  30449. */
  30450. private _useUBO;
  30451. /**
  30452. * Stores a reference to the scene
  30453. */
  30454. private _scene;
  30455. private _needToBindSceneUbo;
  30456. /**
  30457. * Stores the fill mode state
  30458. */
  30459. private _fillMode;
  30460. /**
  30461. * Specifies if the depth write state should be cached
  30462. */
  30463. private _cachedDepthWriteState;
  30464. /**
  30465. * Specifies if the color write state should be cached
  30466. */
  30467. private _cachedColorWriteState;
  30468. /**
  30469. * Specifies if the depth function state should be cached
  30470. */
  30471. private _cachedDepthFunctionState;
  30472. /**
  30473. * Stores the uniform buffer
  30474. */
  30475. protected _uniformBuffer: UniformBuffer;
  30476. /** @hidden */
  30477. _indexInSceneMaterialArray: number;
  30478. /** @hidden */
  30479. meshMap: Nullable<{
  30480. [id: string]: AbstractMesh | undefined;
  30481. }>;
  30482. /**
  30483. * Creates a material instance
  30484. * @param name defines the name of the material
  30485. * @param scene defines the scene to reference
  30486. * @param doNotAdd specifies if the material should be added to the scene
  30487. */
  30488. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30489. /**
  30490. * Returns a string representation of the current material
  30491. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30492. * @returns a string with material information
  30493. */
  30494. toString(fullDetails?: boolean): string;
  30495. /**
  30496. * Gets the class name of the material
  30497. * @returns a string with the class name of the material
  30498. */
  30499. getClassName(): string;
  30500. /**
  30501. * Specifies if updates for the material been locked
  30502. */
  30503. get isFrozen(): boolean;
  30504. /**
  30505. * Locks updates for the material
  30506. */
  30507. freeze(): void;
  30508. /**
  30509. * Unlocks updates for the material
  30510. */
  30511. unfreeze(): void;
  30512. /**
  30513. * Specifies if the material is ready to be used
  30514. * @param mesh defines the mesh to check
  30515. * @param useInstances specifies if instances should be used
  30516. * @returns a boolean indicating if the material is ready to be used
  30517. */
  30518. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30519. /**
  30520. * Specifies that the submesh is ready to be used
  30521. * @param mesh defines the mesh to check
  30522. * @param subMesh defines which submesh to check
  30523. * @param useInstances specifies that instances should be used
  30524. * @returns a boolean indicating that the submesh is ready or not
  30525. */
  30526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30527. /**
  30528. * Returns the material effect
  30529. * @returns the effect associated with the material
  30530. */
  30531. getEffect(): Nullable<Effect>;
  30532. /**
  30533. * Returns the current scene
  30534. * @returns a Scene
  30535. */
  30536. getScene(): Scene;
  30537. /**
  30538. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30539. */
  30540. protected _forceAlphaTest: boolean;
  30541. /**
  30542. * The transparency mode of the material.
  30543. */
  30544. protected _transparencyMode: Nullable<number>;
  30545. /**
  30546. * Gets the current transparency mode.
  30547. */
  30548. get transparencyMode(): Nullable<number>;
  30549. /**
  30550. * Sets the transparency mode of the material.
  30551. *
  30552. * | Value | Type | Description |
  30553. * | ----- | ----------------------------------- | ----------- |
  30554. * | 0 | OPAQUE | |
  30555. * | 1 | ALPHATEST | |
  30556. * | 2 | ALPHABLEND | |
  30557. * | 3 | ALPHATESTANDBLEND | |
  30558. *
  30559. */
  30560. set transparencyMode(value: Nullable<number>);
  30561. /**
  30562. * Returns true if alpha blending should be disabled.
  30563. */
  30564. protected get _disableAlphaBlending(): boolean;
  30565. /**
  30566. * Specifies whether or not this material should be rendered in alpha blend mode.
  30567. * @returns a boolean specifying if alpha blending is needed
  30568. */
  30569. needAlphaBlending(): boolean;
  30570. /**
  30571. * Specifies if the mesh will require alpha blending
  30572. * @param mesh defines the mesh to check
  30573. * @returns a boolean specifying if alpha blending is needed for the mesh
  30574. */
  30575. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30576. /**
  30577. * Specifies whether or not this material should be rendered in alpha test mode.
  30578. * @returns a boolean specifying if an alpha test is needed.
  30579. */
  30580. needAlphaTesting(): boolean;
  30581. /**
  30582. * Specifies if material alpha testing should be turned on for the mesh
  30583. * @param mesh defines the mesh to check
  30584. */
  30585. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30586. /**
  30587. * Gets the texture used for the alpha test
  30588. * @returns the texture to use for alpha testing
  30589. */
  30590. getAlphaTestTexture(): Nullable<BaseTexture>;
  30591. /**
  30592. * Marks the material to indicate that it needs to be re-calculated
  30593. */
  30594. markDirty(): void;
  30595. /** @hidden */
  30596. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30597. /**
  30598. * Binds the material to the mesh
  30599. * @param world defines the world transformation matrix
  30600. * @param mesh defines the mesh to bind the material to
  30601. */
  30602. bind(world: Matrix, mesh?: Mesh): void;
  30603. /**
  30604. * Binds the submesh to the material
  30605. * @param world defines the world transformation matrix
  30606. * @param mesh defines the mesh containing the submesh
  30607. * @param subMesh defines the submesh to bind the material to
  30608. */
  30609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30610. /**
  30611. * Binds the world matrix to the material
  30612. * @param world defines the world transformation matrix
  30613. */
  30614. bindOnlyWorldMatrix(world: Matrix): void;
  30615. /**
  30616. * Update the scene ubo before it can be used in rendering processing
  30617. * @param scene the scene to retrieve the ubo from
  30618. * @returns the scene UniformBuffer
  30619. */
  30620. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30621. /**
  30622. * Binds the scene's uniform buffer to the effect.
  30623. * @param effect defines the effect to bind to the scene uniform buffer
  30624. * @param sceneUbo defines the uniform buffer storing scene data
  30625. */
  30626. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30627. /**
  30628. * Binds the view matrix to the effect
  30629. * @param effect defines the effect to bind the view matrix to
  30630. */
  30631. bindView(effect: Effect): void;
  30632. /**
  30633. * Binds the view projection and projection matrices to the effect
  30634. * @param effect defines the effect to bind the view projection and projection matrices to
  30635. */
  30636. bindViewProjection(effect: Effect): void;
  30637. /**
  30638. * Binds the view matrix to the effect
  30639. * @param effect defines the effect to bind the view matrix to
  30640. * @param variableName name of the shader variable that will hold the eye position
  30641. */
  30642. bindEyePosition(effect: Effect, variableName?: string): void;
  30643. /**
  30644. * Processes to execute after binding the material to a mesh
  30645. * @param mesh defines the rendered mesh
  30646. */
  30647. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30648. /**
  30649. * Unbinds the material from the mesh
  30650. */
  30651. unbind(): void;
  30652. /**
  30653. * Gets the active textures from the material
  30654. * @returns an array of textures
  30655. */
  30656. getActiveTextures(): BaseTexture[];
  30657. /**
  30658. * Specifies if the material uses a texture
  30659. * @param texture defines the texture to check against the material
  30660. * @returns a boolean specifying if the material uses the texture
  30661. */
  30662. hasTexture(texture: BaseTexture): boolean;
  30663. /**
  30664. * Makes a duplicate of the material, and gives it a new name
  30665. * @param name defines the new name for the duplicated material
  30666. * @returns the cloned material
  30667. */
  30668. clone(name: string): Nullable<Material>;
  30669. /**
  30670. * Gets the meshes bound to the material
  30671. * @returns an array of meshes bound to the material
  30672. */
  30673. getBindedMeshes(): AbstractMesh[];
  30674. /**
  30675. * Force shader compilation
  30676. * @param mesh defines the mesh associated with this material
  30677. * @param onCompiled defines a function to execute once the material is compiled
  30678. * @param options defines the options to configure the compilation
  30679. * @param onError defines a function to execute if the material fails compiling
  30680. */
  30681. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30682. /**
  30683. * Force shader compilation
  30684. * @param mesh defines the mesh that will use this material
  30685. * @param options defines additional options for compiling the shaders
  30686. * @returns a promise that resolves when the compilation completes
  30687. */
  30688. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30689. private static readonly _AllDirtyCallBack;
  30690. private static readonly _ImageProcessingDirtyCallBack;
  30691. private static readonly _TextureDirtyCallBack;
  30692. private static readonly _FresnelDirtyCallBack;
  30693. private static readonly _MiscDirtyCallBack;
  30694. private static readonly _PrePassDirtyCallBack;
  30695. private static readonly _LightsDirtyCallBack;
  30696. private static readonly _AttributeDirtyCallBack;
  30697. private static _FresnelAndMiscDirtyCallBack;
  30698. private static _TextureAndMiscDirtyCallBack;
  30699. private static readonly _DirtyCallbackArray;
  30700. private static readonly _RunDirtyCallBacks;
  30701. /**
  30702. * Marks a define in the material to indicate that it needs to be re-computed
  30703. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30704. */
  30705. markAsDirty(flag: number): void;
  30706. /**
  30707. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30708. * @param func defines a function which checks material defines against the submeshes
  30709. */
  30710. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30711. /**
  30712. * Indicates that the scene should check if the rendering now needs a prepass
  30713. */
  30714. protected _markScenePrePassDirty(): void;
  30715. /**
  30716. * Indicates that we need to re-calculated for all submeshes
  30717. */
  30718. protected _markAllSubMeshesAsAllDirty(): void;
  30719. /**
  30720. * Indicates that image processing needs to be re-calculated for all submeshes
  30721. */
  30722. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30723. /**
  30724. * Indicates that textures need to be re-calculated for all submeshes
  30725. */
  30726. protected _markAllSubMeshesAsTexturesDirty(): void;
  30727. /**
  30728. * Indicates that fresnel needs to be re-calculated for all submeshes
  30729. */
  30730. protected _markAllSubMeshesAsFresnelDirty(): void;
  30731. /**
  30732. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30733. */
  30734. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30735. /**
  30736. * Indicates that lights need to be re-calculated for all submeshes
  30737. */
  30738. protected _markAllSubMeshesAsLightsDirty(): void;
  30739. /**
  30740. * Indicates that attributes need to be re-calculated for all submeshes
  30741. */
  30742. protected _markAllSubMeshesAsAttributesDirty(): void;
  30743. /**
  30744. * Indicates that misc needs to be re-calculated for all submeshes
  30745. */
  30746. protected _markAllSubMeshesAsMiscDirty(): void;
  30747. /**
  30748. * Indicates that prepass needs to be re-calculated for all submeshes
  30749. */
  30750. protected _markAllSubMeshesAsPrePassDirty(): void;
  30751. /**
  30752. * Indicates that textures and misc need to be re-calculated for all submeshes
  30753. */
  30754. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30755. /**
  30756. * Sets the required values to the prepass renderer.
  30757. * @param prePassRenderer defines the prepass renderer to setup.
  30758. * @returns true if the pre pass is needed.
  30759. */
  30760. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30761. /**
  30762. * Disposes the material
  30763. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30764. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30765. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30766. */
  30767. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30768. /** @hidden */
  30769. private releaseVertexArrayObject;
  30770. /**
  30771. * Serializes this material
  30772. * @returns the serialized material object
  30773. */
  30774. serialize(): any;
  30775. /**
  30776. * Creates a material from parsed material data
  30777. * @param parsedMaterial defines parsed material data
  30778. * @param scene defines the hosting scene
  30779. * @param rootUrl defines the root URL to use to load textures
  30780. * @returns a new material
  30781. */
  30782. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30783. }
  30784. }
  30785. declare module BABYLON {
  30786. /**
  30787. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30788. * separate meshes. This can be use to improve performances.
  30789. * @see https://doc.babylonjs.com/how_to/multi_materials
  30790. */
  30791. export class MultiMaterial extends Material {
  30792. private _subMaterials;
  30793. /**
  30794. * Gets or Sets the list of Materials used within the multi material.
  30795. * They need to be ordered according to the submeshes order in the associated mesh
  30796. */
  30797. get subMaterials(): Nullable<Material>[];
  30798. set subMaterials(value: Nullable<Material>[]);
  30799. /**
  30800. * Function used to align with Node.getChildren()
  30801. * @returns the list of Materials used within the multi material
  30802. */
  30803. getChildren(): Nullable<Material>[];
  30804. /**
  30805. * Instantiates a new Multi Material
  30806. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30807. * separate meshes. This can be use to improve performances.
  30808. * @see https://doc.babylonjs.com/how_to/multi_materials
  30809. * @param name Define the name in the scene
  30810. * @param scene Define the scene the material belongs to
  30811. */
  30812. constructor(name: string, scene: Scene);
  30813. private _hookArray;
  30814. /**
  30815. * Get one of the submaterial by its index in the submaterials array
  30816. * @param index The index to look the sub material at
  30817. * @returns The Material if the index has been defined
  30818. */
  30819. getSubMaterial(index: number): Nullable<Material>;
  30820. /**
  30821. * Get the list of active textures for the whole sub materials list.
  30822. * @returns All the textures that will be used during the rendering
  30823. */
  30824. getActiveTextures(): BaseTexture[];
  30825. /**
  30826. * Specifies if any sub-materials of this multi-material use a given texture.
  30827. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30828. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30829. */
  30830. hasTexture(texture: BaseTexture): boolean;
  30831. /**
  30832. * Gets the current class name of the material e.g. "MultiMaterial"
  30833. * Mainly use in serialization.
  30834. * @returns the class name
  30835. */
  30836. getClassName(): string;
  30837. /**
  30838. * Checks if the material is ready to render the requested sub mesh
  30839. * @param mesh Define the mesh the submesh belongs to
  30840. * @param subMesh Define the sub mesh to look readyness for
  30841. * @param useInstances Define whether or not the material is used with instances
  30842. * @returns true if ready, otherwise false
  30843. */
  30844. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30845. /**
  30846. * Clones the current material and its related sub materials
  30847. * @param name Define the name of the newly cloned material
  30848. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30849. * @returns the cloned material
  30850. */
  30851. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30852. /**
  30853. * Serializes the materials into a JSON representation.
  30854. * @returns the JSON representation
  30855. */
  30856. serialize(): any;
  30857. /**
  30858. * Dispose the material and release its associated resources
  30859. * @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)
  30860. * @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)
  30861. * @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)
  30862. */
  30863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30864. /**
  30865. * Creates a MultiMaterial from parsed MultiMaterial data.
  30866. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30867. * @param scene defines the hosting scene
  30868. * @returns a new MultiMaterial
  30869. */
  30870. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30871. }
  30872. }
  30873. declare module BABYLON {
  30874. /** @hidden */
  30875. export interface ICustomEffect {
  30876. effect: Effect;
  30877. defines: string;
  30878. }
  30879. /**
  30880. * Defines a subdivision inside a mesh
  30881. */
  30882. export class SubMesh implements ICullable {
  30883. /** the material index to use */
  30884. materialIndex: number;
  30885. /** vertex index start */
  30886. verticesStart: number;
  30887. /** vertices count */
  30888. verticesCount: number;
  30889. /** index start */
  30890. indexStart: number;
  30891. /** indices count */
  30892. indexCount: number;
  30893. /** @hidden */
  30894. _materialDefines: Nullable<MaterialDefines>;
  30895. /** @hidden */
  30896. _materialEffect: Nullable<Effect>;
  30897. /** @hidden */
  30898. _effectOverride: Nullable<Effect>;
  30899. private _customEffects;
  30900. /**
  30901. * Gets material defines used by the effect associated to the sub mesh
  30902. */
  30903. get materialDefines(): Nullable<MaterialDefines>;
  30904. /**
  30905. * Sets material defines used by the effect associated to the sub mesh
  30906. */
  30907. set materialDefines(defines: Nullable<MaterialDefines>);
  30908. /** @hidden */
  30909. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30910. /** @hidden */
  30911. _removeCustomEffect(name: string): void;
  30912. /**
  30913. * Gets associated effect
  30914. */
  30915. get effect(): Nullable<Effect>;
  30916. /**
  30917. * Sets associated effect (effect used to render this submesh)
  30918. * @param effect defines the effect to associate with
  30919. * @param defines defines the set of defines used to compile this effect
  30920. */
  30921. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30922. /** @hidden */
  30923. _linesIndexCount: number;
  30924. private _mesh;
  30925. private _renderingMesh;
  30926. private _boundingInfo;
  30927. private _linesIndexBuffer;
  30928. /** @hidden */
  30929. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30930. /** @hidden */
  30931. _trianglePlanes: Plane[];
  30932. /** @hidden */
  30933. _lastColliderTransformMatrix: Nullable<Matrix>;
  30934. /** @hidden */
  30935. _renderId: number;
  30936. /** @hidden */
  30937. _alphaIndex: number;
  30938. /** @hidden */
  30939. _distanceToCamera: number;
  30940. /** @hidden */
  30941. _id: number;
  30942. private _currentMaterial;
  30943. /**
  30944. * Add a new submesh to a mesh
  30945. * @param materialIndex defines the material index to use
  30946. * @param verticesStart defines vertex index start
  30947. * @param verticesCount defines vertices count
  30948. * @param indexStart defines index start
  30949. * @param indexCount defines indices count
  30950. * @param mesh defines the parent mesh
  30951. * @param renderingMesh defines an optional rendering mesh
  30952. * @param createBoundingBox defines if bounding box should be created for this submesh
  30953. * @returns the new submesh
  30954. */
  30955. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30956. /**
  30957. * Creates a new submesh
  30958. * @param materialIndex defines the material index to use
  30959. * @param verticesStart defines vertex index start
  30960. * @param verticesCount defines vertices count
  30961. * @param indexStart defines index start
  30962. * @param indexCount defines indices count
  30963. * @param mesh defines the parent mesh
  30964. * @param renderingMesh defines an optional rendering mesh
  30965. * @param createBoundingBox defines if bounding box should be created for this submesh
  30966. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30967. */
  30968. constructor(
  30969. /** the material index to use */
  30970. materialIndex: number,
  30971. /** vertex index start */
  30972. verticesStart: number,
  30973. /** vertices count */
  30974. verticesCount: number,
  30975. /** index start */
  30976. indexStart: number,
  30977. /** indices count */
  30978. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30979. /**
  30980. * Returns true if this submesh covers the entire parent mesh
  30981. * @ignorenaming
  30982. */
  30983. get IsGlobal(): boolean;
  30984. /**
  30985. * Returns the submesh BoudingInfo object
  30986. * @returns current bounding info (or mesh's one if the submesh is global)
  30987. */
  30988. getBoundingInfo(): BoundingInfo;
  30989. /**
  30990. * Sets the submesh BoundingInfo
  30991. * @param boundingInfo defines the new bounding info to use
  30992. * @returns the SubMesh
  30993. */
  30994. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30995. /**
  30996. * Returns the mesh of the current submesh
  30997. * @return the parent mesh
  30998. */
  30999. getMesh(): AbstractMesh;
  31000. /**
  31001. * Returns the rendering mesh of the submesh
  31002. * @returns the rendering mesh (could be different from parent mesh)
  31003. */
  31004. getRenderingMesh(): Mesh;
  31005. /**
  31006. * Returns the replacement mesh of the submesh
  31007. * @returns the replacement mesh (could be different from parent mesh)
  31008. */
  31009. getReplacementMesh(): Nullable<AbstractMesh>;
  31010. /**
  31011. * Returns the effective mesh of the submesh
  31012. * @returns the effective mesh (could be different from parent mesh)
  31013. */
  31014. getEffectiveMesh(): AbstractMesh;
  31015. /**
  31016. * Returns the submesh material
  31017. * @returns null or the current material
  31018. */
  31019. getMaterial(): Nullable<Material>;
  31020. private _IsMultiMaterial;
  31021. /**
  31022. * Sets a new updated BoundingInfo object to the submesh
  31023. * @param data defines an optional position array to use to determine the bounding info
  31024. * @returns the SubMesh
  31025. */
  31026. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31027. /** @hidden */
  31028. _checkCollision(collider: Collider): boolean;
  31029. /**
  31030. * Updates the submesh BoundingInfo
  31031. * @param world defines the world matrix to use to update the bounding info
  31032. * @returns the submesh
  31033. */
  31034. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31035. /**
  31036. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31037. * @param frustumPlanes defines the frustum planes
  31038. * @returns true if the submesh is intersecting with the frustum
  31039. */
  31040. isInFrustum(frustumPlanes: Plane[]): boolean;
  31041. /**
  31042. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31043. * @param frustumPlanes defines the frustum planes
  31044. * @returns true if the submesh is inside the frustum
  31045. */
  31046. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31047. /**
  31048. * Renders the submesh
  31049. * @param enableAlphaMode defines if alpha needs to be used
  31050. * @returns the submesh
  31051. */
  31052. render(enableAlphaMode: boolean): SubMesh;
  31053. /**
  31054. * @hidden
  31055. */
  31056. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31057. /**
  31058. * Checks if the submesh intersects with a ray
  31059. * @param ray defines the ray to test
  31060. * @returns true is the passed ray intersects the submesh bounding box
  31061. */
  31062. canIntersects(ray: Ray): boolean;
  31063. /**
  31064. * Intersects current submesh with a ray
  31065. * @param ray defines the ray to test
  31066. * @param positions defines mesh's positions array
  31067. * @param indices defines mesh's indices array
  31068. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31070. * @returns intersection info or null if no intersection
  31071. */
  31072. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31073. /** @hidden */
  31074. private _intersectLines;
  31075. /** @hidden */
  31076. private _intersectUnIndexedLines;
  31077. /** @hidden */
  31078. private _intersectTriangles;
  31079. /** @hidden */
  31080. private _intersectUnIndexedTriangles;
  31081. /** @hidden */
  31082. _rebuild(): void;
  31083. /**
  31084. * Creates a new submesh from the passed mesh
  31085. * @param newMesh defines the new hosting mesh
  31086. * @param newRenderingMesh defines an optional rendering mesh
  31087. * @returns the new submesh
  31088. */
  31089. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31090. /**
  31091. * Release associated resources
  31092. */
  31093. dispose(): void;
  31094. /**
  31095. * Gets the class name
  31096. * @returns the string "SubMesh".
  31097. */
  31098. getClassName(): string;
  31099. /**
  31100. * Creates a new submesh from indices data
  31101. * @param materialIndex the index of the main mesh material
  31102. * @param startIndex the index where to start the copy in the mesh indices array
  31103. * @param indexCount the number of indices to copy then from the startIndex
  31104. * @param mesh the main mesh to create the submesh from
  31105. * @param renderingMesh the optional rendering mesh
  31106. * @returns a new submesh
  31107. */
  31108. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31109. }
  31110. }
  31111. declare module BABYLON {
  31112. /**
  31113. * Class used to represent data loading progression
  31114. */
  31115. export class SceneLoaderFlags {
  31116. private static _ForceFullSceneLoadingForIncremental;
  31117. private static _ShowLoadingScreen;
  31118. private static _CleanBoneMatrixWeights;
  31119. private static _loggingLevel;
  31120. /**
  31121. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31122. */
  31123. static get ForceFullSceneLoadingForIncremental(): boolean;
  31124. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31125. /**
  31126. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31127. */
  31128. static get ShowLoadingScreen(): boolean;
  31129. static set ShowLoadingScreen(value: boolean);
  31130. /**
  31131. * Defines the current logging level (while loading the scene)
  31132. * @ignorenaming
  31133. */
  31134. static get loggingLevel(): number;
  31135. static set loggingLevel(value: number);
  31136. /**
  31137. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31138. */
  31139. static get CleanBoneMatrixWeights(): boolean;
  31140. static set CleanBoneMatrixWeights(value: boolean);
  31141. }
  31142. }
  31143. declare module BABYLON {
  31144. /**
  31145. * Class used to store geometry data (vertex buffers + index buffer)
  31146. */
  31147. export class Geometry implements IGetSetVerticesData {
  31148. /**
  31149. * Gets or sets the ID of the geometry
  31150. */
  31151. id: string;
  31152. /**
  31153. * Gets or sets the unique ID of the geometry
  31154. */
  31155. uniqueId: number;
  31156. /**
  31157. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31158. */
  31159. delayLoadState: number;
  31160. /**
  31161. * Gets the file containing the data to load when running in delay load state
  31162. */
  31163. delayLoadingFile: Nullable<string>;
  31164. /**
  31165. * Callback called when the geometry is updated
  31166. */
  31167. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31168. private _scene;
  31169. private _engine;
  31170. private _meshes;
  31171. private _totalVertices;
  31172. /** @hidden */
  31173. _indices: IndicesArray;
  31174. /** @hidden */
  31175. _vertexBuffers: {
  31176. [key: string]: VertexBuffer;
  31177. };
  31178. private _isDisposed;
  31179. private _extend;
  31180. private _boundingBias;
  31181. /** @hidden */
  31182. _delayInfo: Array<string>;
  31183. private _indexBuffer;
  31184. private _indexBufferIsUpdatable;
  31185. /** @hidden */
  31186. _boundingInfo: Nullable<BoundingInfo>;
  31187. /** @hidden */
  31188. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31189. /** @hidden */
  31190. _softwareSkinningFrameId: number;
  31191. private _vertexArrayObjects;
  31192. private _updatable;
  31193. /** @hidden */
  31194. _positions: Nullable<Vector3[]>;
  31195. private _positionsCache;
  31196. /**
  31197. * 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
  31198. */
  31199. get boundingBias(): Vector2;
  31200. /**
  31201. * 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
  31202. */
  31203. set boundingBias(value: Vector2);
  31204. /**
  31205. * Static function used to attach a new empty geometry to a mesh
  31206. * @param mesh defines the mesh to attach the geometry to
  31207. * @returns the new Geometry
  31208. */
  31209. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31210. /** Get the list of meshes using this geometry */
  31211. get meshes(): Mesh[];
  31212. /**
  31213. * 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
  31214. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31215. */
  31216. useBoundingInfoFromGeometry: boolean;
  31217. /**
  31218. * Creates a new geometry
  31219. * @param id defines the unique ID
  31220. * @param scene defines the hosting scene
  31221. * @param vertexData defines the VertexData used to get geometry data
  31222. * @param updatable defines if geometry must be updatable (false by default)
  31223. * @param mesh defines the mesh that will be associated with the geometry
  31224. */
  31225. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31226. /**
  31227. * Gets the current extend of the geometry
  31228. */
  31229. get extend(): {
  31230. minimum: Vector3;
  31231. maximum: Vector3;
  31232. };
  31233. /**
  31234. * Gets the hosting scene
  31235. * @returns the hosting Scene
  31236. */
  31237. getScene(): Scene;
  31238. /**
  31239. * Gets the hosting engine
  31240. * @returns the hosting Engine
  31241. */
  31242. getEngine(): Engine;
  31243. /**
  31244. * Defines if the geometry is ready to use
  31245. * @returns true if the geometry is ready to be used
  31246. */
  31247. isReady(): boolean;
  31248. /**
  31249. * Gets a value indicating that the geometry should not be serialized
  31250. */
  31251. get doNotSerialize(): boolean;
  31252. /** @hidden */
  31253. _rebuild(): void;
  31254. /**
  31255. * Affects all geometry data in one call
  31256. * @param vertexData defines the geometry data
  31257. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31258. */
  31259. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31260. /**
  31261. * Set specific vertex data
  31262. * @param kind defines the data kind (Position, normal, etc...)
  31263. * @param data defines the vertex data to use
  31264. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31265. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31266. */
  31267. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31268. /**
  31269. * Removes a specific vertex data
  31270. * @param kind defines the data kind (Position, normal, etc...)
  31271. */
  31272. removeVerticesData(kind: string): void;
  31273. /**
  31274. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31275. * @param buffer defines the vertex buffer to use
  31276. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31277. */
  31278. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31279. /**
  31280. * Update a specific vertex buffer
  31281. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31282. * It will do nothing if the buffer is not updatable
  31283. * @param kind defines the data kind (Position, normal, etc...)
  31284. * @param data defines the data to use
  31285. * @param offset defines the offset in the target buffer where to store the data
  31286. * @param useBytes set to true if the offset is in bytes
  31287. */
  31288. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31289. /**
  31290. * Update a specific vertex buffer
  31291. * This function will create a new buffer if the current one is not updatable
  31292. * @param kind defines the data kind (Position, normal, etc...)
  31293. * @param data defines the data to use
  31294. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31295. */
  31296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31297. private _updateBoundingInfo;
  31298. /** @hidden */
  31299. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31300. [kind: string]: Nullable<VertexBuffer>;
  31301. }, overrideVertexArrayObjects?: {
  31302. [key: string]: WebGLVertexArrayObject;
  31303. }): void;
  31304. /**
  31305. * Gets total number of vertices
  31306. * @returns the total number of vertices
  31307. */
  31308. getTotalVertices(): number;
  31309. /**
  31310. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31311. * @param kind defines the data kind (Position, normal, etc...)
  31312. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31313. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31314. * @returns a float array containing vertex data
  31315. */
  31316. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31317. /**
  31318. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31319. * @param kind defines the data kind (Position, normal, etc...)
  31320. * @returns true if the vertex buffer with the specified kind is updatable
  31321. */
  31322. isVertexBufferUpdatable(kind: string): boolean;
  31323. /**
  31324. * Gets a specific vertex buffer
  31325. * @param kind defines the data kind (Position, normal, etc...)
  31326. * @returns a VertexBuffer
  31327. */
  31328. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31329. /**
  31330. * Returns all vertex buffers
  31331. * @return an object holding all vertex buffers indexed by kind
  31332. */
  31333. getVertexBuffers(): Nullable<{
  31334. [key: string]: VertexBuffer;
  31335. }>;
  31336. /**
  31337. * Gets a boolean indicating if specific vertex buffer is present
  31338. * @param kind defines the data kind (Position, normal, etc...)
  31339. * @returns true if data is present
  31340. */
  31341. isVerticesDataPresent(kind: string): boolean;
  31342. /**
  31343. * Gets a list of all attached data kinds (Position, normal, etc...)
  31344. * @returns a list of string containing all kinds
  31345. */
  31346. getVerticesDataKinds(): string[];
  31347. /**
  31348. * Update index buffer
  31349. * @param indices defines the indices to store in the index buffer
  31350. * @param offset defines the offset in the target buffer where to store the data
  31351. * @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)
  31352. */
  31353. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31354. /**
  31355. * Creates a new index buffer
  31356. * @param indices defines the indices to store in the index buffer
  31357. * @param totalVertices defines the total number of vertices (could be null)
  31358. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31359. */
  31360. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31361. /**
  31362. * Return the total number of indices
  31363. * @returns the total number of indices
  31364. */
  31365. getTotalIndices(): number;
  31366. /**
  31367. * Gets the index buffer array
  31368. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31369. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31370. * @returns the index buffer array
  31371. */
  31372. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31373. /**
  31374. * Gets the index buffer
  31375. * @return the index buffer
  31376. */
  31377. getIndexBuffer(): Nullable<DataBuffer>;
  31378. /** @hidden */
  31379. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31380. /**
  31381. * Release the associated resources for a specific mesh
  31382. * @param mesh defines the source mesh
  31383. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31384. */
  31385. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31386. /**
  31387. * Apply current geometry to a given mesh
  31388. * @param mesh defines the mesh to apply geometry to
  31389. */
  31390. applyToMesh(mesh: Mesh): void;
  31391. private _updateExtend;
  31392. private _applyToMesh;
  31393. private notifyUpdate;
  31394. /**
  31395. * Load the geometry if it was flagged as delay loaded
  31396. * @param scene defines the hosting scene
  31397. * @param onLoaded defines a callback called when the geometry is loaded
  31398. */
  31399. load(scene: Scene, onLoaded?: () => void): void;
  31400. private _queueLoad;
  31401. /**
  31402. * Invert the geometry to move from a right handed system to a left handed one.
  31403. */
  31404. toLeftHanded(): void;
  31405. /** @hidden */
  31406. _resetPointsArrayCache(): void;
  31407. /** @hidden */
  31408. _generatePointsArray(): boolean;
  31409. /**
  31410. * Gets a value indicating if the geometry is disposed
  31411. * @returns true if the geometry was disposed
  31412. */
  31413. isDisposed(): boolean;
  31414. private _disposeVertexArrayObjects;
  31415. /**
  31416. * Free all associated resources
  31417. */
  31418. dispose(): void;
  31419. /**
  31420. * Clone the current geometry into a new geometry
  31421. * @param id defines the unique ID of the new geometry
  31422. * @returns a new geometry object
  31423. */
  31424. copy(id: string): Geometry;
  31425. /**
  31426. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31427. * @return a JSON representation of the current geometry data (without the vertices data)
  31428. */
  31429. serialize(): any;
  31430. private toNumberArray;
  31431. /**
  31432. * Serialize all vertices data into a JSON oject
  31433. * @returns a JSON representation of the current geometry data
  31434. */
  31435. serializeVerticeData(): any;
  31436. /**
  31437. * Extracts a clone of a mesh geometry
  31438. * @param mesh defines the source mesh
  31439. * @param id defines the unique ID of the new geometry object
  31440. * @returns the new geometry object
  31441. */
  31442. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31443. /**
  31444. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31445. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31446. * Be aware Math.random() could cause collisions, but:
  31447. * "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"
  31448. * @returns a string containing a new GUID
  31449. */
  31450. static RandomId(): string;
  31451. /** @hidden */
  31452. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31453. private static _CleanMatricesWeights;
  31454. /**
  31455. * Create a new geometry from persisted data (Using .babylon file format)
  31456. * @param parsedVertexData defines the persisted data
  31457. * @param scene defines the hosting scene
  31458. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31459. * @returns the new geometry object
  31460. */
  31461. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31462. }
  31463. }
  31464. declare module BABYLON {
  31465. /**
  31466. * Defines a target to use with MorphTargetManager
  31467. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31468. */
  31469. export class MorphTarget implements IAnimatable {
  31470. /** defines the name of the target */
  31471. name: string;
  31472. /**
  31473. * Gets or sets the list of animations
  31474. */
  31475. animations: Animation[];
  31476. private _scene;
  31477. private _positions;
  31478. private _normals;
  31479. private _tangents;
  31480. private _uvs;
  31481. private _influence;
  31482. private _uniqueId;
  31483. /**
  31484. * Observable raised when the influence changes
  31485. */
  31486. onInfluenceChanged: Observable<boolean>;
  31487. /** @hidden */
  31488. _onDataLayoutChanged: Observable<void>;
  31489. /**
  31490. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31491. */
  31492. get influence(): number;
  31493. set influence(influence: number);
  31494. /**
  31495. * Gets or sets the id of the morph Target
  31496. */
  31497. id: string;
  31498. private _animationPropertiesOverride;
  31499. /**
  31500. * Gets or sets the animation properties override
  31501. */
  31502. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31503. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31504. /**
  31505. * Creates a new MorphTarget
  31506. * @param name defines the name of the target
  31507. * @param influence defines the influence to use
  31508. * @param scene defines the scene the morphtarget belongs to
  31509. */
  31510. constructor(
  31511. /** defines the name of the target */
  31512. name: string, influence?: number, scene?: Nullable<Scene>);
  31513. /**
  31514. * Gets the unique ID of this manager
  31515. */
  31516. get uniqueId(): number;
  31517. /**
  31518. * Gets a boolean defining if the target contains position data
  31519. */
  31520. get hasPositions(): boolean;
  31521. /**
  31522. * Gets a boolean defining if the target contains normal data
  31523. */
  31524. get hasNormals(): boolean;
  31525. /**
  31526. * Gets a boolean defining if the target contains tangent data
  31527. */
  31528. get hasTangents(): boolean;
  31529. /**
  31530. * Gets a boolean defining if the target contains texture coordinates data
  31531. */
  31532. get hasUVs(): boolean;
  31533. /**
  31534. * Affects position data to this target
  31535. * @param data defines the position data to use
  31536. */
  31537. setPositions(data: Nullable<FloatArray>): void;
  31538. /**
  31539. * Gets the position data stored in this target
  31540. * @returns a FloatArray containing the position data (or null if not present)
  31541. */
  31542. getPositions(): Nullable<FloatArray>;
  31543. /**
  31544. * Affects normal data to this target
  31545. * @param data defines the normal data to use
  31546. */
  31547. setNormals(data: Nullable<FloatArray>): void;
  31548. /**
  31549. * Gets the normal data stored in this target
  31550. * @returns a FloatArray containing the normal data (or null if not present)
  31551. */
  31552. getNormals(): Nullable<FloatArray>;
  31553. /**
  31554. * Affects tangent data to this target
  31555. * @param data defines the tangent data to use
  31556. */
  31557. setTangents(data: Nullable<FloatArray>): void;
  31558. /**
  31559. * Gets the tangent data stored in this target
  31560. * @returns a FloatArray containing the tangent data (or null if not present)
  31561. */
  31562. getTangents(): Nullable<FloatArray>;
  31563. /**
  31564. * Affects texture coordinates data to this target
  31565. * @param data defines the texture coordinates data to use
  31566. */
  31567. setUVs(data: Nullable<FloatArray>): void;
  31568. /**
  31569. * Gets the texture coordinates data stored in this target
  31570. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31571. */
  31572. getUVs(): Nullable<FloatArray>;
  31573. /**
  31574. * Clone the current target
  31575. * @returns a new MorphTarget
  31576. */
  31577. clone(): MorphTarget;
  31578. /**
  31579. * Serializes the current target into a Serialization object
  31580. * @returns the serialized object
  31581. */
  31582. serialize(): any;
  31583. /**
  31584. * Returns the string "MorphTarget"
  31585. * @returns "MorphTarget"
  31586. */
  31587. getClassName(): string;
  31588. /**
  31589. * Creates a new target from serialized data
  31590. * @param serializationObject defines the serialized data to use
  31591. * @returns a new MorphTarget
  31592. */
  31593. static Parse(serializationObject: any): MorphTarget;
  31594. /**
  31595. * Creates a MorphTarget from mesh data
  31596. * @param mesh defines the source mesh
  31597. * @param name defines the name to use for the new target
  31598. * @param influence defines the influence to attach to the target
  31599. * @returns a new MorphTarget
  31600. */
  31601. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31602. }
  31603. }
  31604. declare module BABYLON {
  31605. /**
  31606. * This class is used to deform meshes using morphing between different targets
  31607. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31608. */
  31609. export class MorphTargetManager {
  31610. private _targets;
  31611. private _targetInfluenceChangedObservers;
  31612. private _targetDataLayoutChangedObservers;
  31613. private _activeTargets;
  31614. private _scene;
  31615. private _influences;
  31616. private _supportsNormals;
  31617. private _supportsTangents;
  31618. private _supportsUVs;
  31619. private _vertexCount;
  31620. private _uniqueId;
  31621. private _tempInfluences;
  31622. /**
  31623. * Gets or sets a boolean indicating if normals must be morphed
  31624. */
  31625. enableNormalMorphing: boolean;
  31626. /**
  31627. * Gets or sets a boolean indicating if tangents must be morphed
  31628. */
  31629. enableTangentMorphing: boolean;
  31630. /**
  31631. * Gets or sets a boolean indicating if UV must be morphed
  31632. */
  31633. enableUVMorphing: boolean;
  31634. /**
  31635. * Creates a new MorphTargetManager
  31636. * @param scene defines the current scene
  31637. */
  31638. constructor(scene?: Nullable<Scene>);
  31639. /**
  31640. * Gets the unique ID of this manager
  31641. */
  31642. get uniqueId(): number;
  31643. /**
  31644. * Gets the number of vertices handled by this manager
  31645. */
  31646. get vertexCount(): number;
  31647. /**
  31648. * Gets a boolean indicating if this manager supports morphing of normals
  31649. */
  31650. get supportsNormals(): boolean;
  31651. /**
  31652. * Gets a boolean indicating if this manager supports morphing of tangents
  31653. */
  31654. get supportsTangents(): boolean;
  31655. /**
  31656. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31657. */
  31658. get supportsUVs(): boolean;
  31659. /**
  31660. * Gets the number of targets stored in this manager
  31661. */
  31662. get numTargets(): number;
  31663. /**
  31664. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31665. */
  31666. get numInfluencers(): number;
  31667. /**
  31668. * Gets the list of influences (one per target)
  31669. */
  31670. get influences(): Float32Array;
  31671. /**
  31672. * Gets the active target at specified index. An active target is a target with an influence > 0
  31673. * @param index defines the index to check
  31674. * @returns the requested target
  31675. */
  31676. getActiveTarget(index: number): MorphTarget;
  31677. /**
  31678. * Gets the target at specified index
  31679. * @param index defines the index to check
  31680. * @returns the requested target
  31681. */
  31682. getTarget(index: number): MorphTarget;
  31683. /**
  31684. * Add a new target to this manager
  31685. * @param target defines the target to add
  31686. */
  31687. addTarget(target: MorphTarget): void;
  31688. /**
  31689. * Removes a target from the manager
  31690. * @param target defines the target to remove
  31691. */
  31692. removeTarget(target: MorphTarget): void;
  31693. /**
  31694. * Clone the current manager
  31695. * @returns a new MorphTargetManager
  31696. */
  31697. clone(): MorphTargetManager;
  31698. /**
  31699. * Serializes the current manager into a Serialization object
  31700. * @returns the serialized object
  31701. */
  31702. serialize(): any;
  31703. private _syncActiveTargets;
  31704. /**
  31705. * Syncrhonize the targets with all the meshes using this morph target manager
  31706. */
  31707. synchronize(): void;
  31708. /**
  31709. * Creates a new MorphTargetManager from serialized data
  31710. * @param serializationObject defines the serialized data
  31711. * @param scene defines the hosting scene
  31712. * @returns the new MorphTargetManager
  31713. */
  31714. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31715. }
  31716. }
  31717. declare module BABYLON {
  31718. /**
  31719. * Class used to represent a specific level of detail of a mesh
  31720. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31721. */
  31722. export class MeshLODLevel {
  31723. /** Defines the distance where this level should start being displayed */
  31724. distance: number;
  31725. /** Defines the mesh to use to render this level */
  31726. mesh: Nullable<Mesh>;
  31727. /**
  31728. * Creates a new LOD level
  31729. * @param distance defines the distance where this level should star being displayed
  31730. * @param mesh defines the mesh to use to render this level
  31731. */
  31732. constructor(
  31733. /** Defines the distance where this level should start being displayed */
  31734. distance: number,
  31735. /** Defines the mesh to use to render this level */
  31736. mesh: Nullable<Mesh>);
  31737. }
  31738. }
  31739. declare module BABYLON {
  31740. /**
  31741. * Helper class used to generate a canvas to manipulate images
  31742. */
  31743. export class CanvasGenerator {
  31744. /**
  31745. * Create a new canvas (or offscreen canvas depending on the context)
  31746. * @param width defines the expected width
  31747. * @param height defines the expected height
  31748. * @return a new canvas or offscreen canvas
  31749. */
  31750. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31751. }
  31752. }
  31753. declare module BABYLON {
  31754. /**
  31755. * Mesh representing the gorund
  31756. */
  31757. export class GroundMesh extends Mesh {
  31758. /** If octree should be generated */
  31759. generateOctree: boolean;
  31760. private _heightQuads;
  31761. /** @hidden */
  31762. _subdivisionsX: number;
  31763. /** @hidden */
  31764. _subdivisionsY: number;
  31765. /** @hidden */
  31766. _width: number;
  31767. /** @hidden */
  31768. _height: number;
  31769. /** @hidden */
  31770. _minX: number;
  31771. /** @hidden */
  31772. _maxX: number;
  31773. /** @hidden */
  31774. _minZ: number;
  31775. /** @hidden */
  31776. _maxZ: number;
  31777. constructor(name: string, scene: Scene);
  31778. /**
  31779. * "GroundMesh"
  31780. * @returns "GroundMesh"
  31781. */
  31782. getClassName(): string;
  31783. /**
  31784. * The minimum of x and y subdivisions
  31785. */
  31786. get subdivisions(): number;
  31787. /**
  31788. * X subdivisions
  31789. */
  31790. get subdivisionsX(): number;
  31791. /**
  31792. * Y subdivisions
  31793. */
  31794. get subdivisionsY(): number;
  31795. /**
  31796. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31797. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31798. * @param chunksCount the number of subdivisions for x and y
  31799. * @param octreeBlocksSize (Default: 32)
  31800. */
  31801. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31802. /**
  31803. * Returns a height (y) value in the Worl system :
  31804. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31805. * @param x x coordinate
  31806. * @param z z coordinate
  31807. * @returns the ground y position if (x, z) are outside the ground surface.
  31808. */
  31809. getHeightAtCoordinates(x: number, z: number): number;
  31810. /**
  31811. * Returns a normalized vector (Vector3) orthogonal to the ground
  31812. * at the ground coordinates (x, z) expressed in the World system.
  31813. * @param x x coordinate
  31814. * @param z z coordinate
  31815. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31816. */
  31817. getNormalAtCoordinates(x: number, z: number): Vector3;
  31818. /**
  31819. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31820. * at the ground coordinates (x, z) expressed in the World system.
  31821. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31822. * @param x x coordinate
  31823. * @param z z coordinate
  31824. * @param ref vector to store the result
  31825. * @returns the GroundMesh.
  31826. */
  31827. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31828. /**
  31829. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31830. * if the ground has been updated.
  31831. * This can be used in the render loop.
  31832. * @returns the GroundMesh.
  31833. */
  31834. updateCoordinateHeights(): GroundMesh;
  31835. private _getFacetAt;
  31836. private _initHeightQuads;
  31837. private _computeHeightQuads;
  31838. /**
  31839. * Serializes this ground mesh
  31840. * @param serializationObject object to write serialization to
  31841. */
  31842. serialize(serializationObject: any): void;
  31843. /**
  31844. * Parses a serialized ground mesh
  31845. * @param parsedMesh the serialized mesh
  31846. * @param scene the scene to create the ground mesh in
  31847. * @returns the created ground mesh
  31848. */
  31849. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31850. }
  31851. }
  31852. declare module BABYLON {
  31853. /**
  31854. * Interface for Physics-Joint data
  31855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31856. */
  31857. export interface PhysicsJointData {
  31858. /**
  31859. * The main pivot of the joint
  31860. */
  31861. mainPivot?: Vector3;
  31862. /**
  31863. * The connected pivot of the joint
  31864. */
  31865. connectedPivot?: Vector3;
  31866. /**
  31867. * The main axis of the joint
  31868. */
  31869. mainAxis?: Vector3;
  31870. /**
  31871. * The connected axis of the joint
  31872. */
  31873. connectedAxis?: Vector3;
  31874. /**
  31875. * The collision of the joint
  31876. */
  31877. collision?: boolean;
  31878. /**
  31879. * Native Oimo/Cannon/Energy data
  31880. */
  31881. nativeParams?: any;
  31882. }
  31883. /**
  31884. * This is a holder class for the physics joint created by the physics plugin
  31885. * It holds a set of functions to control the underlying joint
  31886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31887. */
  31888. export class PhysicsJoint {
  31889. /**
  31890. * The type of the physics joint
  31891. */
  31892. type: number;
  31893. /**
  31894. * The data for the physics joint
  31895. */
  31896. jointData: PhysicsJointData;
  31897. private _physicsJoint;
  31898. protected _physicsPlugin: IPhysicsEnginePlugin;
  31899. /**
  31900. * Initializes the physics joint
  31901. * @param type The type of the physics joint
  31902. * @param jointData The data for the physics joint
  31903. */
  31904. constructor(
  31905. /**
  31906. * The type of the physics joint
  31907. */
  31908. type: number,
  31909. /**
  31910. * The data for the physics joint
  31911. */
  31912. jointData: PhysicsJointData);
  31913. /**
  31914. * Gets the physics joint
  31915. */
  31916. get physicsJoint(): any;
  31917. /**
  31918. * Sets the physics joint
  31919. */
  31920. set physicsJoint(newJoint: any);
  31921. /**
  31922. * Sets the physics plugin
  31923. */
  31924. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31925. /**
  31926. * Execute a function that is physics-plugin specific.
  31927. * @param {Function} func the function that will be executed.
  31928. * It accepts two parameters: the physics world and the physics joint
  31929. */
  31930. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31931. /**
  31932. * Distance-Joint type
  31933. */
  31934. static DistanceJoint: number;
  31935. /**
  31936. * Hinge-Joint type
  31937. */
  31938. static HingeJoint: number;
  31939. /**
  31940. * Ball-and-Socket joint type
  31941. */
  31942. static BallAndSocketJoint: number;
  31943. /**
  31944. * Wheel-Joint type
  31945. */
  31946. static WheelJoint: number;
  31947. /**
  31948. * Slider-Joint type
  31949. */
  31950. static SliderJoint: number;
  31951. /**
  31952. * Prismatic-Joint type
  31953. */
  31954. static PrismaticJoint: number;
  31955. /**
  31956. * Universal-Joint type
  31957. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31958. */
  31959. static UniversalJoint: number;
  31960. /**
  31961. * Hinge-Joint 2 type
  31962. */
  31963. static Hinge2Joint: number;
  31964. /**
  31965. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31966. */
  31967. static PointToPointJoint: number;
  31968. /**
  31969. * Spring-Joint type
  31970. */
  31971. static SpringJoint: number;
  31972. /**
  31973. * Lock-Joint type
  31974. */
  31975. static LockJoint: number;
  31976. }
  31977. /**
  31978. * A class representing a physics distance joint
  31979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31980. */
  31981. export class DistanceJoint extends PhysicsJoint {
  31982. /**
  31983. *
  31984. * @param jointData The data for the Distance-Joint
  31985. */
  31986. constructor(jointData: DistanceJointData);
  31987. /**
  31988. * Update the predefined distance.
  31989. * @param maxDistance The maximum preferred distance
  31990. * @param minDistance The minimum preferred distance
  31991. */
  31992. updateDistance(maxDistance: number, minDistance?: number): void;
  31993. }
  31994. /**
  31995. * Represents a Motor-Enabled Joint
  31996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31997. */
  31998. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31999. /**
  32000. * Initializes the Motor-Enabled Joint
  32001. * @param type The type of the joint
  32002. * @param jointData The physica joint data for the joint
  32003. */
  32004. constructor(type: number, jointData: PhysicsJointData);
  32005. /**
  32006. * Set the motor values.
  32007. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32008. * @param force the force to apply
  32009. * @param maxForce max force for this motor.
  32010. */
  32011. setMotor(force?: number, maxForce?: number): void;
  32012. /**
  32013. * Set the motor's limits.
  32014. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32015. * @param upperLimit The upper limit of the motor
  32016. * @param lowerLimit The lower limit of the motor
  32017. */
  32018. setLimit(upperLimit: number, lowerLimit?: number): void;
  32019. }
  32020. /**
  32021. * This class represents a single physics Hinge-Joint
  32022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32023. */
  32024. export class HingeJoint extends MotorEnabledJoint {
  32025. /**
  32026. * Initializes the Hinge-Joint
  32027. * @param jointData The joint data for the Hinge-Joint
  32028. */
  32029. constructor(jointData: PhysicsJointData);
  32030. /**
  32031. * Set the motor values.
  32032. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32033. * @param {number} force the force to apply
  32034. * @param {number} maxForce max force for this motor.
  32035. */
  32036. setMotor(force?: number, maxForce?: number): void;
  32037. /**
  32038. * Set the motor's limits.
  32039. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32040. * @param upperLimit The upper limit of the motor
  32041. * @param lowerLimit The lower limit of the motor
  32042. */
  32043. setLimit(upperLimit: number, lowerLimit?: number): void;
  32044. }
  32045. /**
  32046. * This class represents a dual hinge physics joint (same as wheel joint)
  32047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32048. */
  32049. export class Hinge2Joint extends MotorEnabledJoint {
  32050. /**
  32051. * Initializes the Hinge2-Joint
  32052. * @param jointData The joint data for the Hinge2-Joint
  32053. */
  32054. constructor(jointData: PhysicsJointData);
  32055. /**
  32056. * Set the motor values.
  32057. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32058. * @param {number} targetSpeed the speed the motor is to reach
  32059. * @param {number} maxForce max force for this motor.
  32060. * @param {motorIndex} the motor's index, 0 or 1.
  32061. */
  32062. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32063. /**
  32064. * Set the motor limits.
  32065. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32066. * @param {number} upperLimit the upper limit
  32067. * @param {number} lowerLimit lower limit
  32068. * @param {motorIndex} the motor's index, 0 or 1.
  32069. */
  32070. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32071. }
  32072. /**
  32073. * Interface for a motor enabled joint
  32074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32075. */
  32076. export interface IMotorEnabledJoint {
  32077. /**
  32078. * Physics joint
  32079. */
  32080. physicsJoint: any;
  32081. /**
  32082. * Sets the motor of the motor-enabled joint
  32083. * @param force The force of the motor
  32084. * @param maxForce The maximum force of the motor
  32085. * @param motorIndex The index of the motor
  32086. */
  32087. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32088. /**
  32089. * Sets the limit of the motor
  32090. * @param upperLimit The upper limit of the motor
  32091. * @param lowerLimit The lower limit of the motor
  32092. * @param motorIndex The index of the motor
  32093. */
  32094. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32095. }
  32096. /**
  32097. * Joint data for a Distance-Joint
  32098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32099. */
  32100. export interface DistanceJointData extends PhysicsJointData {
  32101. /**
  32102. * Max distance the 2 joint objects can be apart
  32103. */
  32104. maxDistance: number;
  32105. }
  32106. /**
  32107. * Joint data from a spring joint
  32108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32109. */
  32110. export interface SpringJointData extends PhysicsJointData {
  32111. /**
  32112. * Length of the spring
  32113. */
  32114. length: number;
  32115. /**
  32116. * Stiffness of the spring
  32117. */
  32118. stiffness: number;
  32119. /**
  32120. * Damping of the spring
  32121. */
  32122. damping: number;
  32123. /** this callback will be called when applying the force to the impostors. */
  32124. forceApplicationCallback: () => void;
  32125. }
  32126. }
  32127. declare module BABYLON {
  32128. /**
  32129. * Holds the data for the raycast result
  32130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32131. */
  32132. export class PhysicsRaycastResult {
  32133. private _hasHit;
  32134. private _hitDistance;
  32135. private _hitNormalWorld;
  32136. private _hitPointWorld;
  32137. private _rayFromWorld;
  32138. private _rayToWorld;
  32139. /**
  32140. * Gets if there was a hit
  32141. */
  32142. get hasHit(): boolean;
  32143. /**
  32144. * Gets the distance from the hit
  32145. */
  32146. get hitDistance(): number;
  32147. /**
  32148. * Gets the hit normal/direction in the world
  32149. */
  32150. get hitNormalWorld(): Vector3;
  32151. /**
  32152. * Gets the hit point in the world
  32153. */
  32154. get hitPointWorld(): Vector3;
  32155. /**
  32156. * Gets the ray "start point" of the ray in the world
  32157. */
  32158. get rayFromWorld(): Vector3;
  32159. /**
  32160. * Gets the ray "end point" of the ray in the world
  32161. */
  32162. get rayToWorld(): Vector3;
  32163. /**
  32164. * Sets the hit data (normal & point in world space)
  32165. * @param hitNormalWorld defines the normal in world space
  32166. * @param hitPointWorld defines the point in world space
  32167. */
  32168. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32169. /**
  32170. * Sets the distance from the start point to the hit point
  32171. * @param distance
  32172. */
  32173. setHitDistance(distance: number): void;
  32174. /**
  32175. * Calculates the distance manually
  32176. */
  32177. calculateHitDistance(): void;
  32178. /**
  32179. * Resets all the values to default
  32180. * @param from The from point on world space
  32181. * @param to The to point on world space
  32182. */
  32183. reset(from?: Vector3, to?: Vector3): void;
  32184. }
  32185. /**
  32186. * Interface for the size containing width and height
  32187. */
  32188. interface IXYZ {
  32189. /**
  32190. * X
  32191. */
  32192. x: number;
  32193. /**
  32194. * Y
  32195. */
  32196. y: number;
  32197. /**
  32198. * Z
  32199. */
  32200. z: number;
  32201. }
  32202. }
  32203. declare module BABYLON {
  32204. /**
  32205. * Interface used to describe a physics joint
  32206. */
  32207. export interface PhysicsImpostorJoint {
  32208. /** Defines the main impostor to which the joint is linked */
  32209. mainImpostor: PhysicsImpostor;
  32210. /** Defines the impostor that is connected to the main impostor using this joint */
  32211. connectedImpostor: PhysicsImpostor;
  32212. /** Defines the joint itself */
  32213. joint: PhysicsJoint;
  32214. }
  32215. /** @hidden */
  32216. export interface IPhysicsEnginePlugin {
  32217. world: any;
  32218. name: string;
  32219. setGravity(gravity: Vector3): void;
  32220. setTimeStep(timeStep: number): void;
  32221. getTimeStep(): number;
  32222. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32223. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32225. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32226. removePhysicsBody(impostor: PhysicsImpostor): void;
  32227. generateJoint(joint: PhysicsImpostorJoint): void;
  32228. removeJoint(joint: PhysicsImpostorJoint): void;
  32229. isSupported(): boolean;
  32230. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32231. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32232. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32233. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32234. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32235. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32236. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32237. getBodyMass(impostor: PhysicsImpostor): number;
  32238. getBodyFriction(impostor: PhysicsImpostor): number;
  32239. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32240. getBodyRestitution(impostor: PhysicsImpostor): number;
  32241. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32242. getBodyPressure?(impostor: PhysicsImpostor): number;
  32243. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32244. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32245. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32246. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32247. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32248. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32249. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32250. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32251. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32252. sleepBody(impostor: PhysicsImpostor): void;
  32253. wakeUpBody(impostor: PhysicsImpostor): void;
  32254. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32256. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32257. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32258. getRadius(impostor: PhysicsImpostor): number;
  32259. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32260. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32261. dispose(): void;
  32262. }
  32263. /**
  32264. * Interface used to define a physics engine
  32265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32266. */
  32267. export interface IPhysicsEngine {
  32268. /**
  32269. * Gets the gravity vector used by the simulation
  32270. */
  32271. gravity: Vector3;
  32272. /**
  32273. * Sets the gravity vector used by the simulation
  32274. * @param gravity defines the gravity vector to use
  32275. */
  32276. setGravity(gravity: Vector3): void;
  32277. /**
  32278. * Set the time step of the physics engine.
  32279. * Default is 1/60.
  32280. * To slow it down, enter 1/600 for example.
  32281. * To speed it up, 1/30
  32282. * @param newTimeStep the new timestep to apply to this world.
  32283. */
  32284. setTimeStep(newTimeStep: number): void;
  32285. /**
  32286. * Get the time step of the physics engine.
  32287. * @returns the current time step
  32288. */
  32289. getTimeStep(): number;
  32290. /**
  32291. * Set the sub time step of the physics engine.
  32292. * Default is 0 meaning there is no sub steps
  32293. * To increase physics resolution precision, set a small value (like 1 ms)
  32294. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32295. */
  32296. setSubTimeStep(subTimeStep: number): void;
  32297. /**
  32298. * Get the sub time step of the physics engine.
  32299. * @returns the current sub time step
  32300. */
  32301. getSubTimeStep(): number;
  32302. /**
  32303. * Release all resources
  32304. */
  32305. dispose(): void;
  32306. /**
  32307. * Gets the name of the current physics plugin
  32308. * @returns the name of the plugin
  32309. */
  32310. getPhysicsPluginName(): string;
  32311. /**
  32312. * Adding a new impostor for the impostor tracking.
  32313. * This will be done by the impostor itself.
  32314. * @param impostor the impostor to add
  32315. */
  32316. addImpostor(impostor: PhysicsImpostor): void;
  32317. /**
  32318. * Remove an impostor from the engine.
  32319. * This impostor and its mesh will not longer be updated by the physics engine.
  32320. * @param impostor the impostor to remove
  32321. */
  32322. removeImpostor(impostor: PhysicsImpostor): void;
  32323. /**
  32324. * Add a joint to the physics engine
  32325. * @param mainImpostor defines the main impostor to which the joint is added.
  32326. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32327. * @param joint defines the joint that will connect both impostors.
  32328. */
  32329. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32330. /**
  32331. * Removes a joint from the simulation
  32332. * @param mainImpostor defines the impostor used with the joint
  32333. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32334. * @param joint defines the joint to remove
  32335. */
  32336. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32337. /**
  32338. * Gets the current plugin used to run the simulation
  32339. * @returns current plugin
  32340. */
  32341. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32342. /**
  32343. * Gets the list of physic impostors
  32344. * @returns an array of PhysicsImpostor
  32345. */
  32346. getImpostors(): Array<PhysicsImpostor>;
  32347. /**
  32348. * Gets the impostor for a physics enabled object
  32349. * @param object defines the object impersonated by the impostor
  32350. * @returns the PhysicsImpostor or null if not found
  32351. */
  32352. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32353. /**
  32354. * Gets the impostor for a physics body object
  32355. * @param body defines physics body used by the impostor
  32356. * @returns the PhysicsImpostor or null if not found
  32357. */
  32358. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32359. /**
  32360. * Does a raycast in the physics world
  32361. * @param from when should the ray start?
  32362. * @param to when should the ray end?
  32363. * @returns PhysicsRaycastResult
  32364. */
  32365. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32366. /**
  32367. * Called by the scene. No need to call it.
  32368. * @param delta defines the timespam between frames
  32369. */
  32370. _step(delta: number): void;
  32371. }
  32372. }
  32373. declare module BABYLON {
  32374. /**
  32375. * The interface for the physics imposter parameters
  32376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32377. */
  32378. export interface PhysicsImpostorParameters {
  32379. /**
  32380. * The mass of the physics imposter
  32381. */
  32382. mass: number;
  32383. /**
  32384. * The friction of the physics imposter
  32385. */
  32386. friction?: number;
  32387. /**
  32388. * The coefficient of restitution of the physics imposter
  32389. */
  32390. restitution?: number;
  32391. /**
  32392. * The native options of the physics imposter
  32393. */
  32394. nativeOptions?: any;
  32395. /**
  32396. * Specifies if the parent should be ignored
  32397. */
  32398. ignoreParent?: boolean;
  32399. /**
  32400. * Specifies if bi-directional transformations should be disabled
  32401. */
  32402. disableBidirectionalTransformation?: boolean;
  32403. /**
  32404. * The pressure inside the physics imposter, soft object only
  32405. */
  32406. pressure?: number;
  32407. /**
  32408. * The stiffness the physics imposter, soft object only
  32409. */
  32410. stiffness?: number;
  32411. /**
  32412. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32413. */
  32414. velocityIterations?: number;
  32415. /**
  32416. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32417. */
  32418. positionIterations?: number;
  32419. /**
  32420. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32421. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32422. * Add to fix multiple points
  32423. */
  32424. fixedPoints?: number;
  32425. /**
  32426. * The collision margin around a soft object
  32427. */
  32428. margin?: number;
  32429. /**
  32430. * The collision margin around a soft object
  32431. */
  32432. damping?: number;
  32433. /**
  32434. * The path for a rope based on an extrusion
  32435. */
  32436. path?: any;
  32437. /**
  32438. * The shape of an extrusion used for a rope based on an extrusion
  32439. */
  32440. shape?: any;
  32441. }
  32442. /**
  32443. * Interface for a physics-enabled object
  32444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32445. */
  32446. export interface IPhysicsEnabledObject {
  32447. /**
  32448. * The position of the physics-enabled object
  32449. */
  32450. position: Vector3;
  32451. /**
  32452. * The rotation of the physics-enabled object
  32453. */
  32454. rotationQuaternion: Nullable<Quaternion>;
  32455. /**
  32456. * The scale of the physics-enabled object
  32457. */
  32458. scaling: Vector3;
  32459. /**
  32460. * The rotation of the physics-enabled object
  32461. */
  32462. rotation?: Vector3;
  32463. /**
  32464. * The parent of the physics-enabled object
  32465. */
  32466. parent?: any;
  32467. /**
  32468. * The bounding info of the physics-enabled object
  32469. * @returns The bounding info of the physics-enabled object
  32470. */
  32471. getBoundingInfo(): BoundingInfo;
  32472. /**
  32473. * Computes the world matrix
  32474. * @param force Specifies if the world matrix should be computed by force
  32475. * @returns A world matrix
  32476. */
  32477. computeWorldMatrix(force: boolean): Matrix;
  32478. /**
  32479. * Gets the world matrix
  32480. * @returns A world matrix
  32481. */
  32482. getWorldMatrix?(): Matrix;
  32483. /**
  32484. * Gets the child meshes
  32485. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32486. * @returns An array of abstract meshes
  32487. */
  32488. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32489. /**
  32490. * Gets the vertex data
  32491. * @param kind The type of vertex data
  32492. * @returns A nullable array of numbers, or a float32 array
  32493. */
  32494. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32495. /**
  32496. * Gets the indices from the mesh
  32497. * @returns A nullable array of index arrays
  32498. */
  32499. getIndices?(): Nullable<IndicesArray>;
  32500. /**
  32501. * Gets the scene from the mesh
  32502. * @returns the indices array or null
  32503. */
  32504. getScene?(): Scene;
  32505. /**
  32506. * Gets the absolute position from the mesh
  32507. * @returns the absolute position
  32508. */
  32509. getAbsolutePosition(): Vector3;
  32510. /**
  32511. * Gets the absolute pivot point from the mesh
  32512. * @returns the absolute pivot point
  32513. */
  32514. getAbsolutePivotPoint(): Vector3;
  32515. /**
  32516. * Rotates the mesh
  32517. * @param axis The axis of rotation
  32518. * @param amount The amount of rotation
  32519. * @param space The space of the rotation
  32520. * @returns The rotation transform node
  32521. */
  32522. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32523. /**
  32524. * Translates the mesh
  32525. * @param axis The axis of translation
  32526. * @param distance The distance of translation
  32527. * @param space The space of the translation
  32528. * @returns The transform node
  32529. */
  32530. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32531. /**
  32532. * Sets the absolute position of the mesh
  32533. * @param absolutePosition The absolute position of the mesh
  32534. * @returns The transform node
  32535. */
  32536. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32537. /**
  32538. * Gets the class name of the mesh
  32539. * @returns The class name
  32540. */
  32541. getClassName(): string;
  32542. }
  32543. /**
  32544. * Represents a physics imposter
  32545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32546. */
  32547. export class PhysicsImpostor {
  32548. /**
  32549. * The physics-enabled object used as the physics imposter
  32550. */
  32551. object: IPhysicsEnabledObject;
  32552. /**
  32553. * The type of the physics imposter
  32554. */
  32555. type: number;
  32556. private _options;
  32557. private _scene?;
  32558. /**
  32559. * The default object size of the imposter
  32560. */
  32561. static DEFAULT_OBJECT_SIZE: Vector3;
  32562. /**
  32563. * The identity quaternion of the imposter
  32564. */
  32565. static IDENTITY_QUATERNION: Quaternion;
  32566. /** @hidden */
  32567. _pluginData: any;
  32568. private _physicsEngine;
  32569. private _physicsBody;
  32570. private _bodyUpdateRequired;
  32571. private _onBeforePhysicsStepCallbacks;
  32572. private _onAfterPhysicsStepCallbacks;
  32573. /** @hidden */
  32574. _onPhysicsCollideCallbacks: Array<{
  32575. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32576. otherImpostors: Array<PhysicsImpostor>;
  32577. }>;
  32578. private _deltaPosition;
  32579. private _deltaRotation;
  32580. private _deltaRotationConjugated;
  32581. /** @hidden */
  32582. _isFromLine: boolean;
  32583. private _parent;
  32584. private _isDisposed;
  32585. private static _tmpVecs;
  32586. private static _tmpQuat;
  32587. /**
  32588. * Specifies if the physics imposter is disposed
  32589. */
  32590. get isDisposed(): boolean;
  32591. /**
  32592. * Gets the mass of the physics imposter
  32593. */
  32594. get mass(): number;
  32595. set mass(value: number);
  32596. /**
  32597. * Gets the coefficient of friction
  32598. */
  32599. get friction(): number;
  32600. /**
  32601. * Sets the coefficient of friction
  32602. */
  32603. set friction(value: number);
  32604. /**
  32605. * Gets the coefficient of restitution
  32606. */
  32607. get restitution(): number;
  32608. /**
  32609. * Sets the coefficient of restitution
  32610. */
  32611. set restitution(value: number);
  32612. /**
  32613. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32614. */
  32615. get pressure(): number;
  32616. /**
  32617. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32618. */
  32619. set pressure(value: number);
  32620. /**
  32621. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32622. */
  32623. get stiffness(): number;
  32624. /**
  32625. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32626. */
  32627. set stiffness(value: number);
  32628. /**
  32629. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32630. */
  32631. get velocityIterations(): number;
  32632. /**
  32633. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32634. */
  32635. set velocityIterations(value: number);
  32636. /**
  32637. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32638. */
  32639. get positionIterations(): number;
  32640. /**
  32641. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32642. */
  32643. set positionIterations(value: number);
  32644. /**
  32645. * The unique id of the physics imposter
  32646. * set by the physics engine when adding this impostor to the array
  32647. */
  32648. uniqueId: number;
  32649. /**
  32650. * @hidden
  32651. */
  32652. soft: boolean;
  32653. /**
  32654. * @hidden
  32655. */
  32656. segments: number;
  32657. private _joints;
  32658. /**
  32659. * Initializes the physics imposter
  32660. * @param object The physics-enabled object used as the physics imposter
  32661. * @param type The type of the physics imposter
  32662. * @param _options The options for the physics imposter
  32663. * @param _scene The Babylon scene
  32664. */
  32665. constructor(
  32666. /**
  32667. * The physics-enabled object used as the physics imposter
  32668. */
  32669. object: IPhysicsEnabledObject,
  32670. /**
  32671. * The type of the physics imposter
  32672. */
  32673. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32674. /**
  32675. * This function will completly initialize this impostor.
  32676. * It will create a new body - but only if this mesh has no parent.
  32677. * If it has, this impostor will not be used other than to define the impostor
  32678. * of the child mesh.
  32679. * @hidden
  32680. */
  32681. _init(): void;
  32682. private _getPhysicsParent;
  32683. /**
  32684. * Should a new body be generated.
  32685. * @returns boolean specifying if body initialization is required
  32686. */
  32687. isBodyInitRequired(): boolean;
  32688. /**
  32689. * Sets the updated scaling
  32690. * @param updated Specifies if the scaling is updated
  32691. */
  32692. setScalingUpdated(): void;
  32693. /**
  32694. * Force a regeneration of this or the parent's impostor's body.
  32695. * Use under cautious - This will remove all joints already implemented.
  32696. */
  32697. forceUpdate(): void;
  32698. /**
  32699. * Gets the body that holds this impostor. Either its own, or its parent.
  32700. */
  32701. get physicsBody(): any;
  32702. /**
  32703. * Get the parent of the physics imposter
  32704. * @returns Physics imposter or null
  32705. */
  32706. get parent(): Nullable<PhysicsImpostor>;
  32707. /**
  32708. * Sets the parent of the physics imposter
  32709. */
  32710. set parent(value: Nullable<PhysicsImpostor>);
  32711. /**
  32712. * Set the physics body. Used mainly by the physics engine/plugin
  32713. */
  32714. set physicsBody(physicsBody: any);
  32715. /**
  32716. * Resets the update flags
  32717. */
  32718. resetUpdateFlags(): void;
  32719. /**
  32720. * Gets the object extend size
  32721. * @returns the object extend size
  32722. */
  32723. getObjectExtendSize(): Vector3;
  32724. /**
  32725. * Gets the object center
  32726. * @returns The object center
  32727. */
  32728. getObjectCenter(): Vector3;
  32729. /**
  32730. * Get a specific parameter from the options parameters
  32731. * @param paramName The object parameter name
  32732. * @returns The object parameter
  32733. */
  32734. getParam(paramName: string): any;
  32735. /**
  32736. * Sets a specific parameter in the options given to the physics plugin
  32737. * @param paramName The parameter name
  32738. * @param value The value of the parameter
  32739. */
  32740. setParam(paramName: string, value: number): void;
  32741. /**
  32742. * Specifically change the body's mass option. Won't recreate the physics body object
  32743. * @param mass The mass of the physics imposter
  32744. */
  32745. setMass(mass: number): void;
  32746. /**
  32747. * Gets the linear velocity
  32748. * @returns linear velocity or null
  32749. */
  32750. getLinearVelocity(): Nullable<Vector3>;
  32751. /**
  32752. * Sets the linear velocity
  32753. * @param velocity linear velocity or null
  32754. */
  32755. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32756. /**
  32757. * Gets the angular velocity
  32758. * @returns angular velocity or null
  32759. */
  32760. getAngularVelocity(): Nullable<Vector3>;
  32761. /**
  32762. * Sets the angular velocity
  32763. * @param velocity The velocity or null
  32764. */
  32765. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32766. /**
  32767. * Execute a function with the physics plugin native code
  32768. * Provide a function the will have two variables - the world object and the physics body object
  32769. * @param func The function to execute with the physics plugin native code
  32770. */
  32771. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32772. /**
  32773. * Register a function that will be executed before the physics world is stepping forward
  32774. * @param func The function to execute before the physics world is stepped forward
  32775. */
  32776. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32777. /**
  32778. * Unregister a function that will be executed before the physics world is stepping forward
  32779. * @param func The function to execute before the physics world is stepped forward
  32780. */
  32781. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32782. /**
  32783. * Register a function that will be executed after the physics step
  32784. * @param func The function to execute after physics step
  32785. */
  32786. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32787. /**
  32788. * Unregisters a function that will be executed after the physics step
  32789. * @param func The function to execute after physics step
  32790. */
  32791. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32792. /**
  32793. * register a function that will be executed when this impostor collides against a different body
  32794. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32795. * @param func Callback that is executed on collision
  32796. */
  32797. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32798. /**
  32799. * Unregisters the physics imposter on contact
  32800. * @param collideAgainst The physics object to collide against
  32801. * @param func Callback to execute on collision
  32802. */
  32803. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32804. private _tmpQuat;
  32805. private _tmpQuat2;
  32806. /**
  32807. * Get the parent rotation
  32808. * @returns The parent rotation
  32809. */
  32810. getParentsRotation(): Quaternion;
  32811. /**
  32812. * this function is executed by the physics engine.
  32813. */
  32814. beforeStep: () => void;
  32815. /**
  32816. * this function is executed by the physics engine
  32817. */
  32818. afterStep: () => void;
  32819. /**
  32820. * Legacy collision detection event support
  32821. */
  32822. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32823. /**
  32824. * event and body object due to cannon's event-based architecture.
  32825. */
  32826. onCollide: (e: {
  32827. body: any;
  32828. point: Nullable<Vector3>;
  32829. }) => void;
  32830. /**
  32831. * Apply a force
  32832. * @param force The force to apply
  32833. * @param contactPoint The contact point for the force
  32834. * @returns The physics imposter
  32835. */
  32836. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32837. /**
  32838. * Apply an impulse
  32839. * @param force The impulse force
  32840. * @param contactPoint The contact point for the impulse force
  32841. * @returns The physics imposter
  32842. */
  32843. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32844. /**
  32845. * A help function to create a joint
  32846. * @param otherImpostor A physics imposter used to create a joint
  32847. * @param jointType The type of joint
  32848. * @param jointData The data for the joint
  32849. * @returns The physics imposter
  32850. */
  32851. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32852. /**
  32853. * Add a joint to this impostor with a different impostor
  32854. * @param otherImpostor A physics imposter used to add a joint
  32855. * @param joint The joint to add
  32856. * @returns The physics imposter
  32857. */
  32858. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32859. /**
  32860. * Add an anchor to a cloth impostor
  32861. * @param otherImpostor rigid impostor to anchor to
  32862. * @param width ratio across width from 0 to 1
  32863. * @param height ratio up height from 0 to 1
  32864. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32865. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32866. * @returns impostor the soft imposter
  32867. */
  32868. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32869. /**
  32870. * Add a hook to a rope impostor
  32871. * @param otherImpostor rigid impostor to anchor to
  32872. * @param length ratio across rope from 0 to 1
  32873. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32874. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32875. * @returns impostor the rope imposter
  32876. */
  32877. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32878. /**
  32879. * Will keep this body still, in a sleep mode.
  32880. * @returns the physics imposter
  32881. */
  32882. sleep(): PhysicsImpostor;
  32883. /**
  32884. * Wake the body up.
  32885. * @returns The physics imposter
  32886. */
  32887. wakeUp(): PhysicsImpostor;
  32888. /**
  32889. * Clones the physics imposter
  32890. * @param newObject The physics imposter clones to this physics-enabled object
  32891. * @returns A nullable physics imposter
  32892. */
  32893. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32894. /**
  32895. * Disposes the physics imposter
  32896. */
  32897. dispose(): void;
  32898. /**
  32899. * Sets the delta position
  32900. * @param position The delta position amount
  32901. */
  32902. setDeltaPosition(position: Vector3): void;
  32903. /**
  32904. * Sets the delta rotation
  32905. * @param rotation The delta rotation amount
  32906. */
  32907. setDeltaRotation(rotation: Quaternion): void;
  32908. /**
  32909. * Gets the box size of the physics imposter and stores the result in the input parameter
  32910. * @param result Stores the box size
  32911. * @returns The physics imposter
  32912. */
  32913. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32914. /**
  32915. * Gets the radius of the physics imposter
  32916. * @returns Radius of the physics imposter
  32917. */
  32918. getRadius(): number;
  32919. /**
  32920. * Sync a bone with this impostor
  32921. * @param bone The bone to sync to the impostor.
  32922. * @param boneMesh The mesh that the bone is influencing.
  32923. * @param jointPivot The pivot of the joint / bone in local space.
  32924. * @param distToJoint Optional distance from the impostor to the joint.
  32925. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32926. */
  32927. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32928. /**
  32929. * Sync impostor to a bone
  32930. * @param bone The bone that the impostor will be synced to.
  32931. * @param boneMesh The mesh that the bone is influencing.
  32932. * @param jointPivot The pivot of the joint / bone in local space.
  32933. * @param distToJoint Optional distance from the impostor to the joint.
  32934. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32935. * @param boneAxis Optional vector3 axis the bone is aligned with
  32936. */
  32937. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32938. /**
  32939. * No-Imposter type
  32940. */
  32941. static NoImpostor: number;
  32942. /**
  32943. * Sphere-Imposter type
  32944. */
  32945. static SphereImpostor: number;
  32946. /**
  32947. * Box-Imposter type
  32948. */
  32949. static BoxImpostor: number;
  32950. /**
  32951. * Plane-Imposter type
  32952. */
  32953. static PlaneImpostor: number;
  32954. /**
  32955. * Mesh-imposter type
  32956. */
  32957. static MeshImpostor: number;
  32958. /**
  32959. * Capsule-Impostor type (Ammo.js plugin only)
  32960. */
  32961. static CapsuleImpostor: number;
  32962. /**
  32963. * Cylinder-Imposter type
  32964. */
  32965. static CylinderImpostor: number;
  32966. /**
  32967. * Particle-Imposter type
  32968. */
  32969. static ParticleImpostor: number;
  32970. /**
  32971. * Heightmap-Imposter type
  32972. */
  32973. static HeightmapImpostor: number;
  32974. /**
  32975. * ConvexHull-Impostor type (Ammo.js plugin only)
  32976. */
  32977. static ConvexHullImpostor: number;
  32978. /**
  32979. * Custom-Imposter type (Ammo.js plugin only)
  32980. */
  32981. static CustomImpostor: number;
  32982. /**
  32983. * Rope-Imposter type
  32984. */
  32985. static RopeImpostor: number;
  32986. /**
  32987. * Cloth-Imposter type
  32988. */
  32989. static ClothImpostor: number;
  32990. /**
  32991. * Softbody-Imposter type
  32992. */
  32993. static SoftbodyImpostor: number;
  32994. }
  32995. }
  32996. declare module BABYLON {
  32997. /**
  32998. * @hidden
  32999. **/
  33000. export class _CreationDataStorage {
  33001. closePath?: boolean;
  33002. closeArray?: boolean;
  33003. idx: number[];
  33004. dashSize: number;
  33005. gapSize: number;
  33006. path3D: Path3D;
  33007. pathArray: Vector3[][];
  33008. arc: number;
  33009. radius: number;
  33010. cap: number;
  33011. tessellation: number;
  33012. }
  33013. /**
  33014. * @hidden
  33015. **/
  33016. class _InstanceDataStorage {
  33017. visibleInstances: any;
  33018. batchCache: _InstancesBatch;
  33019. instancesBufferSize: number;
  33020. instancesBuffer: Nullable<Buffer>;
  33021. instancesData: Float32Array;
  33022. overridenInstanceCount: number;
  33023. isFrozen: boolean;
  33024. previousBatch: Nullable<_InstancesBatch>;
  33025. hardwareInstancedRendering: boolean;
  33026. sideOrientation: number;
  33027. manualUpdate: boolean;
  33028. previousRenderId: number;
  33029. }
  33030. /**
  33031. * @hidden
  33032. **/
  33033. export class _InstancesBatch {
  33034. mustReturn: boolean;
  33035. visibleInstances: Nullable<InstancedMesh[]>[];
  33036. renderSelf: boolean[];
  33037. hardwareInstancedRendering: boolean[];
  33038. }
  33039. /**
  33040. * @hidden
  33041. **/
  33042. class _ThinInstanceDataStorage {
  33043. instancesCount: number;
  33044. matrixBuffer: Nullable<Buffer>;
  33045. matrixBufferSize: number;
  33046. matrixData: Nullable<Float32Array>;
  33047. boundingVectors: Array<Vector3>;
  33048. worldMatrices: Nullable<Matrix[]>;
  33049. }
  33050. /**
  33051. * Class used to represent renderable models
  33052. */
  33053. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33054. /**
  33055. * Mesh side orientation : usually the external or front surface
  33056. */
  33057. static readonly FRONTSIDE: number;
  33058. /**
  33059. * Mesh side orientation : usually the internal or back surface
  33060. */
  33061. static readonly BACKSIDE: number;
  33062. /**
  33063. * Mesh side orientation : both internal and external or front and back surfaces
  33064. */
  33065. static readonly DOUBLESIDE: number;
  33066. /**
  33067. * Mesh side orientation : by default, `FRONTSIDE`
  33068. */
  33069. static readonly DEFAULTSIDE: number;
  33070. /**
  33071. * Mesh cap setting : no cap
  33072. */
  33073. static readonly NO_CAP: number;
  33074. /**
  33075. * Mesh cap setting : one cap at the beginning of the mesh
  33076. */
  33077. static readonly CAP_START: number;
  33078. /**
  33079. * Mesh cap setting : one cap at the end of the mesh
  33080. */
  33081. static readonly CAP_END: number;
  33082. /**
  33083. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33084. */
  33085. static readonly CAP_ALL: number;
  33086. /**
  33087. * Mesh pattern setting : no flip or rotate
  33088. */
  33089. static readonly NO_FLIP: number;
  33090. /**
  33091. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33092. */
  33093. static readonly FLIP_TILE: number;
  33094. /**
  33095. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33096. */
  33097. static readonly ROTATE_TILE: number;
  33098. /**
  33099. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33100. */
  33101. static readonly FLIP_ROW: number;
  33102. /**
  33103. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33104. */
  33105. static readonly ROTATE_ROW: number;
  33106. /**
  33107. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33108. */
  33109. static readonly FLIP_N_ROTATE_TILE: number;
  33110. /**
  33111. * Mesh pattern setting : rotate pattern and rotate
  33112. */
  33113. static readonly FLIP_N_ROTATE_ROW: number;
  33114. /**
  33115. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33116. */
  33117. static readonly CENTER: number;
  33118. /**
  33119. * Mesh tile positioning : part tiles on left
  33120. */
  33121. static readonly LEFT: number;
  33122. /**
  33123. * Mesh tile positioning : part tiles on right
  33124. */
  33125. static readonly RIGHT: number;
  33126. /**
  33127. * Mesh tile positioning : part tiles on top
  33128. */
  33129. static readonly TOP: number;
  33130. /**
  33131. * Mesh tile positioning : part tiles on bottom
  33132. */
  33133. static readonly BOTTOM: number;
  33134. /**
  33135. * Gets the default side orientation.
  33136. * @param orientation the orientation to value to attempt to get
  33137. * @returns the default orientation
  33138. * @hidden
  33139. */
  33140. static _GetDefaultSideOrientation(orientation?: number): number;
  33141. private _internalMeshDataInfo;
  33142. get computeBonesUsingShaders(): boolean;
  33143. set computeBonesUsingShaders(value: boolean);
  33144. /**
  33145. * An event triggered before rendering the mesh
  33146. */
  33147. get onBeforeRenderObservable(): Observable<Mesh>;
  33148. /**
  33149. * An event triggered before binding the mesh
  33150. */
  33151. get onBeforeBindObservable(): Observable<Mesh>;
  33152. /**
  33153. * An event triggered after rendering the mesh
  33154. */
  33155. get onAfterRenderObservable(): Observable<Mesh>;
  33156. /**
  33157. * An event triggered before drawing the mesh
  33158. */
  33159. get onBeforeDrawObservable(): Observable<Mesh>;
  33160. private _onBeforeDrawObserver;
  33161. /**
  33162. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33163. */
  33164. set onBeforeDraw(callback: () => void);
  33165. get hasInstances(): boolean;
  33166. get hasThinInstances(): boolean;
  33167. /**
  33168. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33169. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33170. */
  33171. delayLoadState: number;
  33172. /**
  33173. * Gets the list of instances created from this mesh
  33174. * it is not supposed to be modified manually.
  33175. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33177. */
  33178. instances: InstancedMesh[];
  33179. /**
  33180. * Gets the file containing delay loading data for this mesh
  33181. */
  33182. delayLoadingFile: string;
  33183. /** @hidden */
  33184. _binaryInfo: any;
  33185. /**
  33186. * User defined function used to change how LOD level selection is done
  33187. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33188. */
  33189. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33190. /**
  33191. * Gets or sets the morph target manager
  33192. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33193. */
  33194. get morphTargetManager(): Nullable<MorphTargetManager>;
  33195. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33196. /** @hidden */
  33197. _creationDataStorage: Nullable<_CreationDataStorage>;
  33198. /** @hidden */
  33199. _geometry: Nullable<Geometry>;
  33200. /** @hidden */
  33201. _delayInfo: Array<string>;
  33202. /** @hidden */
  33203. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33204. /** @hidden */
  33205. _instanceDataStorage: _InstanceDataStorage;
  33206. /** @hidden */
  33207. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33208. private _effectiveMaterial;
  33209. /** @hidden */
  33210. _shouldGenerateFlatShading: boolean;
  33211. /** @hidden */
  33212. _originalBuilderSideOrientation: number;
  33213. /**
  33214. * Use this property to change the original side orientation defined at construction time
  33215. */
  33216. overrideMaterialSideOrientation: Nullable<number>;
  33217. /**
  33218. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33219. * Note this will reduce performance when set to true.
  33220. */
  33221. ignoreCameraMaxZ: boolean;
  33222. /**
  33223. * Gets the source mesh (the one used to clone this one from)
  33224. */
  33225. get source(): Nullable<Mesh>;
  33226. /**
  33227. * Gets the list of clones of this mesh
  33228. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33229. * Note that useClonedMeshMap=true is the default setting
  33230. */
  33231. get cloneMeshMap(): Nullable<{
  33232. [id: string]: Mesh | undefined;
  33233. }>;
  33234. /**
  33235. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33236. */
  33237. get isUnIndexed(): boolean;
  33238. set isUnIndexed(value: boolean);
  33239. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33240. get worldMatrixInstancedBuffer(): Float32Array;
  33241. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33242. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33243. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33244. /**
  33245. * @constructor
  33246. * @param name The value used by scene.getMeshByName() to do a lookup.
  33247. * @param scene The scene to add this mesh to.
  33248. * @param parent The parent of this mesh, if it has one
  33249. * @param source An optional Mesh from which geometry is shared, cloned.
  33250. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33251. * When false, achieved by calling a clone(), also passing False.
  33252. * This will make creation of children, recursive.
  33253. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33254. */
  33255. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33256. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33257. doNotInstantiate: boolean;
  33258. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33259. /**
  33260. * Gets the class name
  33261. * @returns the string "Mesh".
  33262. */
  33263. getClassName(): string;
  33264. /** @hidden */
  33265. get _isMesh(): boolean;
  33266. /**
  33267. * Returns a description of this mesh
  33268. * @param fullDetails define if full details about this mesh must be used
  33269. * @returns a descriptive string representing this mesh
  33270. */
  33271. toString(fullDetails?: boolean): string;
  33272. /** @hidden */
  33273. _unBindEffect(): void;
  33274. /**
  33275. * Gets a boolean indicating if this mesh has LOD
  33276. */
  33277. get hasLODLevels(): boolean;
  33278. /**
  33279. * Gets the list of MeshLODLevel associated with the current mesh
  33280. * @returns an array of MeshLODLevel
  33281. */
  33282. getLODLevels(): MeshLODLevel[];
  33283. private _sortLODLevels;
  33284. /**
  33285. * Add a mesh as LOD level triggered at the given distance.
  33286. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33287. * @param distance The distance from the center of the object to show this level
  33288. * @param mesh The mesh to be added as LOD level (can be null)
  33289. * @return This mesh (for chaining)
  33290. */
  33291. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33292. /**
  33293. * Returns the LOD level mesh at the passed distance or null if not found.
  33294. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33295. * @param distance The distance from the center of the object to show this level
  33296. * @returns a Mesh or `null`
  33297. */
  33298. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33299. /**
  33300. * Remove a mesh from the LOD array
  33301. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33302. * @param mesh defines the mesh to be removed
  33303. * @return This mesh (for chaining)
  33304. */
  33305. removeLODLevel(mesh: Mesh): Mesh;
  33306. /**
  33307. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33308. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33309. * @param camera defines the camera to use to compute distance
  33310. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33311. * @return This mesh (for chaining)
  33312. */
  33313. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33314. /**
  33315. * Gets the mesh internal Geometry object
  33316. */
  33317. get geometry(): Nullable<Geometry>;
  33318. /**
  33319. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33320. * @returns the total number of vertices
  33321. */
  33322. getTotalVertices(): number;
  33323. /**
  33324. * Returns the content of an associated vertex buffer
  33325. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33326. * - VertexBuffer.PositionKind
  33327. * - VertexBuffer.UVKind
  33328. * - VertexBuffer.UV2Kind
  33329. * - VertexBuffer.UV3Kind
  33330. * - VertexBuffer.UV4Kind
  33331. * - VertexBuffer.UV5Kind
  33332. * - VertexBuffer.UV6Kind
  33333. * - VertexBuffer.ColorKind
  33334. * - VertexBuffer.MatricesIndicesKind
  33335. * - VertexBuffer.MatricesIndicesExtraKind
  33336. * - VertexBuffer.MatricesWeightsKind
  33337. * - VertexBuffer.MatricesWeightsExtraKind
  33338. * @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
  33339. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33340. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33341. */
  33342. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33343. /**
  33344. * Returns the mesh VertexBuffer object from the requested `kind`
  33345. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33346. * - VertexBuffer.PositionKind
  33347. * - VertexBuffer.NormalKind
  33348. * - VertexBuffer.UVKind
  33349. * - VertexBuffer.UV2Kind
  33350. * - VertexBuffer.UV3Kind
  33351. * - VertexBuffer.UV4Kind
  33352. * - VertexBuffer.UV5Kind
  33353. * - VertexBuffer.UV6Kind
  33354. * - VertexBuffer.ColorKind
  33355. * - VertexBuffer.MatricesIndicesKind
  33356. * - VertexBuffer.MatricesIndicesExtraKind
  33357. * - VertexBuffer.MatricesWeightsKind
  33358. * - VertexBuffer.MatricesWeightsExtraKind
  33359. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33360. */
  33361. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33362. /**
  33363. * Tests if a specific vertex buffer is associated with this mesh
  33364. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33365. * - VertexBuffer.PositionKind
  33366. * - VertexBuffer.NormalKind
  33367. * - VertexBuffer.UVKind
  33368. * - VertexBuffer.UV2Kind
  33369. * - VertexBuffer.UV3Kind
  33370. * - VertexBuffer.UV4Kind
  33371. * - VertexBuffer.UV5Kind
  33372. * - VertexBuffer.UV6Kind
  33373. * - VertexBuffer.ColorKind
  33374. * - VertexBuffer.MatricesIndicesKind
  33375. * - VertexBuffer.MatricesIndicesExtraKind
  33376. * - VertexBuffer.MatricesWeightsKind
  33377. * - VertexBuffer.MatricesWeightsExtraKind
  33378. * @returns a boolean
  33379. */
  33380. isVerticesDataPresent(kind: string): boolean;
  33381. /**
  33382. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33383. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33384. * - VertexBuffer.PositionKind
  33385. * - VertexBuffer.UVKind
  33386. * - VertexBuffer.UV2Kind
  33387. * - VertexBuffer.UV3Kind
  33388. * - VertexBuffer.UV4Kind
  33389. * - VertexBuffer.UV5Kind
  33390. * - VertexBuffer.UV6Kind
  33391. * - VertexBuffer.ColorKind
  33392. * - VertexBuffer.MatricesIndicesKind
  33393. * - VertexBuffer.MatricesIndicesExtraKind
  33394. * - VertexBuffer.MatricesWeightsKind
  33395. * - VertexBuffer.MatricesWeightsExtraKind
  33396. * @returns a boolean
  33397. */
  33398. isVertexBufferUpdatable(kind: string): boolean;
  33399. /**
  33400. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33401. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33402. * - VertexBuffer.PositionKind
  33403. * - VertexBuffer.NormalKind
  33404. * - VertexBuffer.UVKind
  33405. * - VertexBuffer.UV2Kind
  33406. * - VertexBuffer.UV3Kind
  33407. * - VertexBuffer.UV4Kind
  33408. * - VertexBuffer.UV5Kind
  33409. * - VertexBuffer.UV6Kind
  33410. * - VertexBuffer.ColorKind
  33411. * - VertexBuffer.MatricesIndicesKind
  33412. * - VertexBuffer.MatricesIndicesExtraKind
  33413. * - VertexBuffer.MatricesWeightsKind
  33414. * - VertexBuffer.MatricesWeightsExtraKind
  33415. * @returns an array of strings
  33416. */
  33417. getVerticesDataKinds(): string[];
  33418. /**
  33419. * Returns a positive integer : the total number of indices in this mesh geometry.
  33420. * @returns the numner of indices or zero if the mesh has no geometry.
  33421. */
  33422. getTotalIndices(): number;
  33423. /**
  33424. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33425. * @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.
  33426. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33427. * @returns the indices array or an empty array if the mesh has no geometry
  33428. */
  33429. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33430. get isBlocked(): boolean;
  33431. /**
  33432. * Determine if the current mesh is ready to be rendered
  33433. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33434. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33435. * @returns true if all associated assets are ready (material, textures, shaders)
  33436. */
  33437. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33438. /**
  33439. * 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.
  33440. */
  33441. get areNormalsFrozen(): boolean;
  33442. /**
  33443. * 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.
  33444. * @returns the current mesh
  33445. */
  33446. freezeNormals(): Mesh;
  33447. /**
  33448. * 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
  33449. * @returns the current mesh
  33450. */
  33451. unfreezeNormals(): Mesh;
  33452. /**
  33453. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33454. */
  33455. set overridenInstanceCount(count: number);
  33456. /** @hidden */
  33457. _preActivate(): Mesh;
  33458. /** @hidden */
  33459. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33460. /** @hidden */
  33461. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33462. protected _afterComputeWorldMatrix(): void;
  33463. /** @hidden */
  33464. _postActivate(): void;
  33465. /**
  33466. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33467. * This means the mesh underlying bounding box and sphere are recomputed.
  33468. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33469. * @returns the current mesh
  33470. */
  33471. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33472. /** @hidden */
  33473. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33474. /**
  33475. * This function will subdivide the mesh into multiple submeshes
  33476. * @param count defines the expected number of submeshes
  33477. */
  33478. subdivide(count: number): void;
  33479. /**
  33480. * Copy a FloatArray into a specific associated vertex buffer
  33481. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33482. * - VertexBuffer.PositionKind
  33483. * - VertexBuffer.UVKind
  33484. * - VertexBuffer.UV2Kind
  33485. * - VertexBuffer.UV3Kind
  33486. * - VertexBuffer.UV4Kind
  33487. * - VertexBuffer.UV5Kind
  33488. * - VertexBuffer.UV6Kind
  33489. * - VertexBuffer.ColorKind
  33490. * - VertexBuffer.MatricesIndicesKind
  33491. * - VertexBuffer.MatricesIndicesExtraKind
  33492. * - VertexBuffer.MatricesWeightsKind
  33493. * - VertexBuffer.MatricesWeightsExtraKind
  33494. * @param data defines the data source
  33495. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33496. * @param stride defines the data stride size (can be null)
  33497. * @returns the current mesh
  33498. */
  33499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33500. /**
  33501. * Delete a vertex buffer associated with this mesh
  33502. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33503. * - VertexBuffer.PositionKind
  33504. * - VertexBuffer.UVKind
  33505. * - VertexBuffer.UV2Kind
  33506. * - VertexBuffer.UV3Kind
  33507. * - VertexBuffer.UV4Kind
  33508. * - VertexBuffer.UV5Kind
  33509. * - VertexBuffer.UV6Kind
  33510. * - VertexBuffer.ColorKind
  33511. * - VertexBuffer.MatricesIndicesKind
  33512. * - VertexBuffer.MatricesIndicesExtraKind
  33513. * - VertexBuffer.MatricesWeightsKind
  33514. * - VertexBuffer.MatricesWeightsExtraKind
  33515. */
  33516. removeVerticesData(kind: string): void;
  33517. /**
  33518. * Flags an associated vertex buffer as updatable
  33519. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33520. * - VertexBuffer.PositionKind
  33521. * - VertexBuffer.UVKind
  33522. * - VertexBuffer.UV2Kind
  33523. * - VertexBuffer.UV3Kind
  33524. * - VertexBuffer.UV4Kind
  33525. * - VertexBuffer.UV5Kind
  33526. * - VertexBuffer.UV6Kind
  33527. * - VertexBuffer.ColorKind
  33528. * - VertexBuffer.MatricesIndicesKind
  33529. * - VertexBuffer.MatricesIndicesExtraKind
  33530. * - VertexBuffer.MatricesWeightsKind
  33531. * - VertexBuffer.MatricesWeightsExtraKind
  33532. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33533. */
  33534. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33535. /**
  33536. * Sets the mesh global Vertex Buffer
  33537. * @param buffer defines the buffer to use
  33538. * @returns the current mesh
  33539. */
  33540. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33541. /**
  33542. * Update a specific associated vertex buffer
  33543. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33544. * - VertexBuffer.PositionKind
  33545. * - VertexBuffer.UVKind
  33546. * - VertexBuffer.UV2Kind
  33547. * - VertexBuffer.UV3Kind
  33548. * - VertexBuffer.UV4Kind
  33549. * - VertexBuffer.UV5Kind
  33550. * - VertexBuffer.UV6Kind
  33551. * - VertexBuffer.ColorKind
  33552. * - VertexBuffer.MatricesIndicesKind
  33553. * - VertexBuffer.MatricesIndicesExtraKind
  33554. * - VertexBuffer.MatricesWeightsKind
  33555. * - VertexBuffer.MatricesWeightsExtraKind
  33556. * @param data defines the data source
  33557. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33558. * @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)
  33559. * @returns the current mesh
  33560. */
  33561. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33562. /**
  33563. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33564. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33565. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33566. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33567. * @returns the current mesh
  33568. */
  33569. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33570. /**
  33571. * Creates a un-shared specific occurence of the geometry for the mesh.
  33572. * @returns the current mesh
  33573. */
  33574. makeGeometryUnique(): Mesh;
  33575. /**
  33576. * Set the index buffer of this mesh
  33577. * @param indices defines the source data
  33578. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33579. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33580. * @returns the current mesh
  33581. */
  33582. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33583. /**
  33584. * Update the current index buffer
  33585. * @param indices defines the source data
  33586. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33587. * @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)
  33588. * @returns the current mesh
  33589. */
  33590. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33591. /**
  33592. * Invert the geometry to move from a right handed system to a left handed one.
  33593. * @returns the current mesh
  33594. */
  33595. toLeftHanded(): Mesh;
  33596. /** @hidden */
  33597. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33598. /** @hidden */
  33599. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33600. /**
  33601. * Registers for this mesh a javascript function called just before the rendering process
  33602. * @param func defines the function to call before rendering this mesh
  33603. * @returns the current mesh
  33604. */
  33605. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33606. /**
  33607. * Disposes a previously registered javascript function called before the rendering
  33608. * @param func defines the function to remove
  33609. * @returns the current mesh
  33610. */
  33611. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33612. /**
  33613. * Registers for this mesh a javascript function called just after the rendering is complete
  33614. * @param func defines the function to call after rendering this mesh
  33615. * @returns the current mesh
  33616. */
  33617. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33618. /**
  33619. * Disposes a previously registered javascript function called after the rendering.
  33620. * @param func defines the function to remove
  33621. * @returns the current mesh
  33622. */
  33623. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33624. /** @hidden */
  33625. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33626. /** @hidden */
  33627. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33628. /** @hidden */
  33629. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33630. /** @hidden */
  33631. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33632. /** @hidden */
  33633. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33634. /** @hidden */
  33635. _rebuild(): void;
  33636. /** @hidden */
  33637. _freeze(): void;
  33638. /** @hidden */
  33639. _unFreeze(): void;
  33640. /**
  33641. * 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
  33642. * @param subMesh defines the subMesh to render
  33643. * @param enableAlphaMode defines if alpha mode can be changed
  33644. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33645. * @returns the current mesh
  33646. */
  33647. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33648. private _onBeforeDraw;
  33649. /**
  33650. * Renormalize the mesh and patch it up if there are no weights
  33651. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33652. * However in the case of zero weights then we set just a single influence to 1.
  33653. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33654. */
  33655. cleanMatrixWeights(): void;
  33656. private normalizeSkinFourWeights;
  33657. private normalizeSkinWeightsAndExtra;
  33658. /**
  33659. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33660. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33661. * the user know there was an issue with importing the mesh
  33662. * @returns a validation object with skinned, valid and report string
  33663. */
  33664. validateSkinning(): {
  33665. skinned: boolean;
  33666. valid: boolean;
  33667. report: string;
  33668. };
  33669. /** @hidden */
  33670. _checkDelayState(): Mesh;
  33671. private _queueLoad;
  33672. /**
  33673. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33674. * A mesh is in the frustum if its bounding box intersects the frustum
  33675. * @param frustumPlanes defines the frustum to test
  33676. * @returns true if the mesh is in the frustum planes
  33677. */
  33678. isInFrustum(frustumPlanes: Plane[]): boolean;
  33679. /**
  33680. * Sets the mesh material by the material or multiMaterial `id` property
  33681. * @param id is a string identifying the material or the multiMaterial
  33682. * @returns the current mesh
  33683. */
  33684. setMaterialByID(id: string): Mesh;
  33685. /**
  33686. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33687. * @returns an array of IAnimatable
  33688. */
  33689. getAnimatables(): IAnimatable[];
  33690. /**
  33691. * Modifies the mesh geometry according to the passed transformation matrix.
  33692. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33693. * The mesh normals are modified using the same transformation.
  33694. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33695. * @param transform defines the transform matrix to use
  33696. * @see https://doc.babylonjs.com/resources/baking_transformations
  33697. * @returns the current mesh
  33698. */
  33699. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33700. /**
  33701. * Modifies the mesh geometry according to its own current World Matrix.
  33702. * The mesh World Matrix is then reset.
  33703. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33704. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33705. * @see https://doc.babylonjs.com/resources/baking_transformations
  33706. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33707. * @returns the current mesh
  33708. */
  33709. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33710. /** @hidden */
  33711. get _positions(): Nullable<Vector3[]>;
  33712. /** @hidden */
  33713. _resetPointsArrayCache(): Mesh;
  33714. /** @hidden */
  33715. _generatePointsArray(): boolean;
  33716. /**
  33717. * Returns a new Mesh object generated from the current mesh properties.
  33718. * This method must not get confused with createInstance()
  33719. * @param name is a string, the name given to the new mesh
  33720. * @param newParent can be any Node object (default `null`)
  33721. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33722. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33723. * @returns a new mesh
  33724. */
  33725. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33726. /**
  33727. * Releases resources associated with this mesh.
  33728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33730. */
  33731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33732. /** @hidden */
  33733. _disposeInstanceSpecificData(): void;
  33734. /** @hidden */
  33735. _disposeThinInstanceSpecificData(): void;
  33736. /**
  33737. * Modifies the mesh geometry according to a displacement map.
  33738. * 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.
  33739. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33740. * @param url is a string, the URL from the image file is to be downloaded.
  33741. * @param minHeight is the lower limit of the displacement.
  33742. * @param maxHeight is the upper limit of the displacement.
  33743. * @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.
  33744. * @param uvOffset is an optional vector2 used to offset UV.
  33745. * @param uvScale is an optional vector2 used to scale UV.
  33746. * @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.
  33747. * @returns the Mesh.
  33748. */
  33749. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33750. /**
  33751. * Modifies the mesh geometry according to a displacementMap buffer.
  33752. * 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.
  33753. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33754. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33755. * @param heightMapWidth is the width of the buffer image.
  33756. * @param heightMapHeight is the height of the buffer image.
  33757. * @param minHeight is the lower limit of the displacement.
  33758. * @param maxHeight is the upper limit of the displacement.
  33759. * @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.
  33760. * @param uvOffset is an optional vector2 used to offset UV.
  33761. * @param uvScale is an optional vector2 used to scale UV.
  33762. * @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.
  33763. * @returns the Mesh.
  33764. */
  33765. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33766. /**
  33767. * Modify the mesh to get a flat shading rendering.
  33768. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33769. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33770. * @returns current mesh
  33771. */
  33772. convertToFlatShadedMesh(): Mesh;
  33773. /**
  33774. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33775. * In other words, more vertices, no more indices and a single bigger VBO.
  33776. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33777. * @returns current mesh
  33778. */
  33779. convertToUnIndexedMesh(): Mesh;
  33780. /**
  33781. * Inverses facet orientations.
  33782. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33783. * @param flipNormals will also inverts the normals
  33784. * @returns current mesh
  33785. */
  33786. flipFaces(flipNormals?: boolean): Mesh;
  33787. /**
  33788. * Increase the number of facets and hence vertices in a mesh
  33789. * Vertex normals are interpolated from existing vertex normals
  33790. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33791. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33792. */
  33793. increaseVertices(numberPerEdge: number): void;
  33794. /**
  33795. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33796. * This will undo any application of covertToFlatShadedMesh
  33797. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33798. */
  33799. forceSharedVertices(): void;
  33800. /** @hidden */
  33801. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33802. /** @hidden */
  33803. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33804. /**
  33805. * Creates a new InstancedMesh object from the mesh model.
  33806. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33807. * @param name defines the name of the new instance
  33808. * @returns a new InstancedMesh
  33809. */
  33810. createInstance(name: string): InstancedMesh;
  33811. /**
  33812. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33813. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33814. * @returns the current mesh
  33815. */
  33816. synchronizeInstances(): Mesh;
  33817. /**
  33818. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33819. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33820. * This should be used together with the simplification to avoid disappearing triangles.
  33821. * @param successCallback an optional success callback to be called after the optimization finished.
  33822. * @returns the current mesh
  33823. */
  33824. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33825. /**
  33826. * Serialize current mesh
  33827. * @param serializationObject defines the object which will receive the serialization data
  33828. */
  33829. serialize(serializationObject: any): void;
  33830. /** @hidden */
  33831. _syncGeometryWithMorphTargetManager(): void;
  33832. /** @hidden */
  33833. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33834. /**
  33835. * Returns a new Mesh object parsed from the source provided.
  33836. * @param parsedMesh is the source
  33837. * @param scene defines the hosting scene
  33838. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33839. * @returns a new Mesh
  33840. */
  33841. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33842. /**
  33843. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33844. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33845. * @param name defines the name of the mesh to create
  33846. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33847. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33848. * @param closePath creates a seam between the first and the last points of each path of the path array
  33849. * @param offset is taken in account only if the `pathArray` is containing a single path
  33850. * @param scene defines the hosting scene
  33851. * @param updatable defines if the mesh must be flagged as updatable
  33852. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33853. * @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)
  33854. * @returns a new Mesh
  33855. */
  33856. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33857. /**
  33858. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33859. * @param name defines the name of the mesh to create
  33860. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33861. * @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
  33862. * @param scene defines the hosting scene
  33863. * @param updatable defines if the mesh must be flagged as updatable
  33864. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33865. * @returns a new Mesh
  33866. */
  33867. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33868. /**
  33869. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33870. * @param name defines the name of the mesh to create
  33871. * @param size sets the size (float) of each box side (default 1)
  33872. * @param scene defines the hosting scene
  33873. * @param updatable defines if the mesh must be flagged as updatable
  33874. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33875. * @returns a new Mesh
  33876. */
  33877. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33878. /**
  33879. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33880. * @param name defines the name of the mesh to create
  33881. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33882. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33883. * @param scene defines the hosting scene
  33884. * @param updatable defines if the mesh must be flagged as updatable
  33885. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33886. * @returns a new Mesh
  33887. */
  33888. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33889. /**
  33890. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33891. * @param name defines the name of the mesh to create
  33892. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33893. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33894. * @param scene defines the hosting scene
  33895. * @returns a new Mesh
  33896. */
  33897. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33898. /**
  33899. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33900. * @param name defines the name of the mesh to create
  33901. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33902. * @param diameterTop set the top cap diameter (floats, default 1)
  33903. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33904. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33905. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33906. * @param scene defines the hosting scene
  33907. * @param updatable defines if the mesh must be flagged as updatable
  33908. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33909. * @returns a new Mesh
  33910. */
  33911. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33912. /**
  33913. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33914. * @param name defines the name of the mesh to create
  33915. * @param diameter sets the diameter size (float) of the torus (default 1)
  33916. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33917. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33918. * @param scene defines the hosting scene
  33919. * @param updatable defines if the mesh must be flagged as updatable
  33920. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33921. * @returns a new Mesh
  33922. */
  33923. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33924. /**
  33925. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33926. * @param name defines the name of the mesh to create
  33927. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33928. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33929. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33930. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33931. * @param p the number of windings on X axis (positive integers, default 2)
  33932. * @param q the number of windings on Y axis (positive integers, default 3)
  33933. * @param scene defines the hosting scene
  33934. * @param updatable defines if the mesh must be flagged as updatable
  33935. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33936. * @returns a new Mesh
  33937. */
  33938. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33939. /**
  33940. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33941. * @param name defines the name of the mesh to create
  33942. * @param points is an array successive Vector3
  33943. * @param scene defines the hosting scene
  33944. * @param updatable defines if the mesh must be flagged as updatable
  33945. * @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).
  33946. * @returns a new Mesh
  33947. */
  33948. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33949. /**
  33950. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33951. * @param name defines the name of the mesh to create
  33952. * @param points is an array successive Vector3
  33953. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33954. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33955. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33956. * @param scene defines the hosting scene
  33957. * @param updatable defines if the mesh must be flagged as updatable
  33958. * @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)
  33959. * @returns a new Mesh
  33960. */
  33961. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33962. /**
  33963. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33964. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33965. * 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.
  33966. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33967. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33968. * Remember you can only change the shape positions, not their number when updating a polygon.
  33969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33970. * @param name defines the name of the mesh to create
  33971. * @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
  33972. * @param scene defines the hosting scene
  33973. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33974. * @param updatable defines if the mesh must be flagged as updatable
  33975. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33976. * @param earcutInjection can be used to inject your own earcut reference
  33977. * @returns a new Mesh
  33978. */
  33979. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33980. /**
  33981. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33983. * @param name defines the name of the mesh to create
  33984. * @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
  33985. * @param depth defines the height of extrusion
  33986. * @param scene defines the hosting scene
  33987. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33988. * @param updatable defines if the mesh must be flagged as updatable
  33989. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33990. * @param earcutInjection can be used to inject your own earcut reference
  33991. * @returns a new Mesh
  33992. */
  33993. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33994. /**
  33995. * Creates an extruded shape mesh.
  33996. * 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
  33997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33999. * @param name defines the name of the mesh to create
  34000. * @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
  34001. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34002. * @param scale is the value to scale the shape
  34003. * @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
  34004. * @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
  34005. * @param scene defines the hosting scene
  34006. * @param updatable defines if the mesh must be flagged as updatable
  34007. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34008. * @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)
  34009. * @returns a new Mesh
  34010. */
  34011. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34012. /**
  34013. * Creates an custom extruded shape mesh.
  34014. * The custom extrusion is a parametric shape.
  34015. * It has no predefined shape. Its final shape will depend on the input parameters.
  34016. * Please consider using the same method from the MeshBuilder class instead
  34017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34018. * @param name defines the name of the mesh to create
  34019. * @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
  34020. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34021. * @param scaleFunction is a custom Javascript function called on each path point
  34022. * @param rotationFunction is a custom Javascript function called on each path point
  34023. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34024. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34025. * @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
  34026. * @param scene defines the hosting scene
  34027. * @param updatable defines if the mesh must be flagged as updatable
  34028. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34029. * @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)
  34030. * @returns a new Mesh
  34031. */
  34032. 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;
  34033. /**
  34034. * Creates lathe mesh.
  34035. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34036. * Please consider using the same method from the MeshBuilder class instead
  34037. * @param name defines the name of the mesh to create
  34038. * @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
  34039. * @param radius is the radius value of the lathe
  34040. * @param tessellation is the side number of the lathe.
  34041. * @param scene defines the hosting scene
  34042. * @param updatable defines if the mesh must be flagged as updatable
  34043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34044. * @returns a new Mesh
  34045. */
  34046. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34047. /**
  34048. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34049. * @param name defines the name of the mesh to create
  34050. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34051. * @param scene defines the hosting scene
  34052. * @param updatable defines if the mesh must be flagged as updatable
  34053. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34054. * @returns a new Mesh
  34055. */
  34056. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34057. /**
  34058. * Creates a ground mesh.
  34059. * Please consider using the same method from the MeshBuilder class instead
  34060. * @param name defines the name of the mesh to create
  34061. * @param width set the width of the ground
  34062. * @param height set the height of the ground
  34063. * @param subdivisions sets the number of subdivisions per side
  34064. * @param scene defines the hosting scene
  34065. * @param updatable defines if the mesh must be flagged as updatable
  34066. * @returns a new Mesh
  34067. */
  34068. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34069. /**
  34070. * Creates a tiled ground mesh.
  34071. * Please consider using the same method from the MeshBuilder class instead
  34072. * @param name defines the name of the mesh to create
  34073. * @param xmin set the ground minimum X coordinate
  34074. * @param zmin set the ground minimum Y coordinate
  34075. * @param xmax set the ground maximum X coordinate
  34076. * @param zmax set the ground maximum Z coordinate
  34077. * @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
  34078. * @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
  34079. * @param scene defines the hosting scene
  34080. * @param updatable defines if the mesh must be flagged as updatable
  34081. * @returns a new Mesh
  34082. */
  34083. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34084. w: number;
  34085. h: number;
  34086. }, precision: {
  34087. w: number;
  34088. h: number;
  34089. }, scene: Scene, updatable?: boolean): Mesh;
  34090. /**
  34091. * Creates a ground mesh from a height map.
  34092. * Please consider using the same method from the MeshBuilder class instead
  34093. * @see https://doc.babylonjs.com/babylon101/height_map
  34094. * @param name defines the name of the mesh to create
  34095. * @param url sets the URL of the height map image resource
  34096. * @param width set the ground width size
  34097. * @param height set the ground height size
  34098. * @param subdivisions sets the number of subdivision per side
  34099. * @param minHeight is the minimum altitude on the ground
  34100. * @param maxHeight is the maximum altitude on the ground
  34101. * @param scene defines the hosting scene
  34102. * @param updatable defines if the mesh must be flagged as updatable
  34103. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34104. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34105. * @returns a new Mesh
  34106. */
  34107. 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;
  34108. /**
  34109. * Creates a tube mesh.
  34110. * The tube is a parametric shape.
  34111. * It has no predefined shape. Its final shape will depend on the input parameters.
  34112. * Please consider using the same method from the MeshBuilder class instead
  34113. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34114. * @param name defines the name of the mesh to create
  34115. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34116. * @param radius sets the tube radius size
  34117. * @param tessellation is the number of sides on the tubular surface
  34118. * @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
  34119. * @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
  34120. * @param scene defines the hosting scene
  34121. * @param updatable defines if the mesh must be flagged as updatable
  34122. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34123. * @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)
  34124. * @returns a new Mesh
  34125. */
  34126. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34127. (i: number, distance: number): number;
  34128. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34129. /**
  34130. * Creates a polyhedron mesh.
  34131. * Please consider using the same method from the MeshBuilder class instead.
  34132. * * 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
  34133. * * The parameter `size` (positive float, default 1) sets the polygon size
  34134. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34135. * * 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`
  34136. * * 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
  34137. * * 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)`)
  34138. * * 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
  34139. * * 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
  34140. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34141. * * 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
  34142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34143. * @param name defines the name of the mesh to create
  34144. * @param options defines the options used to create the mesh
  34145. * @param scene defines the hosting scene
  34146. * @returns a new Mesh
  34147. */
  34148. static CreatePolyhedron(name: string, options: {
  34149. type?: number;
  34150. size?: number;
  34151. sizeX?: number;
  34152. sizeY?: number;
  34153. sizeZ?: number;
  34154. custom?: any;
  34155. faceUV?: Vector4[];
  34156. faceColors?: Color4[];
  34157. updatable?: boolean;
  34158. sideOrientation?: number;
  34159. }, scene: Scene): Mesh;
  34160. /**
  34161. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34162. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34163. * * 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`)
  34164. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34165. * * 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
  34166. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34167. * * 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
  34168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34169. * @param name defines the name of the mesh
  34170. * @param options defines the options used to create the mesh
  34171. * @param scene defines the hosting scene
  34172. * @returns a new Mesh
  34173. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34174. */
  34175. static CreateIcoSphere(name: string, options: {
  34176. radius?: number;
  34177. flat?: boolean;
  34178. subdivisions?: number;
  34179. sideOrientation?: number;
  34180. updatable?: boolean;
  34181. }, scene: Scene): Mesh;
  34182. /**
  34183. * Creates a decal mesh.
  34184. * Please consider using the same method from the MeshBuilder class instead.
  34185. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34186. * @param name defines the name of the mesh
  34187. * @param sourceMesh defines the mesh receiving the decal
  34188. * @param position sets the position of the decal in world coordinates
  34189. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34190. * @param size sets the decal scaling
  34191. * @param angle sets the angle to rotate the decal
  34192. * @returns a new Mesh
  34193. */
  34194. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34195. /** Creates a Capsule Mesh
  34196. * @param name defines the name of the mesh.
  34197. * @param options the constructors options used to shape the mesh.
  34198. * @param scene defines the scene the mesh is scoped to.
  34199. * @returns the capsule mesh
  34200. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34201. */
  34202. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34203. /**
  34204. * Prepare internal position array for software CPU skinning
  34205. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34206. */
  34207. setPositionsForCPUSkinning(): Float32Array;
  34208. /**
  34209. * Prepare internal normal array for software CPU skinning
  34210. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34211. */
  34212. setNormalsForCPUSkinning(): Float32Array;
  34213. /**
  34214. * Updates the vertex buffer by applying transformation from the bones
  34215. * @param skeleton defines the skeleton to apply to current mesh
  34216. * @returns the current mesh
  34217. */
  34218. applySkeleton(skeleton: Skeleton): Mesh;
  34219. /**
  34220. * 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
  34221. * @param meshes defines the list of meshes to scan
  34222. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34223. */
  34224. static MinMax(meshes: AbstractMesh[]): {
  34225. min: Vector3;
  34226. max: Vector3;
  34227. };
  34228. /**
  34229. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34230. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34231. * @returns a vector3
  34232. */
  34233. static Center(meshesOrMinMaxVector: {
  34234. min: Vector3;
  34235. max: Vector3;
  34236. } | AbstractMesh[]): Vector3;
  34237. /**
  34238. * Merge the array of meshes into a single mesh for performance reasons.
  34239. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34240. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34241. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34242. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34243. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34244. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34245. * @returns a new mesh
  34246. */
  34247. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34248. /** @hidden */
  34249. addInstance(instance: InstancedMesh): void;
  34250. /** @hidden */
  34251. removeInstance(instance: InstancedMesh): void;
  34252. }
  34253. }
  34254. declare module BABYLON {
  34255. /**
  34256. * The options Interface for creating a Capsule Mesh
  34257. */
  34258. export interface ICreateCapsuleOptions {
  34259. /** The Orientation of the capsule. Default : Vector3.Up() */
  34260. orientation?: Vector3;
  34261. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34262. subdivisions: number;
  34263. /** Number of cylindrical segments on the capsule. */
  34264. tessellation: number;
  34265. /** Height or Length of the capsule. */
  34266. height: number;
  34267. /** Radius of the capsule. */
  34268. radius: number;
  34269. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34270. capSubdivisions: number;
  34271. /** Overwrite for the top radius. */
  34272. radiusTop?: number;
  34273. /** Overwrite for the bottom radius. */
  34274. radiusBottom?: number;
  34275. /** Overwrite for the top capSubdivisions. */
  34276. topCapSubdivisions?: number;
  34277. /** Overwrite for the bottom capSubdivisions. */
  34278. bottomCapSubdivisions?: number;
  34279. }
  34280. /**
  34281. * Class containing static functions to help procedurally build meshes
  34282. */
  34283. export class CapsuleBuilder {
  34284. /**
  34285. * Creates a capsule or a pill mesh
  34286. * @param name defines the name of the mesh
  34287. * @param options The constructors options.
  34288. * @param scene The scene the mesh is scoped to.
  34289. * @returns Capsule Mesh
  34290. */
  34291. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34292. }
  34293. }
  34294. declare module BABYLON {
  34295. /**
  34296. * Define an interface for all classes that will get and set the data on vertices
  34297. */
  34298. export interface IGetSetVerticesData {
  34299. /**
  34300. * Gets a boolean indicating if specific vertex data is present
  34301. * @param kind defines the vertex data kind to use
  34302. * @returns true is data kind is present
  34303. */
  34304. isVerticesDataPresent(kind: string): boolean;
  34305. /**
  34306. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34307. * @param kind defines the data kind (Position, normal, etc...)
  34308. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34309. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34310. * @returns a float array containing vertex data
  34311. */
  34312. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34313. /**
  34314. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34315. * @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.
  34316. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34317. * @returns the indices array or an empty array if the mesh has no geometry
  34318. */
  34319. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34320. /**
  34321. * Set specific vertex data
  34322. * @param kind defines the data kind (Position, normal, etc...)
  34323. * @param data defines the vertex data to use
  34324. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34325. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34326. */
  34327. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34328. /**
  34329. * Update a specific associated vertex buffer
  34330. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34331. * - VertexBuffer.PositionKind
  34332. * - VertexBuffer.UVKind
  34333. * - VertexBuffer.UV2Kind
  34334. * - VertexBuffer.UV3Kind
  34335. * - VertexBuffer.UV4Kind
  34336. * - VertexBuffer.UV5Kind
  34337. * - VertexBuffer.UV6Kind
  34338. * - VertexBuffer.ColorKind
  34339. * - VertexBuffer.MatricesIndicesKind
  34340. * - VertexBuffer.MatricesIndicesExtraKind
  34341. * - VertexBuffer.MatricesWeightsKind
  34342. * - VertexBuffer.MatricesWeightsExtraKind
  34343. * @param data defines the data source
  34344. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34345. * @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)
  34346. */
  34347. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34348. /**
  34349. * Creates a new index buffer
  34350. * @param indices defines the indices to store in the index buffer
  34351. * @param totalVertices defines the total number of vertices (could be null)
  34352. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34353. */
  34354. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34355. }
  34356. /**
  34357. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34358. */
  34359. export class VertexData {
  34360. /**
  34361. * Mesh side orientation : usually the external or front surface
  34362. */
  34363. static readonly FRONTSIDE: number;
  34364. /**
  34365. * Mesh side orientation : usually the internal or back surface
  34366. */
  34367. static readonly BACKSIDE: number;
  34368. /**
  34369. * Mesh side orientation : both internal and external or front and back surfaces
  34370. */
  34371. static readonly DOUBLESIDE: number;
  34372. /**
  34373. * Mesh side orientation : by default, `FRONTSIDE`
  34374. */
  34375. static readonly DEFAULTSIDE: number;
  34376. /**
  34377. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34378. */
  34379. positions: Nullable<FloatArray>;
  34380. /**
  34381. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34382. */
  34383. normals: Nullable<FloatArray>;
  34384. /**
  34385. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34386. */
  34387. tangents: Nullable<FloatArray>;
  34388. /**
  34389. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34390. */
  34391. uvs: Nullable<FloatArray>;
  34392. /**
  34393. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34394. */
  34395. uvs2: Nullable<FloatArray>;
  34396. /**
  34397. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34398. */
  34399. uvs3: Nullable<FloatArray>;
  34400. /**
  34401. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34402. */
  34403. uvs4: Nullable<FloatArray>;
  34404. /**
  34405. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34406. */
  34407. uvs5: Nullable<FloatArray>;
  34408. /**
  34409. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34410. */
  34411. uvs6: Nullable<FloatArray>;
  34412. /**
  34413. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34414. */
  34415. colors: Nullable<FloatArray>;
  34416. /**
  34417. * 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).
  34418. */
  34419. matricesIndices: Nullable<FloatArray>;
  34420. /**
  34421. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34422. */
  34423. matricesWeights: Nullable<FloatArray>;
  34424. /**
  34425. * An array extending the number of possible indices
  34426. */
  34427. matricesIndicesExtra: Nullable<FloatArray>;
  34428. /**
  34429. * An array extending the number of possible weights when the number of indices is extended
  34430. */
  34431. matricesWeightsExtra: Nullable<FloatArray>;
  34432. /**
  34433. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34434. */
  34435. indices: Nullable<IndicesArray>;
  34436. /**
  34437. * Uses the passed data array to set the set the values for the specified kind of data
  34438. * @param data a linear array of floating numbers
  34439. * @param kind the type of data that is being set, eg positions, colors etc
  34440. */
  34441. set(data: FloatArray, kind: string): void;
  34442. /**
  34443. * Associates the vertexData to the passed Mesh.
  34444. * Sets it as updatable or not (default `false`)
  34445. * @param mesh the mesh the vertexData is applied to
  34446. * @param updatable when used and having the value true allows new data to update the vertexData
  34447. * @returns the VertexData
  34448. */
  34449. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34450. /**
  34451. * Associates the vertexData to the passed Geometry.
  34452. * Sets it as updatable or not (default `false`)
  34453. * @param geometry the geometry the vertexData is applied to
  34454. * @param updatable when used and having the value true allows new data to update the vertexData
  34455. * @returns VertexData
  34456. */
  34457. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34458. /**
  34459. * Updates the associated mesh
  34460. * @param mesh the mesh to be updated
  34461. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34462. * @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
  34463. * @returns VertexData
  34464. */
  34465. updateMesh(mesh: Mesh): VertexData;
  34466. /**
  34467. * Updates the associated geometry
  34468. * @param geometry the geometry to be updated
  34469. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34470. * @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
  34471. * @returns VertexData.
  34472. */
  34473. updateGeometry(geometry: Geometry): VertexData;
  34474. private _applyTo;
  34475. private _update;
  34476. /**
  34477. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34478. * @param matrix the transforming matrix
  34479. * @returns the VertexData
  34480. */
  34481. transform(matrix: Matrix): VertexData;
  34482. /**
  34483. * Merges the passed VertexData into the current one
  34484. * @param other the VertexData to be merged into the current one
  34485. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34486. * @returns the modified VertexData
  34487. */
  34488. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34489. private _mergeElement;
  34490. private _validate;
  34491. /**
  34492. * Serializes the VertexData
  34493. * @returns a serialized object
  34494. */
  34495. serialize(): any;
  34496. /**
  34497. * Extracts the vertexData from a mesh
  34498. * @param mesh the mesh from which to extract the VertexData
  34499. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34500. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34501. * @returns the object VertexData associated to the passed mesh
  34502. */
  34503. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34504. /**
  34505. * Extracts the vertexData from the geometry
  34506. * @param geometry the geometry from which to extract the VertexData
  34507. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34508. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34509. * @returns the object VertexData associated to the passed mesh
  34510. */
  34511. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34512. private static _ExtractFrom;
  34513. /**
  34514. * Creates the VertexData for a Ribbon
  34515. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34516. * * pathArray array of paths, each of which an array of successive Vector3
  34517. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34518. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34519. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34524. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34525. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34526. * @returns the VertexData of the ribbon
  34527. */
  34528. static CreateRibbon(options: {
  34529. pathArray: Vector3[][];
  34530. closeArray?: boolean;
  34531. closePath?: boolean;
  34532. offset?: number;
  34533. sideOrientation?: number;
  34534. frontUVs?: Vector4;
  34535. backUVs?: Vector4;
  34536. invertUV?: boolean;
  34537. uvs?: Vector2[];
  34538. colors?: Color4[];
  34539. }): VertexData;
  34540. /**
  34541. * Creates the VertexData for a box
  34542. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34543. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34544. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34545. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34546. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34547. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34548. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  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 box
  34553. */
  34554. static CreateBox(options: {
  34555. size?: number;
  34556. width?: number;
  34557. height?: number;
  34558. depth?: number;
  34559. faceUV?: Vector4[];
  34560. faceColors?: Color4[];
  34561. sideOrientation?: number;
  34562. frontUVs?: Vector4;
  34563. backUVs?: Vector4;
  34564. }): VertexData;
  34565. /**
  34566. * Creates the VertexData for a tiled box
  34567. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34568. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34569. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34570. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34572. * @returns the VertexData of the box
  34573. */
  34574. static CreateTiledBox(options: {
  34575. pattern?: number;
  34576. width?: number;
  34577. height?: number;
  34578. depth?: number;
  34579. tileSize?: number;
  34580. tileWidth?: number;
  34581. tileHeight?: number;
  34582. alignHorizontal?: number;
  34583. alignVertical?: number;
  34584. faceUV?: Vector4[];
  34585. faceColors?: Color4[];
  34586. sideOrientation?: number;
  34587. }): VertexData;
  34588. /**
  34589. * Creates the VertexData for a tiled plane
  34590. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34591. * * pattern a limited pattern arrangement depending on the number
  34592. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34593. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34594. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34596. * * 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)
  34597. * * 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)
  34598. * @returns the VertexData of the tiled plane
  34599. */
  34600. static CreateTiledPlane(options: {
  34601. pattern?: number;
  34602. tileSize?: number;
  34603. tileWidth?: number;
  34604. tileHeight?: number;
  34605. size?: number;
  34606. width?: number;
  34607. height?: number;
  34608. alignHorizontal?: number;
  34609. alignVertical?: number;
  34610. sideOrientation?: number;
  34611. frontUVs?: Vector4;
  34612. backUVs?: Vector4;
  34613. }): VertexData;
  34614. /**
  34615. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34616. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34617. * * segments sets the number of horizontal strips optional, default 32
  34618. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34619. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34620. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34621. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34622. * * 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
  34623. * * 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
  34624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34625. * * 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)
  34626. * * 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)
  34627. * @returns the VertexData of the ellipsoid
  34628. */
  34629. static CreateSphere(options: {
  34630. segments?: number;
  34631. diameter?: number;
  34632. diameterX?: number;
  34633. diameterY?: number;
  34634. diameterZ?: number;
  34635. arc?: number;
  34636. slice?: number;
  34637. sideOrientation?: number;
  34638. frontUVs?: Vector4;
  34639. backUVs?: Vector4;
  34640. }): VertexData;
  34641. /**
  34642. * Creates the VertexData for a cylinder, cone or prism
  34643. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34644. * * height sets the height (y direction) of the cylinder, optional, default 2
  34645. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34646. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34647. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34648. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34649. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34650. * * 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
  34651. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34652. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34653. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34654. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34656. * * 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)
  34657. * * 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)
  34658. * @returns the VertexData of the cylinder, cone or prism
  34659. */
  34660. static CreateCylinder(options: {
  34661. height?: number;
  34662. diameterTop?: number;
  34663. diameterBottom?: number;
  34664. diameter?: number;
  34665. tessellation?: number;
  34666. subdivisions?: number;
  34667. arc?: number;
  34668. faceColors?: Color4[];
  34669. faceUV?: Vector4[];
  34670. hasRings?: boolean;
  34671. enclose?: boolean;
  34672. sideOrientation?: number;
  34673. frontUVs?: Vector4;
  34674. backUVs?: Vector4;
  34675. }): VertexData;
  34676. /**
  34677. * Creates the VertexData for a torus
  34678. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34679. * * diameter the diameter of the torus, optional default 1
  34680. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34681. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34683. * * 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)
  34684. * * 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)
  34685. * @returns the VertexData of the torus
  34686. */
  34687. static CreateTorus(options: {
  34688. diameter?: number;
  34689. thickness?: number;
  34690. tessellation?: number;
  34691. sideOrientation?: number;
  34692. frontUVs?: Vector4;
  34693. backUVs?: Vector4;
  34694. }): VertexData;
  34695. /**
  34696. * Creates the VertexData of the LineSystem
  34697. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34698. * - lines an array of lines, each line being an array of successive Vector3
  34699. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34700. * @returns the VertexData of the LineSystem
  34701. */
  34702. static CreateLineSystem(options: {
  34703. lines: Vector3[][];
  34704. colors?: Nullable<Color4[][]>;
  34705. }): VertexData;
  34706. /**
  34707. * Create the VertexData for a DashedLines
  34708. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34709. * - points an array successive Vector3
  34710. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34711. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34712. * - dashNb the intended total number of dashes, optional, default 200
  34713. * @returns the VertexData for the DashedLines
  34714. */
  34715. static CreateDashedLines(options: {
  34716. points: Vector3[];
  34717. dashSize?: number;
  34718. gapSize?: number;
  34719. dashNb?: number;
  34720. }): VertexData;
  34721. /**
  34722. * Creates the VertexData for a Ground
  34723. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34724. * - width the width (x direction) of the ground, optional, default 1
  34725. * - height the height (z direction) of the ground, optional, default 1
  34726. * - subdivisions the number of subdivisions per side, optional, default 1
  34727. * @returns the VertexData of the Ground
  34728. */
  34729. static CreateGround(options: {
  34730. width?: number;
  34731. height?: number;
  34732. subdivisions?: number;
  34733. subdivisionsX?: number;
  34734. subdivisionsY?: number;
  34735. }): VertexData;
  34736. /**
  34737. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34738. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34739. * * xmin the ground minimum X coordinate, optional, default -1
  34740. * * zmin the ground minimum Z coordinate, optional, default -1
  34741. * * xmax the ground maximum X coordinate, optional, default 1
  34742. * * zmax the ground maximum Z coordinate, optional, default 1
  34743. * * 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}
  34744. * * 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}
  34745. * @returns the VertexData of the TiledGround
  34746. */
  34747. static CreateTiledGround(options: {
  34748. xmin: number;
  34749. zmin: number;
  34750. xmax: number;
  34751. zmax: number;
  34752. subdivisions?: {
  34753. w: number;
  34754. h: number;
  34755. };
  34756. precision?: {
  34757. w: number;
  34758. h: number;
  34759. };
  34760. }): VertexData;
  34761. /**
  34762. * Creates the VertexData of the Ground designed from a heightmap
  34763. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34764. * * width the width (x direction) of the ground
  34765. * * height the height (z direction) of the ground
  34766. * * subdivisions the number of subdivisions per side
  34767. * * minHeight the minimum altitude on the ground, optional, default 0
  34768. * * maxHeight the maximum altitude on the ground, optional default 1
  34769. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34770. * * buffer the array holding the image color data
  34771. * * bufferWidth the width of image
  34772. * * bufferHeight the height of image
  34773. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34774. * @returns the VertexData of the Ground designed from a heightmap
  34775. */
  34776. static CreateGroundFromHeightMap(options: {
  34777. width: number;
  34778. height: number;
  34779. subdivisions: number;
  34780. minHeight: number;
  34781. maxHeight: number;
  34782. colorFilter: Color3;
  34783. buffer: Uint8Array;
  34784. bufferWidth: number;
  34785. bufferHeight: number;
  34786. alphaFilter: number;
  34787. }): VertexData;
  34788. /**
  34789. * Creates the VertexData for a Plane
  34790. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34791. * * size sets the width and height of the plane to the value of size, optional default 1
  34792. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34793. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34795. * * 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)
  34796. * * 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)
  34797. * @returns the VertexData of the box
  34798. */
  34799. static CreatePlane(options: {
  34800. size?: number;
  34801. width?: number;
  34802. height?: number;
  34803. sideOrientation?: number;
  34804. frontUVs?: Vector4;
  34805. backUVs?: Vector4;
  34806. }): VertexData;
  34807. /**
  34808. * Creates the VertexData of the Disc or regular Polygon
  34809. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34810. * * radius the radius of the disc, optional default 0.5
  34811. * * tessellation the number of polygon sides, optional, default 64
  34812. * * 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
  34813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34814. * * 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)
  34815. * * 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)
  34816. * @returns the VertexData of the box
  34817. */
  34818. static CreateDisc(options: {
  34819. radius?: number;
  34820. tessellation?: number;
  34821. arc?: number;
  34822. sideOrientation?: number;
  34823. frontUVs?: Vector4;
  34824. backUVs?: Vector4;
  34825. }): VertexData;
  34826. /**
  34827. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34828. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34829. * @param polygon a mesh built from polygonTriangulation.build()
  34830. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34831. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34832. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34833. * @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)
  34834. * @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)
  34835. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34836. * @returns the VertexData of the Polygon
  34837. */
  34838. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34839. /**
  34840. * Creates the VertexData of the IcoSphere
  34841. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34842. * * radius the radius of the IcoSphere, optional default 1
  34843. * * radiusX allows stretching in the x direction, optional, default radius
  34844. * * radiusY allows stretching in the y direction, optional, default radius
  34845. * * radiusZ allows stretching in the z direction, optional, default radius
  34846. * * flat when true creates a flat shaded mesh, optional, default true
  34847. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34849. * * 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)
  34850. * * 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)
  34851. * @returns the VertexData of the IcoSphere
  34852. */
  34853. static CreateIcoSphere(options: {
  34854. radius?: number;
  34855. radiusX?: number;
  34856. radiusY?: number;
  34857. radiusZ?: number;
  34858. flat?: boolean;
  34859. subdivisions?: number;
  34860. sideOrientation?: number;
  34861. frontUVs?: Vector4;
  34862. backUVs?: Vector4;
  34863. }): VertexData;
  34864. /**
  34865. * Creates the VertexData for a Polyhedron
  34866. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34867. * * type provided types are:
  34868. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34869. * * 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)
  34870. * * size the size of the IcoSphere, optional default 1
  34871. * * sizeX allows stretching in the x direction, optional, default size
  34872. * * sizeY allows stretching in the y direction, optional, default size
  34873. * * sizeZ allows stretching in the z direction, optional, default size
  34874. * * 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
  34875. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34876. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34877. * * flat when true creates a flat shaded mesh, optional, default true
  34878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34880. * * 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)
  34881. * * 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)
  34882. * @returns the VertexData of the Polyhedron
  34883. */
  34884. static CreatePolyhedron(options: {
  34885. type?: number;
  34886. size?: number;
  34887. sizeX?: number;
  34888. sizeY?: number;
  34889. sizeZ?: number;
  34890. custom?: any;
  34891. faceUV?: Vector4[];
  34892. faceColors?: Color4[];
  34893. flat?: boolean;
  34894. sideOrientation?: number;
  34895. frontUVs?: Vector4;
  34896. backUVs?: Vector4;
  34897. }): VertexData;
  34898. /**
  34899. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34900. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34901. * @returns the VertexData of the Capsule
  34902. */
  34903. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34904. /**
  34905. * Creates the VertexData for a TorusKnot
  34906. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34907. * * radius the radius of the torus knot, optional, default 2
  34908. * * tube the thickness of the tube, optional, default 0.5
  34909. * * radialSegments the number of sides on each tube segments, optional, default 32
  34910. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34911. * * p the number of windings around the z axis, optional, default 2
  34912. * * q the number of windings around the x axis, optional, default 3
  34913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34914. * * 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)
  34915. * * 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)
  34916. * @returns the VertexData of the Torus Knot
  34917. */
  34918. static CreateTorusKnot(options: {
  34919. radius?: number;
  34920. tube?: number;
  34921. radialSegments?: number;
  34922. tubularSegments?: number;
  34923. p?: number;
  34924. q?: number;
  34925. sideOrientation?: number;
  34926. frontUVs?: Vector4;
  34927. backUVs?: Vector4;
  34928. }): VertexData;
  34929. /**
  34930. * Compute normals for given positions and indices
  34931. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34932. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34933. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34934. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34935. * * facetNormals : optional array of facet normals (vector3)
  34936. * * facetPositions : optional array of facet positions (vector3)
  34937. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34938. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34939. * * bInfo : optional bounding info, required for facetPartitioning computation
  34940. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34941. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34942. * * useRightHandedSystem: optional boolean to for right handed system computation
  34943. * * depthSort : optional boolean to enable the facet depth sort computation
  34944. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34945. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34946. */
  34947. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34948. facetNormals?: any;
  34949. facetPositions?: any;
  34950. facetPartitioning?: any;
  34951. ratio?: number;
  34952. bInfo?: any;
  34953. bbSize?: Vector3;
  34954. subDiv?: any;
  34955. useRightHandedSystem?: boolean;
  34956. depthSort?: boolean;
  34957. distanceTo?: Vector3;
  34958. depthSortedFacets?: any;
  34959. }): void;
  34960. /** @hidden */
  34961. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34962. /**
  34963. * Applies VertexData created from the imported parameters to the geometry
  34964. * @param parsedVertexData the parsed data from an imported file
  34965. * @param geometry the geometry to apply the VertexData to
  34966. */
  34967. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34968. }
  34969. }
  34970. declare module BABYLON {
  34971. /**
  34972. * Class containing static functions to help procedurally build meshes
  34973. */
  34974. export class DiscBuilder {
  34975. /**
  34976. * Creates a plane polygonal mesh. By default, this is a disc
  34977. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34978. * * 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
  34979. * * 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
  34980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34981. * * 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
  34982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34983. * @param name defines the name of the mesh
  34984. * @param options defines the options used to create the mesh
  34985. * @param scene defines the hosting scene
  34986. * @returns the plane polygonal mesh
  34987. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34988. */
  34989. static CreateDisc(name: string, options: {
  34990. radius?: number;
  34991. tessellation?: number;
  34992. arc?: number;
  34993. updatable?: boolean;
  34994. sideOrientation?: number;
  34995. frontUVs?: Vector4;
  34996. backUVs?: Vector4;
  34997. }, scene?: Nullable<Scene>): Mesh;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /**
  35002. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35003. *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.
  35004. * The SPS is also a particle system. It provides some methods to manage the particles.
  35005. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35006. *
  35007. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35008. */
  35009. export class SolidParticleSystem implements IDisposable {
  35010. /**
  35011. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35012. * Example : var p = SPS.particles[i];
  35013. */
  35014. particles: SolidParticle[];
  35015. /**
  35016. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35017. */
  35018. nbParticles: number;
  35019. /**
  35020. * If the particles must ever face the camera (default false). Useful for planar particles.
  35021. */
  35022. billboard: boolean;
  35023. /**
  35024. * Recompute normals when adding a shape
  35025. */
  35026. recomputeNormals: boolean;
  35027. /**
  35028. * This a counter ofr your own usage. It's not set by any SPS functions.
  35029. */
  35030. counter: number;
  35031. /**
  35032. * The SPS name. This name is also given to the underlying mesh.
  35033. */
  35034. name: string;
  35035. /**
  35036. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35037. */
  35038. mesh: Mesh;
  35039. /**
  35040. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35041. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35042. */
  35043. vars: any;
  35044. /**
  35045. * This array is populated when the SPS is set as 'pickable'.
  35046. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35047. * Each element of this array is an object `{idx: int, faceId: int}`.
  35048. * `idx` is the picked particle index in the `SPS.particles` array
  35049. * `faceId` is the picked face index counted within this particle.
  35050. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35051. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35052. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35053. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35054. */
  35055. pickedParticles: {
  35056. idx: number;
  35057. faceId: number;
  35058. }[];
  35059. /**
  35060. * This array is populated when the SPS is set as 'pickable'
  35061. * Each key of this array is a submesh index.
  35062. * Each element of this array is a second array defined like this :
  35063. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35064. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35065. * `idx` is the picked particle index in the `SPS.particles` array
  35066. * `faceId` is the picked face index counted within this particle.
  35067. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35068. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35069. */
  35070. pickedBySubMesh: {
  35071. idx: number;
  35072. faceId: number;
  35073. }[][];
  35074. /**
  35075. * This array is populated when `enableDepthSort` is set to true.
  35076. * Each element of this array is an instance of the class DepthSortedParticle.
  35077. */
  35078. depthSortedParticles: DepthSortedParticle[];
  35079. /**
  35080. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35081. * @hidden
  35082. */
  35083. _bSphereOnly: boolean;
  35084. /**
  35085. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35086. * @hidden
  35087. */
  35088. _bSphereRadiusFactor: number;
  35089. private _scene;
  35090. private _positions;
  35091. private _indices;
  35092. private _normals;
  35093. private _colors;
  35094. private _uvs;
  35095. private _indices32;
  35096. private _positions32;
  35097. private _normals32;
  35098. private _fixedNormal32;
  35099. private _colors32;
  35100. private _uvs32;
  35101. private _index;
  35102. private _updatable;
  35103. private _pickable;
  35104. private _isVisibilityBoxLocked;
  35105. private _alwaysVisible;
  35106. private _depthSort;
  35107. private _expandable;
  35108. private _shapeCounter;
  35109. private _copy;
  35110. private _color;
  35111. private _computeParticleColor;
  35112. private _computeParticleTexture;
  35113. private _computeParticleRotation;
  35114. private _computeParticleVertex;
  35115. private _computeBoundingBox;
  35116. private _depthSortParticles;
  35117. private _camera;
  35118. private _mustUnrotateFixedNormals;
  35119. private _particlesIntersect;
  35120. private _needs32Bits;
  35121. private _isNotBuilt;
  35122. private _lastParticleId;
  35123. private _idxOfId;
  35124. private _multimaterialEnabled;
  35125. private _useModelMaterial;
  35126. private _indicesByMaterial;
  35127. private _materialIndexes;
  35128. private _depthSortFunction;
  35129. private _materialSortFunction;
  35130. private _materials;
  35131. private _multimaterial;
  35132. private _materialIndexesById;
  35133. private _defaultMaterial;
  35134. private _autoUpdateSubMeshes;
  35135. private _tmpVertex;
  35136. /**
  35137. * Creates a SPS (Solid Particle System) object.
  35138. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35139. * @param scene (Scene) is the scene in which the SPS is added.
  35140. * @param options defines the options of the sps e.g.
  35141. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35142. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35143. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35144. * * 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.
  35145. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35146. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35147. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35148. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35149. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35150. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35151. */
  35152. constructor(name: string, scene: Scene, options?: {
  35153. updatable?: boolean;
  35154. isPickable?: boolean;
  35155. enableDepthSort?: boolean;
  35156. particleIntersection?: boolean;
  35157. boundingSphereOnly?: boolean;
  35158. bSphereRadiusFactor?: number;
  35159. expandable?: boolean;
  35160. useModelMaterial?: boolean;
  35161. enableMultiMaterial?: boolean;
  35162. });
  35163. /**
  35164. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35165. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35166. * @returns the created mesh
  35167. */
  35168. buildMesh(): Mesh;
  35169. /**
  35170. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35171. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35172. * Thus the particles generated from `digest()` have their property `position` set yet.
  35173. * @param mesh ( Mesh ) is the mesh to be digested
  35174. * @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
  35175. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35176. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  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 current SPS
  35179. */
  35180. digest(mesh: Mesh, options?: {
  35181. facetNb?: number;
  35182. number?: number;
  35183. delta?: number;
  35184. storage?: [];
  35185. }): SolidParticleSystem;
  35186. /**
  35187. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35188. * @hidden
  35189. */
  35190. private _unrotateFixedNormals;
  35191. /**
  35192. * Resets the temporary working copy particle
  35193. * @hidden
  35194. */
  35195. private _resetCopy;
  35196. /**
  35197. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35198. * @param p the current index in the positions array to be updated
  35199. * @param ind the current index in the indices array
  35200. * @param shape a Vector3 array, the shape geometry
  35201. * @param positions the positions array to be updated
  35202. * @param meshInd the shape indices array
  35203. * @param indices the indices array to be updated
  35204. * @param meshUV the shape uv array
  35205. * @param uvs the uv array to be updated
  35206. * @param meshCol the shape color array
  35207. * @param colors the color array to be updated
  35208. * @param meshNor the shape normals array
  35209. * @param normals the normals array to be updated
  35210. * @param idx the particle index
  35211. * @param idxInShape the particle index in its shape
  35212. * @param options the addShape() method passed options
  35213. * @model the particle model
  35214. * @hidden
  35215. */
  35216. private _meshBuilder;
  35217. /**
  35218. * Returns a shape Vector3 array from positions float array
  35219. * @param positions float array
  35220. * @returns a vector3 array
  35221. * @hidden
  35222. */
  35223. private _posToShape;
  35224. /**
  35225. * Returns a shapeUV array from a float uvs (array deep copy)
  35226. * @param uvs as a float array
  35227. * @returns a shapeUV array
  35228. * @hidden
  35229. */
  35230. private _uvsToShapeUV;
  35231. /**
  35232. * Adds a new particle object in the particles array
  35233. * @param idx particle index in particles array
  35234. * @param id particle id
  35235. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35236. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35237. * @param model particle ModelShape object
  35238. * @param shapeId model shape identifier
  35239. * @param idxInShape index of the particle in the current model
  35240. * @param bInfo model bounding info object
  35241. * @param storage target storage array, if any
  35242. * @hidden
  35243. */
  35244. private _addParticle;
  35245. /**
  35246. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35247. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35248. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35249. * @param nb (positive integer) the number of particles to be created from this model
  35250. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35251. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35252. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35253. * @returns the number of shapes in the system
  35254. */
  35255. addShape(mesh: Mesh, nb: number, options?: {
  35256. positionFunction?: any;
  35257. vertexFunction?: any;
  35258. storage?: [];
  35259. }): number;
  35260. /**
  35261. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35262. * @hidden
  35263. */
  35264. private _rebuildParticle;
  35265. /**
  35266. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35267. * @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.
  35268. * @returns the SPS.
  35269. */
  35270. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35271. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35272. * Returns an array with the removed particles.
  35273. * 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.
  35274. * The SPS can't be empty so at least one particle needs to remain in place.
  35275. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35276. * @param start index of the first particle to remove
  35277. * @param end index of the last particle to remove (included)
  35278. * @returns an array populated with the removed particles
  35279. */
  35280. removeParticles(start: number, end: number): SolidParticle[];
  35281. /**
  35282. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35283. * @param solidParticleArray an array populated with Solid Particles objects
  35284. * @returns the SPS
  35285. */
  35286. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35287. /**
  35288. * Creates a new particle and modifies the SPS mesh geometry :
  35289. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35290. * - calls _addParticle() to populate the particle array
  35291. * factorized code from addShape() and insertParticlesFromArray()
  35292. * @param idx particle index in the particles array
  35293. * @param i particle index in its shape
  35294. * @param modelShape particle ModelShape object
  35295. * @param shape shape vertex array
  35296. * @param meshInd shape indices array
  35297. * @param meshUV shape uv array
  35298. * @param meshCol shape color array
  35299. * @param meshNor shape normals array
  35300. * @param bbInfo shape bounding info
  35301. * @param storage target particle storage
  35302. * @options addShape() passed options
  35303. * @hidden
  35304. */
  35305. private _insertNewParticle;
  35306. /**
  35307. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35308. * This method calls `updateParticle()` for each particle of the SPS.
  35309. * For an animated SPS, it is usually called within the render loop.
  35310. * 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.
  35311. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35312. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35313. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35314. * @returns the SPS.
  35315. */
  35316. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35317. /**
  35318. * Disposes the SPS.
  35319. */
  35320. dispose(): void;
  35321. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35322. * idx is the particle index in the SPS
  35323. * faceId is the picked face index counted within this particle.
  35324. * Returns null if the pickInfo can't identify a picked particle.
  35325. * @param pickingInfo (PickingInfo object)
  35326. * @returns {idx: number, faceId: number} or null
  35327. */
  35328. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35329. idx: number;
  35330. faceId: number;
  35331. }>;
  35332. /**
  35333. * Returns a SolidParticle object from its identifier : particle.id
  35334. * @param id (integer) the particle Id
  35335. * @returns the searched particle or null if not found in the SPS.
  35336. */
  35337. getParticleById(id: number): Nullable<SolidParticle>;
  35338. /**
  35339. * Returns a new array populated with the particles having the passed shapeId.
  35340. * @param shapeId (integer) the shape identifier
  35341. * @returns a new solid particle array
  35342. */
  35343. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35344. /**
  35345. * Populates the passed array "ref" with the particles having the passed shapeId.
  35346. * @param shapeId the shape identifier
  35347. * @returns the SPS
  35348. * @param ref
  35349. */
  35350. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35351. /**
  35352. * Computes the required SubMeshes according the materials assigned to the particles.
  35353. * @returns the solid particle system.
  35354. * Does nothing if called before the SPS mesh is built.
  35355. */
  35356. computeSubMeshes(): SolidParticleSystem;
  35357. /**
  35358. * Sorts the solid particles by material when MultiMaterial is enabled.
  35359. * Updates the indices32 array.
  35360. * Updates the indicesByMaterial array.
  35361. * Updates the mesh indices array.
  35362. * @returns the SPS
  35363. * @hidden
  35364. */
  35365. private _sortParticlesByMaterial;
  35366. /**
  35367. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35368. * @hidden
  35369. */
  35370. private _setMaterialIndexesById;
  35371. /**
  35372. * Returns an array with unique values of Materials from the passed array
  35373. * @param array the material array to be checked and filtered
  35374. * @hidden
  35375. */
  35376. private _filterUniqueMaterialId;
  35377. /**
  35378. * Sets a new Standard Material as _defaultMaterial if not already set.
  35379. * @hidden
  35380. */
  35381. private _setDefaultMaterial;
  35382. /**
  35383. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35384. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35385. * @returns the SPS.
  35386. */
  35387. refreshVisibleSize(): SolidParticleSystem;
  35388. /**
  35389. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35390. * @param size the size (float) of the visibility box
  35391. * note : this doesn't lock the SPS mesh bounding box.
  35392. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35393. */
  35394. setVisibilityBox(size: number): void;
  35395. /**
  35396. * Gets whether the SPS as always visible or not
  35397. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35398. */
  35399. get isAlwaysVisible(): boolean;
  35400. /**
  35401. * Sets the SPS as always visible or not
  35402. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35403. */
  35404. set isAlwaysVisible(val: boolean);
  35405. /**
  35406. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35407. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35408. */
  35409. set isVisibilityBoxLocked(val: boolean);
  35410. /**
  35411. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35412. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35413. */
  35414. get isVisibilityBoxLocked(): boolean;
  35415. /**
  35416. * Tells to `setParticles()` to compute the particle rotations or not.
  35417. * Default value : true. The SPS is faster when it's set to false.
  35418. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35419. */
  35420. set computeParticleRotation(val: boolean);
  35421. /**
  35422. * Tells to `setParticles()` to compute the particle colors or not.
  35423. * Default value : true. The SPS is faster when it's set to false.
  35424. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35425. */
  35426. set computeParticleColor(val: boolean);
  35427. set computeParticleTexture(val: boolean);
  35428. /**
  35429. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35430. * Default value : false. The SPS is faster when it's set to false.
  35431. * Note : the particle custom vertex positions aren't stored values.
  35432. */
  35433. set computeParticleVertex(val: boolean);
  35434. /**
  35435. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35436. */
  35437. set computeBoundingBox(val: boolean);
  35438. /**
  35439. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35440. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35441. * Default : `true`
  35442. */
  35443. set depthSortParticles(val: boolean);
  35444. /**
  35445. * Gets if `setParticles()` computes the particle rotations or not.
  35446. * Default value : true. The SPS is faster when it's set to false.
  35447. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35448. */
  35449. get computeParticleRotation(): boolean;
  35450. /**
  35451. * Gets if `setParticles()` computes the particle colors or not.
  35452. * Default value : true. The SPS is faster when it's set to false.
  35453. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35454. */
  35455. get computeParticleColor(): boolean;
  35456. /**
  35457. * Gets if `setParticles()` computes the particle textures or not.
  35458. * Default value : true. The SPS is faster when it's set to false.
  35459. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35460. */
  35461. get computeParticleTexture(): boolean;
  35462. /**
  35463. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35464. * Default value : false. The SPS is faster when it's set to false.
  35465. * Note : the particle custom vertex positions aren't stored values.
  35466. */
  35467. get computeParticleVertex(): boolean;
  35468. /**
  35469. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35470. */
  35471. get computeBoundingBox(): boolean;
  35472. /**
  35473. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35474. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35475. * Default : `true`
  35476. */
  35477. get depthSortParticles(): boolean;
  35478. /**
  35479. * Gets if the SPS is created as expandable at construction time.
  35480. * Default : `false`
  35481. */
  35482. get expandable(): boolean;
  35483. /**
  35484. * Gets if the SPS supports the Multi Materials
  35485. */
  35486. get multimaterialEnabled(): boolean;
  35487. /**
  35488. * Gets if the SPS uses the model materials for its own multimaterial.
  35489. */
  35490. get useModelMaterial(): boolean;
  35491. /**
  35492. * The SPS used material array.
  35493. */
  35494. get materials(): Material[];
  35495. /**
  35496. * Sets the SPS MultiMaterial from the passed materials.
  35497. * Note : the passed array is internally copied and not used then by reference.
  35498. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35499. */
  35500. setMultiMaterial(materials: Material[]): void;
  35501. /**
  35502. * The SPS computed multimaterial object
  35503. */
  35504. get multimaterial(): MultiMaterial;
  35505. set multimaterial(mm: MultiMaterial);
  35506. /**
  35507. * If the subMeshes must be updated on the next call to setParticles()
  35508. */
  35509. get autoUpdateSubMeshes(): boolean;
  35510. set autoUpdateSubMeshes(val: boolean);
  35511. /**
  35512. * This function does nothing. It may be overwritten to set all the particle first values.
  35513. * The SPS doesn't call this function, you may have to call it by your own.
  35514. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35515. */
  35516. initParticles(): void;
  35517. /**
  35518. * This function does nothing. It may be overwritten to recycle a particle.
  35519. * The SPS doesn't call this function, you may have to call it by your own.
  35520. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35521. * @param particle The particle to recycle
  35522. * @returns the recycled particle
  35523. */
  35524. recycleParticle(particle: SolidParticle): SolidParticle;
  35525. /**
  35526. * Updates a particle : this function should be overwritten by the user.
  35527. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35528. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35529. * @example : just set a particle position or velocity and recycle conditions
  35530. * @param particle The particle to update
  35531. * @returns the updated particle
  35532. */
  35533. updateParticle(particle: SolidParticle): SolidParticle;
  35534. /**
  35535. * Updates a vertex of a particle : it can be overwritten by the user.
  35536. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35537. * @param particle the current particle
  35538. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35539. * @param pt the index of the current vertex in the particle shape
  35540. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35541. * @example : just set a vertex particle position or color
  35542. * @returns the sps
  35543. */
  35544. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35545. /**
  35546. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35547. * This does nothing and may be overwritten by the user.
  35548. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35549. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35550. * @param update the boolean update value actually passed to setParticles()
  35551. */
  35552. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35553. /**
  35554. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35555. * This will be passed three parameters.
  35556. * This does nothing and may be overwritten by the user.
  35557. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35558. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35559. * @param update the boolean update value actually passed to setParticles()
  35560. */
  35561. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35562. }
  35563. }
  35564. declare module BABYLON {
  35565. /**
  35566. * Represents one particle of a solid particle system.
  35567. */
  35568. export class SolidParticle {
  35569. /**
  35570. * particle global index
  35571. */
  35572. idx: number;
  35573. /**
  35574. * particle identifier
  35575. */
  35576. id: number;
  35577. /**
  35578. * The color of the particle
  35579. */
  35580. color: Nullable<Color4>;
  35581. /**
  35582. * The world space position of the particle.
  35583. */
  35584. position: Vector3;
  35585. /**
  35586. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35587. */
  35588. rotation: Vector3;
  35589. /**
  35590. * The world space rotation quaternion of the particle.
  35591. */
  35592. rotationQuaternion: Nullable<Quaternion>;
  35593. /**
  35594. * The scaling of the particle.
  35595. */
  35596. scaling: Vector3;
  35597. /**
  35598. * The uvs of the particle.
  35599. */
  35600. uvs: Vector4;
  35601. /**
  35602. * The current speed of the particle.
  35603. */
  35604. velocity: Vector3;
  35605. /**
  35606. * The pivot point in the particle local space.
  35607. */
  35608. pivot: Vector3;
  35609. /**
  35610. * Must the particle be translated from its pivot point in its local space ?
  35611. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35612. * Default : false
  35613. */
  35614. translateFromPivot: boolean;
  35615. /**
  35616. * Is the particle active or not ?
  35617. */
  35618. alive: boolean;
  35619. /**
  35620. * Is the particle visible or not ?
  35621. */
  35622. isVisible: boolean;
  35623. /**
  35624. * Index of this particle in the global "positions" array (Internal use)
  35625. * @hidden
  35626. */
  35627. _pos: number;
  35628. /**
  35629. * @hidden Index of this particle in the global "indices" array (Internal use)
  35630. */
  35631. _ind: number;
  35632. /**
  35633. * @hidden ModelShape of this particle (Internal use)
  35634. */
  35635. _model: ModelShape;
  35636. /**
  35637. * ModelShape id of this particle
  35638. */
  35639. shapeId: number;
  35640. /**
  35641. * Index of the particle in its shape id
  35642. */
  35643. idxInShape: number;
  35644. /**
  35645. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35646. */
  35647. _modelBoundingInfo: BoundingInfo;
  35648. /**
  35649. * @hidden Particle BoundingInfo object (Internal use)
  35650. */
  35651. _boundingInfo: BoundingInfo;
  35652. /**
  35653. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35654. */
  35655. _sps: SolidParticleSystem;
  35656. /**
  35657. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35658. */
  35659. _stillInvisible: boolean;
  35660. /**
  35661. * @hidden Last computed particle rotation matrix
  35662. */
  35663. _rotationMatrix: number[];
  35664. /**
  35665. * Parent particle Id, if any.
  35666. * Default null.
  35667. */
  35668. parentId: Nullable<number>;
  35669. /**
  35670. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35671. */
  35672. materialIndex: Nullable<number>;
  35673. /**
  35674. * Custom object or properties.
  35675. */
  35676. props: Nullable<any>;
  35677. /**
  35678. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35679. * The possible values are :
  35680. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35681. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35682. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35683. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35684. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35685. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35686. * */
  35687. cullingStrategy: number;
  35688. /**
  35689. * @hidden Internal global position in the SPS.
  35690. */
  35691. _globalPosition: Vector3;
  35692. /**
  35693. * Creates a Solid Particle object.
  35694. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35695. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35696. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35697. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35698. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35699. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35700. * @param shapeId (integer) is the model shape identifier in the SPS.
  35701. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35702. * @param sps defines the sps it is associated to
  35703. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35704. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35705. */
  35706. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35707. /**
  35708. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35709. * @param target the particle target
  35710. * @returns the current particle
  35711. */
  35712. copyToRef(target: SolidParticle): SolidParticle;
  35713. /**
  35714. * Legacy support, changed scale to scaling
  35715. */
  35716. get scale(): Vector3;
  35717. /**
  35718. * Legacy support, changed scale to scaling
  35719. */
  35720. set scale(scale: Vector3);
  35721. /**
  35722. * Legacy support, changed quaternion to rotationQuaternion
  35723. */
  35724. get quaternion(): Nullable<Quaternion>;
  35725. /**
  35726. * Legacy support, changed quaternion to rotationQuaternion
  35727. */
  35728. set quaternion(q: Nullable<Quaternion>);
  35729. /**
  35730. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35731. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35732. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35733. * @returns true if it intersects
  35734. */
  35735. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35736. /**
  35737. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35738. * A particle is in the frustum if its bounding box intersects the frustum
  35739. * @param frustumPlanes defines the frustum to test
  35740. * @returns true if the particle is in the frustum planes
  35741. */
  35742. isInFrustum(frustumPlanes: Plane[]): boolean;
  35743. /**
  35744. * get the rotation matrix of the particle
  35745. * @hidden
  35746. */
  35747. getRotationMatrix(m: Matrix): void;
  35748. }
  35749. /**
  35750. * Represents the shape of the model used by one particle of a solid particle system.
  35751. * SPS internal tool, don't use it manually.
  35752. */
  35753. export class ModelShape {
  35754. /**
  35755. * The shape id
  35756. * @hidden
  35757. */
  35758. shapeID: number;
  35759. /**
  35760. * flat array of model positions (internal use)
  35761. * @hidden
  35762. */
  35763. _shape: Vector3[];
  35764. /**
  35765. * flat array of model UVs (internal use)
  35766. * @hidden
  35767. */
  35768. _shapeUV: number[];
  35769. /**
  35770. * color array of the model
  35771. * @hidden
  35772. */
  35773. _shapeColors: number[];
  35774. /**
  35775. * indices array of the model
  35776. * @hidden
  35777. */
  35778. _indices: number[];
  35779. /**
  35780. * normals array of the model
  35781. * @hidden
  35782. */
  35783. _normals: number[];
  35784. /**
  35785. * length of the shape in the model indices array (internal use)
  35786. * @hidden
  35787. */
  35788. _indicesLength: number;
  35789. /**
  35790. * Custom position function (internal use)
  35791. * @hidden
  35792. */
  35793. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35794. /**
  35795. * Custom vertex function (internal use)
  35796. * @hidden
  35797. */
  35798. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35799. /**
  35800. * Model material (internal use)
  35801. * @hidden
  35802. */
  35803. _material: Nullable<Material>;
  35804. /**
  35805. * 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.
  35806. * SPS internal tool, don't use it manually.
  35807. * @hidden
  35808. */
  35809. 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>);
  35810. }
  35811. /**
  35812. * Represents a Depth Sorted Particle in the solid particle system.
  35813. * @hidden
  35814. */
  35815. export class DepthSortedParticle {
  35816. /**
  35817. * Particle index
  35818. */
  35819. idx: number;
  35820. /**
  35821. * Index of the particle in the "indices" array
  35822. */
  35823. ind: number;
  35824. /**
  35825. * Length of the particle shape in the "indices" array
  35826. */
  35827. indicesLength: number;
  35828. /**
  35829. * Squared distance from the particle to the camera
  35830. */
  35831. sqDistance: number;
  35832. /**
  35833. * Material index when used with MultiMaterials
  35834. */
  35835. materialIndex: number;
  35836. /**
  35837. * Creates a new sorted particle
  35838. * @param materialIndex
  35839. */
  35840. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35841. }
  35842. /**
  35843. * Represents a solid particle vertex
  35844. */
  35845. export class SolidParticleVertex {
  35846. /**
  35847. * Vertex position
  35848. */
  35849. position: Vector3;
  35850. /**
  35851. * Vertex color
  35852. */
  35853. color: Color4;
  35854. /**
  35855. * Vertex UV
  35856. */
  35857. uv: Vector2;
  35858. /**
  35859. * Creates a new solid particle vertex
  35860. */
  35861. constructor();
  35862. /** Vertex x coordinate */
  35863. get x(): number;
  35864. set x(val: number);
  35865. /** Vertex y coordinate */
  35866. get y(): number;
  35867. set y(val: number);
  35868. /** Vertex z coordinate */
  35869. get z(): number;
  35870. set z(val: number);
  35871. }
  35872. }
  35873. declare module BABYLON {
  35874. /**
  35875. * @hidden
  35876. */
  35877. export class _MeshCollisionData {
  35878. _checkCollisions: boolean;
  35879. _collisionMask: number;
  35880. _collisionGroup: number;
  35881. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35882. _collider: Nullable<Collider>;
  35883. _oldPositionForCollisions: Vector3;
  35884. _diffPositionForCollisions: Vector3;
  35885. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35886. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35887. _collisionResponse: boolean;
  35888. }
  35889. }
  35890. declare module BABYLON {
  35891. /** @hidden */
  35892. class _FacetDataStorage {
  35893. facetPositions: Vector3[];
  35894. facetNormals: Vector3[];
  35895. facetPartitioning: number[][];
  35896. facetNb: number;
  35897. partitioningSubdivisions: number;
  35898. partitioningBBoxRatio: number;
  35899. facetDataEnabled: boolean;
  35900. facetParameters: any;
  35901. bbSize: Vector3;
  35902. subDiv: {
  35903. max: number;
  35904. X: number;
  35905. Y: number;
  35906. Z: number;
  35907. };
  35908. facetDepthSort: boolean;
  35909. facetDepthSortEnabled: boolean;
  35910. depthSortedIndices: IndicesArray;
  35911. depthSortedFacets: {
  35912. ind: number;
  35913. sqDistance: number;
  35914. }[];
  35915. facetDepthSortFunction: (f1: {
  35916. ind: number;
  35917. sqDistance: number;
  35918. }, f2: {
  35919. ind: number;
  35920. sqDistance: number;
  35921. }) => number;
  35922. facetDepthSortFrom: Vector3;
  35923. facetDepthSortOrigin: Vector3;
  35924. invertedMatrix: Matrix;
  35925. }
  35926. /**
  35927. * @hidden
  35928. **/
  35929. class _InternalAbstractMeshDataInfo {
  35930. _hasVertexAlpha: boolean;
  35931. _useVertexColors: boolean;
  35932. _numBoneInfluencers: number;
  35933. _applyFog: boolean;
  35934. _receiveShadows: boolean;
  35935. _facetData: _FacetDataStorage;
  35936. _visibility: number;
  35937. _skeleton: Nullable<Skeleton>;
  35938. _layerMask: number;
  35939. _computeBonesUsingShaders: boolean;
  35940. _isActive: boolean;
  35941. _onlyForInstances: boolean;
  35942. _isActiveIntermediate: boolean;
  35943. _onlyForInstancesIntermediate: boolean;
  35944. _actAsRegularMesh: boolean;
  35945. _currentLOD: Nullable<AbstractMesh>;
  35946. _currentLODIsUpToDate: boolean;
  35947. }
  35948. /**
  35949. * Class used to store all common mesh properties
  35950. */
  35951. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35952. /** No occlusion */
  35953. static OCCLUSION_TYPE_NONE: number;
  35954. /** Occlusion set to optimisitic */
  35955. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35956. /** Occlusion set to strict */
  35957. static OCCLUSION_TYPE_STRICT: number;
  35958. /** Use an accurante occlusion algorithm */
  35959. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35960. /** Use a conservative occlusion algorithm */
  35961. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35962. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35963. * Test order :
  35964. * Is the bounding sphere outside the frustum ?
  35965. * If not, are the bounding box vertices outside the frustum ?
  35966. * It not, then the cullable object is in the frustum.
  35967. */
  35968. static readonly CULLINGSTRATEGY_STANDARD: number;
  35969. /** Culling strategy : Bounding Sphere Only.
  35970. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35971. * It's also less accurate than the standard because some not visible objects can still be selected.
  35972. * Test : is the bounding sphere outside the frustum ?
  35973. * If not, then the cullable object is in the frustum.
  35974. */
  35975. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35976. /** Culling strategy : Optimistic Inclusion.
  35977. * This in an inclusion test first, then the standard exclusion test.
  35978. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35979. * 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.
  35980. * Anyway, it's as accurate as the standard strategy.
  35981. * Test :
  35982. * Is the cullable object bounding sphere center in the frustum ?
  35983. * If not, apply the default culling strategy.
  35984. */
  35985. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35986. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35987. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35988. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35989. * 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.
  35990. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35991. * Test :
  35992. * Is the cullable object bounding sphere center in the frustum ?
  35993. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35994. */
  35995. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35996. /**
  35997. * No billboard
  35998. */
  35999. static get BILLBOARDMODE_NONE(): number;
  36000. /** Billboard on X axis */
  36001. static get BILLBOARDMODE_X(): number;
  36002. /** Billboard on Y axis */
  36003. static get BILLBOARDMODE_Y(): number;
  36004. /** Billboard on Z axis */
  36005. static get BILLBOARDMODE_Z(): number;
  36006. /** Billboard on all axes */
  36007. static get BILLBOARDMODE_ALL(): number;
  36008. /** Billboard on using position instead of orientation */
  36009. static get BILLBOARDMODE_USE_POSITION(): number;
  36010. /** @hidden */
  36011. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36012. /**
  36013. * The culling strategy to use to check whether the mesh must be rendered or not.
  36014. * This value can be changed at any time and will be used on the next render mesh selection.
  36015. * The possible values are :
  36016. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36017. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36019. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36020. * Please read each static variable documentation to get details about the culling process.
  36021. * */
  36022. cullingStrategy: number;
  36023. /**
  36024. * Gets the number of facets in the mesh
  36025. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36026. */
  36027. get facetNb(): number;
  36028. /**
  36029. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36031. */
  36032. get partitioningSubdivisions(): number;
  36033. set partitioningSubdivisions(nb: number);
  36034. /**
  36035. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36036. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36038. */
  36039. get partitioningBBoxRatio(): number;
  36040. set partitioningBBoxRatio(ratio: number);
  36041. /**
  36042. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36043. * Works only for updatable meshes.
  36044. * Doesn't work with multi-materials
  36045. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36046. */
  36047. get mustDepthSortFacets(): boolean;
  36048. set mustDepthSortFacets(sort: boolean);
  36049. /**
  36050. * The location (Vector3) where the facet depth sort must be computed from.
  36051. * By default, the active camera position.
  36052. * Used only when facet depth sort is enabled
  36053. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36054. */
  36055. get facetDepthSortFrom(): Vector3;
  36056. set facetDepthSortFrom(location: Vector3);
  36057. /**
  36058. * gets a boolean indicating if facetData is enabled
  36059. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36060. */
  36061. get isFacetDataEnabled(): boolean;
  36062. /** @hidden */
  36063. _updateNonUniformScalingState(value: boolean): boolean;
  36064. /**
  36065. * An event triggered when this mesh collides with another one
  36066. */
  36067. onCollideObservable: Observable<AbstractMesh>;
  36068. /** Set a function to call when this mesh collides with another one */
  36069. set onCollide(callback: () => void);
  36070. /**
  36071. * An event triggered when the collision's position changes
  36072. */
  36073. onCollisionPositionChangeObservable: Observable<Vector3>;
  36074. /** Set a function to call when the collision's position changes */
  36075. set onCollisionPositionChange(callback: () => void);
  36076. /**
  36077. * An event triggered when material is changed
  36078. */
  36079. onMaterialChangedObservable: Observable<AbstractMesh>;
  36080. /**
  36081. * Gets or sets the orientation for POV movement & rotation
  36082. */
  36083. definedFacingForward: boolean;
  36084. /** @hidden */
  36085. _occlusionQuery: Nullable<WebGLQuery>;
  36086. /** @hidden */
  36087. _renderingGroup: Nullable<RenderingGroup>;
  36088. /**
  36089. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36090. */
  36091. get visibility(): number;
  36092. /**
  36093. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36094. */
  36095. set visibility(value: number);
  36096. /** Gets or sets the alpha index used to sort transparent meshes
  36097. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36098. */
  36099. alphaIndex: number;
  36100. /**
  36101. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36102. */
  36103. isVisible: boolean;
  36104. /**
  36105. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36106. */
  36107. isPickable: boolean;
  36108. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36109. showSubMeshesBoundingBox: boolean;
  36110. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36111. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36112. */
  36113. isBlocker: boolean;
  36114. /**
  36115. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36116. */
  36117. enablePointerMoveEvents: boolean;
  36118. private _renderingGroupId;
  36119. /**
  36120. * Specifies the rendering group id for this mesh (0 by default)
  36121. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36122. */
  36123. get renderingGroupId(): number;
  36124. set renderingGroupId(value: number);
  36125. private _material;
  36126. /** Gets or sets current material */
  36127. get material(): Nullable<Material>;
  36128. set material(value: Nullable<Material>);
  36129. /**
  36130. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36131. * @see https://doc.babylonjs.com/babylon101/shadows
  36132. */
  36133. get receiveShadows(): boolean;
  36134. set receiveShadows(value: boolean);
  36135. /** Defines color to use when rendering outline */
  36136. outlineColor: Color3;
  36137. /** Define width to use when rendering outline */
  36138. outlineWidth: number;
  36139. /** Defines color to use when rendering overlay */
  36140. overlayColor: Color3;
  36141. /** Defines alpha to use when rendering overlay */
  36142. overlayAlpha: number;
  36143. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36144. get hasVertexAlpha(): boolean;
  36145. set hasVertexAlpha(value: boolean);
  36146. /** 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) */
  36147. get useVertexColors(): boolean;
  36148. set useVertexColors(value: boolean);
  36149. /**
  36150. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36151. */
  36152. get computeBonesUsingShaders(): boolean;
  36153. set computeBonesUsingShaders(value: boolean);
  36154. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36155. get numBoneInfluencers(): number;
  36156. set numBoneInfluencers(value: number);
  36157. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36158. get applyFog(): boolean;
  36159. set applyFog(value: boolean);
  36160. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36161. useOctreeForRenderingSelection: boolean;
  36162. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36163. useOctreeForPicking: boolean;
  36164. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36165. useOctreeForCollisions: boolean;
  36166. /**
  36167. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36168. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36169. */
  36170. get layerMask(): number;
  36171. set layerMask(value: number);
  36172. /**
  36173. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36174. */
  36175. alwaysSelectAsActiveMesh: boolean;
  36176. /**
  36177. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36178. */
  36179. doNotSyncBoundingInfo: boolean;
  36180. /**
  36181. * Gets or sets the current action manager
  36182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36183. */
  36184. actionManager: Nullable<AbstractActionManager>;
  36185. private _meshCollisionData;
  36186. /**
  36187. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36188. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36189. */
  36190. ellipsoid: Vector3;
  36191. /**
  36192. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36193. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36194. */
  36195. ellipsoidOffset: Vector3;
  36196. /**
  36197. * Gets or sets a collision mask used to mask collisions (default is -1).
  36198. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36199. */
  36200. get collisionMask(): number;
  36201. set collisionMask(mask: number);
  36202. /**
  36203. * Gets or sets a collision response flag (default is true).
  36204. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36205. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36206. * to respond to the collision.
  36207. */
  36208. get collisionResponse(): boolean;
  36209. set collisionResponse(response: boolean);
  36210. /**
  36211. * Gets or sets the current collision group mask (-1 by default).
  36212. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36213. */
  36214. get collisionGroup(): number;
  36215. set collisionGroup(mask: number);
  36216. /**
  36217. * Gets or sets current surrounding meshes (null by default).
  36218. *
  36219. * By default collision detection is tested against every mesh in the scene.
  36220. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36221. * meshes will be tested for the collision.
  36222. *
  36223. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36224. */
  36225. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36226. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36227. /**
  36228. * Defines edge width used when edgesRenderer is enabled
  36229. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36230. */
  36231. edgesWidth: number;
  36232. /**
  36233. * Defines edge color used when edgesRenderer is enabled
  36234. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36235. */
  36236. edgesColor: Color4;
  36237. /** @hidden */
  36238. _edgesRenderer: Nullable<IEdgesRenderer>;
  36239. /** @hidden */
  36240. _masterMesh: Nullable<AbstractMesh>;
  36241. /** @hidden */
  36242. _boundingInfo: Nullable<BoundingInfo>;
  36243. /** @hidden */
  36244. _renderId: number;
  36245. /**
  36246. * Gets or sets the list of subMeshes
  36247. * @see https://doc.babylonjs.com/how_to/multi_materials
  36248. */
  36249. subMeshes: SubMesh[];
  36250. /** @hidden */
  36251. _intersectionsInProgress: AbstractMesh[];
  36252. /** @hidden */
  36253. _unIndexed: boolean;
  36254. /** @hidden */
  36255. _lightSources: Light[];
  36256. /** Gets the list of lights affecting that mesh */
  36257. get lightSources(): Light[];
  36258. /** @hidden */
  36259. get _positions(): Nullable<Vector3[]>;
  36260. /** @hidden */
  36261. _waitingData: {
  36262. lods: Nullable<any>;
  36263. actions: Nullable<any>;
  36264. freezeWorldMatrix: Nullable<boolean>;
  36265. };
  36266. /** @hidden */
  36267. _bonesTransformMatrices: Nullable<Float32Array>;
  36268. /** @hidden */
  36269. _transformMatrixTexture: Nullable<RawTexture>;
  36270. /**
  36271. * Gets or sets a skeleton to apply skining transformations
  36272. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36273. */
  36274. set skeleton(value: Nullable<Skeleton>);
  36275. get skeleton(): Nullable<Skeleton>;
  36276. /**
  36277. * An event triggered when the mesh is rebuilt.
  36278. */
  36279. onRebuildObservable: Observable<AbstractMesh>;
  36280. /**
  36281. * The current mesh unifom buffer.
  36282. * @hidden Internal use only.
  36283. */
  36284. _uniformBuffer: UniformBuffer;
  36285. /**
  36286. * Creates a new AbstractMesh
  36287. * @param name defines the name of the mesh
  36288. * @param scene defines the hosting scene
  36289. */
  36290. constructor(name: string, scene?: Nullable<Scene>);
  36291. protected _buildUniformLayout(): void;
  36292. /**
  36293. * Transfer the mesh values to its UBO.
  36294. * @param world The world matrix associated with the mesh
  36295. */
  36296. transferToEffect(world: Matrix): void;
  36297. /**
  36298. * Gets the mesh uniform buffer.
  36299. * @return the uniform buffer of the mesh.
  36300. */
  36301. getMeshUniformBuffer(): UniformBuffer;
  36302. /**
  36303. * Returns the string "AbstractMesh"
  36304. * @returns "AbstractMesh"
  36305. */
  36306. getClassName(): string;
  36307. /**
  36308. * Gets a string representation of the current mesh
  36309. * @param fullDetails defines a boolean indicating if full details must be included
  36310. * @returns a string representation of the current mesh
  36311. */
  36312. toString(fullDetails?: boolean): string;
  36313. /**
  36314. * @hidden
  36315. */
  36316. protected _getEffectiveParent(): Nullable<Node>;
  36317. /** @hidden */
  36318. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36319. /** @hidden */
  36320. _rebuild(): void;
  36321. /** @hidden */
  36322. _resyncLightSources(): void;
  36323. /** @hidden */
  36324. _resyncLightSource(light: Light): void;
  36325. /** @hidden */
  36326. _unBindEffect(): void;
  36327. /** @hidden */
  36328. _removeLightSource(light: Light, dispose: boolean): void;
  36329. private _markSubMeshesAsDirty;
  36330. /** @hidden */
  36331. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36332. /** @hidden */
  36333. _markSubMeshesAsAttributesDirty(): void;
  36334. /** @hidden */
  36335. _markSubMeshesAsMiscDirty(): void;
  36336. /**
  36337. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36338. */
  36339. get scaling(): Vector3;
  36340. set scaling(newScaling: Vector3);
  36341. /**
  36342. * Returns true if the mesh is blocked. Implemented by child classes
  36343. */
  36344. get isBlocked(): boolean;
  36345. /**
  36346. * Returns the mesh itself by default. Implemented by child classes
  36347. * @param camera defines the camera to use to pick the right LOD level
  36348. * @returns the currentAbstractMesh
  36349. */
  36350. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36351. /**
  36352. * Returns 0 by default. Implemented by child classes
  36353. * @returns an integer
  36354. */
  36355. getTotalVertices(): number;
  36356. /**
  36357. * Returns a positive integer : the total number of indices in this mesh geometry.
  36358. * @returns the numner of indices or zero if the mesh has no geometry.
  36359. */
  36360. getTotalIndices(): number;
  36361. /**
  36362. * Returns null by default. Implemented by child classes
  36363. * @returns null
  36364. */
  36365. getIndices(): Nullable<IndicesArray>;
  36366. /**
  36367. * Returns the array of the requested vertex data kind. Implemented by child classes
  36368. * @param kind defines the vertex data kind to use
  36369. * @returns null
  36370. */
  36371. getVerticesData(kind: string): Nullable<FloatArray>;
  36372. /**
  36373. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36374. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36375. * Note that a new underlying VertexBuffer object is created each call.
  36376. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36377. * @param kind defines vertex data kind:
  36378. * * VertexBuffer.PositionKind
  36379. * * VertexBuffer.UVKind
  36380. * * VertexBuffer.UV2Kind
  36381. * * VertexBuffer.UV3Kind
  36382. * * VertexBuffer.UV4Kind
  36383. * * VertexBuffer.UV5Kind
  36384. * * VertexBuffer.UV6Kind
  36385. * * VertexBuffer.ColorKind
  36386. * * VertexBuffer.MatricesIndicesKind
  36387. * * VertexBuffer.MatricesIndicesExtraKind
  36388. * * VertexBuffer.MatricesWeightsKind
  36389. * * VertexBuffer.MatricesWeightsExtraKind
  36390. * @param data defines the data source
  36391. * @param updatable defines if the data must be flagged as updatable (or static)
  36392. * @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
  36393. * @returns the current mesh
  36394. */
  36395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36396. /**
  36397. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36398. * If the mesh has no geometry, it is simply returned as it is.
  36399. * @param kind defines vertex data kind:
  36400. * * VertexBuffer.PositionKind
  36401. * * VertexBuffer.UVKind
  36402. * * VertexBuffer.UV2Kind
  36403. * * VertexBuffer.UV3Kind
  36404. * * VertexBuffer.UV4Kind
  36405. * * VertexBuffer.UV5Kind
  36406. * * VertexBuffer.UV6Kind
  36407. * * VertexBuffer.ColorKind
  36408. * * VertexBuffer.MatricesIndicesKind
  36409. * * VertexBuffer.MatricesIndicesExtraKind
  36410. * * VertexBuffer.MatricesWeightsKind
  36411. * * VertexBuffer.MatricesWeightsExtraKind
  36412. * @param data defines the data source
  36413. * @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
  36414. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36415. * @returns the current mesh
  36416. */
  36417. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36418. /**
  36419. * Sets the mesh indices,
  36420. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36421. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36422. * @param totalVertices Defines the total number of vertices
  36423. * @returns the current mesh
  36424. */
  36425. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36426. /**
  36427. * Gets a boolean indicating if specific vertex data is present
  36428. * @param kind defines the vertex data kind to use
  36429. * @returns true is data kind is present
  36430. */
  36431. isVerticesDataPresent(kind: string): boolean;
  36432. /**
  36433. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36434. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36435. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36436. * @returns a BoundingInfo
  36437. */
  36438. getBoundingInfo(): BoundingInfo;
  36439. /**
  36440. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36441. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36442. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36443. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36444. * @returns the current mesh
  36445. */
  36446. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36447. /**
  36448. * Overwrite the current bounding info
  36449. * @param boundingInfo defines the new bounding info
  36450. * @returns the current mesh
  36451. */
  36452. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36453. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36454. get useBones(): boolean;
  36455. /** @hidden */
  36456. _preActivate(): void;
  36457. /** @hidden */
  36458. _preActivateForIntermediateRendering(renderId: number): void;
  36459. /** @hidden */
  36460. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36461. /** @hidden */
  36462. _postActivate(): void;
  36463. /** @hidden */
  36464. _freeze(): void;
  36465. /** @hidden */
  36466. _unFreeze(): void;
  36467. /**
  36468. * Gets the current world matrix
  36469. * @returns a Matrix
  36470. */
  36471. getWorldMatrix(): Matrix;
  36472. /** @hidden */
  36473. _getWorldMatrixDeterminant(): number;
  36474. /**
  36475. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36476. */
  36477. get isAnInstance(): boolean;
  36478. /**
  36479. * Gets a boolean indicating if this mesh has instances
  36480. */
  36481. get hasInstances(): boolean;
  36482. /**
  36483. * Gets a boolean indicating if this mesh has thin instances
  36484. */
  36485. get hasThinInstances(): boolean;
  36486. /**
  36487. * Perform relative position change from the point of view of behind the front of the mesh.
  36488. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36489. * Supports definition of mesh facing forward or backward
  36490. * @param amountRight defines the distance on the right axis
  36491. * @param amountUp defines the distance on the up axis
  36492. * @param amountForward defines the distance on the forward axis
  36493. * @returns the current mesh
  36494. */
  36495. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36496. /**
  36497. * Calculate relative position change from the point of view of behind the front of the mesh.
  36498. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36499. * Supports definition of mesh facing forward or backward
  36500. * @param amountRight defines the distance on the right axis
  36501. * @param amountUp defines the distance on the up axis
  36502. * @param amountForward defines the distance on the forward axis
  36503. * @returns the new displacement vector
  36504. */
  36505. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36506. /**
  36507. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36508. * Supports definition of mesh facing forward or backward
  36509. * @param flipBack defines the flip
  36510. * @param twirlClockwise defines the twirl
  36511. * @param tiltRight defines the tilt
  36512. * @returns the current mesh
  36513. */
  36514. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36515. /**
  36516. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36517. * Supports definition of mesh facing forward or backward.
  36518. * @param flipBack defines the flip
  36519. * @param twirlClockwise defines the twirl
  36520. * @param tiltRight defines the tilt
  36521. * @returns the new rotation vector
  36522. */
  36523. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36524. /**
  36525. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36526. * This means the mesh underlying bounding box and sphere are recomputed.
  36527. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36528. * @returns the current mesh
  36529. */
  36530. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36531. /** @hidden */
  36532. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36533. /** @hidden */
  36534. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36535. /** @hidden */
  36536. _updateBoundingInfo(): AbstractMesh;
  36537. /** @hidden */
  36538. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36539. /** @hidden */
  36540. protected _afterComputeWorldMatrix(): void;
  36541. /** @hidden */
  36542. get _effectiveMesh(): AbstractMesh;
  36543. /**
  36544. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36545. * A mesh is in the frustum if its bounding box intersects the frustum
  36546. * @param frustumPlanes defines the frustum to test
  36547. * @returns true if the mesh is in the frustum planes
  36548. */
  36549. isInFrustum(frustumPlanes: Plane[]): boolean;
  36550. /**
  36551. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36552. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36553. * @param frustumPlanes defines the frustum to test
  36554. * @returns true if the mesh is completely in the frustum planes
  36555. */
  36556. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36557. /**
  36558. * True if the mesh intersects another mesh or a SolidParticle object
  36559. * @param mesh defines a target mesh or SolidParticle to test
  36560. * @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)
  36561. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36562. * @returns true if there is an intersection
  36563. */
  36564. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36565. /**
  36566. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36567. * @param point defines the point to test
  36568. * @returns true if there is an intersection
  36569. */
  36570. intersectsPoint(point: Vector3): boolean;
  36571. /**
  36572. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36573. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36574. */
  36575. get checkCollisions(): boolean;
  36576. set checkCollisions(collisionEnabled: boolean);
  36577. /**
  36578. * Gets Collider object used to compute collisions (not physics)
  36579. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36580. */
  36581. get collider(): Nullable<Collider>;
  36582. /**
  36583. * Move the mesh using collision engine
  36584. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36585. * @param displacement defines the requested displacement vector
  36586. * @returns the current mesh
  36587. */
  36588. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36589. private _onCollisionPositionChange;
  36590. /** @hidden */
  36591. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36592. /** @hidden */
  36593. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36594. /** @hidden */
  36595. _checkCollision(collider: Collider): AbstractMesh;
  36596. /** @hidden */
  36597. _generatePointsArray(): boolean;
  36598. /**
  36599. * Checks if the passed Ray intersects with the mesh
  36600. * @param ray defines the ray to use
  36601. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36603. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36604. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36605. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36606. * @returns the picking info
  36607. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36608. */
  36609. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36610. /**
  36611. * Clones the current mesh
  36612. * @param name defines the mesh name
  36613. * @param newParent defines the new mesh parent
  36614. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36615. * @returns the new mesh
  36616. */
  36617. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36618. /**
  36619. * Disposes all the submeshes of the current meshnp
  36620. * @returns the current mesh
  36621. */
  36622. releaseSubMeshes(): AbstractMesh;
  36623. /**
  36624. * Releases resources associated with this abstract mesh.
  36625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36627. */
  36628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36629. /**
  36630. * Adds the passed mesh as a child to the current mesh
  36631. * @param mesh defines the child mesh
  36632. * @returns the current mesh
  36633. */
  36634. addChild(mesh: AbstractMesh): AbstractMesh;
  36635. /**
  36636. * Removes the passed mesh from the current mesh children list
  36637. * @param mesh defines the child mesh
  36638. * @returns the current mesh
  36639. */
  36640. removeChild(mesh: AbstractMesh): AbstractMesh;
  36641. /** @hidden */
  36642. private _initFacetData;
  36643. /**
  36644. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36645. * This method can be called within the render loop.
  36646. * 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
  36647. * @returns the current mesh
  36648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36649. */
  36650. updateFacetData(): AbstractMesh;
  36651. /**
  36652. * Returns the facetLocalNormals array.
  36653. * The normals are expressed in the mesh local spac
  36654. * @returns an array of Vector3
  36655. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36656. */
  36657. getFacetLocalNormals(): Vector3[];
  36658. /**
  36659. * Returns the facetLocalPositions array.
  36660. * The facet positions are expressed in the mesh local space
  36661. * @returns an array of Vector3
  36662. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36663. */
  36664. getFacetLocalPositions(): Vector3[];
  36665. /**
  36666. * Returns the facetLocalPartioning array
  36667. * @returns an array of array of numbers
  36668. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36669. */
  36670. getFacetLocalPartitioning(): number[][];
  36671. /**
  36672. * Returns the i-th facet position in the world system.
  36673. * This method allocates a new Vector3 per call
  36674. * @param i defines the facet index
  36675. * @returns a new Vector3
  36676. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36677. */
  36678. getFacetPosition(i: number): Vector3;
  36679. /**
  36680. * Sets the reference Vector3 with the i-th facet position in the world system
  36681. * @param i defines the facet index
  36682. * @param ref defines the target vector
  36683. * @returns the current mesh
  36684. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36685. */
  36686. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36687. /**
  36688. * Returns the i-th facet normal in the world system.
  36689. * This method allocates a new Vector3 per call
  36690. * @param i defines the facet index
  36691. * @returns a new Vector3
  36692. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36693. */
  36694. getFacetNormal(i: number): Vector3;
  36695. /**
  36696. * Sets the reference Vector3 with the i-th facet normal in the world system
  36697. * @param i defines the facet index
  36698. * @param ref defines the target vector
  36699. * @returns the current mesh
  36700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36701. */
  36702. getFacetNormalToRef(i: number, ref: Vector3): this;
  36703. /**
  36704. * 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)
  36705. * @param x defines x coordinate
  36706. * @param y defines y coordinate
  36707. * @param z defines z coordinate
  36708. * @returns the array of facet indexes
  36709. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36710. */
  36711. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36712. /**
  36713. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36714. * @param projected sets as the (x,y,z) world projection on the facet
  36715. * @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
  36716. * @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
  36717. * @param x defines x coordinate
  36718. * @param y defines y coordinate
  36719. * @param z defines z coordinate
  36720. * @returns the face index if found (or null instead)
  36721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36722. */
  36723. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36724. /**
  36725. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36726. * @param projected sets as the (x,y,z) local projection on the facet
  36727. * @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
  36728. * @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
  36729. * @param x defines x coordinate
  36730. * @param y defines y coordinate
  36731. * @param z defines z coordinate
  36732. * @returns the face index if found (or null instead)
  36733. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36734. */
  36735. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36736. /**
  36737. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36738. * @returns the parameters
  36739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36740. */
  36741. getFacetDataParameters(): any;
  36742. /**
  36743. * Disables the feature FacetData and frees the related memory
  36744. * @returns the current mesh
  36745. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36746. */
  36747. disableFacetData(): AbstractMesh;
  36748. /**
  36749. * Updates the AbstractMesh indices array
  36750. * @param indices defines the data source
  36751. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36752. * @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)
  36753. * @returns the current mesh
  36754. */
  36755. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36756. /**
  36757. * Creates new normals data for the mesh
  36758. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36759. * @returns the current mesh
  36760. */
  36761. createNormals(updatable: boolean): AbstractMesh;
  36762. /**
  36763. * Align the mesh with a normal
  36764. * @param normal defines the normal to use
  36765. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36766. * @returns the current mesh
  36767. */
  36768. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36769. /** @hidden */
  36770. _checkOcclusionQuery(): boolean;
  36771. /**
  36772. * Disables the mesh edge rendering mode
  36773. * @returns the currentAbstractMesh
  36774. */
  36775. disableEdgesRendering(): AbstractMesh;
  36776. /**
  36777. * Enables the edge rendering mode on the mesh.
  36778. * This mode makes the mesh edges visible
  36779. * @param epsilon defines the maximal distance between two angles to detect a face
  36780. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36781. * @param options options to the edge renderer
  36782. * @returns the currentAbstractMesh
  36783. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36784. */
  36785. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36786. /**
  36787. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36788. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36789. */
  36790. getConnectedParticleSystems(): IParticleSystem[];
  36791. }
  36792. }
  36793. declare module BABYLON {
  36794. /**
  36795. * Interface used to define ActionEvent
  36796. */
  36797. export interface IActionEvent {
  36798. /** The mesh or sprite that triggered the action */
  36799. source: any;
  36800. /** The X mouse cursor position at the time of the event */
  36801. pointerX: number;
  36802. /** The Y mouse cursor position at the time of the event */
  36803. pointerY: number;
  36804. /** The mesh that is currently pointed at (can be null) */
  36805. meshUnderPointer: Nullable<AbstractMesh>;
  36806. /** the original (browser) event that triggered the ActionEvent */
  36807. sourceEvent?: any;
  36808. /** additional data for the event */
  36809. additionalData?: any;
  36810. }
  36811. /**
  36812. * ActionEvent is the event being sent when an action is triggered.
  36813. */
  36814. export class ActionEvent implements IActionEvent {
  36815. /** The mesh or sprite that triggered the action */
  36816. source: any;
  36817. /** The X mouse cursor position at the time of the event */
  36818. pointerX: number;
  36819. /** The Y mouse cursor position at the time of the event */
  36820. pointerY: number;
  36821. /** The mesh that is currently pointed at (can be null) */
  36822. meshUnderPointer: Nullable<AbstractMesh>;
  36823. /** the original (browser) event that triggered the ActionEvent */
  36824. sourceEvent?: any;
  36825. /** additional data for the event */
  36826. additionalData?: any;
  36827. /**
  36828. * Creates a new ActionEvent
  36829. * @param source The mesh or sprite that triggered the action
  36830. * @param pointerX The X mouse cursor position at the time of the event
  36831. * @param pointerY The Y mouse cursor position at the time of the event
  36832. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36833. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36834. * @param additionalData additional data for the event
  36835. */
  36836. constructor(
  36837. /** The mesh or sprite that triggered the action */
  36838. source: any,
  36839. /** The X mouse cursor position at the time of the event */
  36840. pointerX: number,
  36841. /** The Y mouse cursor position at the time of the event */
  36842. pointerY: number,
  36843. /** The mesh that is currently pointed at (can be null) */
  36844. meshUnderPointer: Nullable<AbstractMesh>,
  36845. /** the original (browser) event that triggered the ActionEvent */
  36846. sourceEvent?: any,
  36847. /** additional data for the event */
  36848. additionalData?: any);
  36849. /**
  36850. * Helper function to auto-create an ActionEvent from a source mesh.
  36851. * @param source The source mesh that triggered the event
  36852. * @param evt The original (browser) event
  36853. * @param additionalData additional data for the event
  36854. * @returns the new ActionEvent
  36855. */
  36856. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36857. /**
  36858. * Helper function to auto-create an ActionEvent from a source sprite
  36859. * @param source The source sprite that triggered the event
  36860. * @param scene Scene associated with the sprite
  36861. * @param evt The original (browser) event
  36862. * @param additionalData additional data for the event
  36863. * @returns the new ActionEvent
  36864. */
  36865. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36866. /**
  36867. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36868. * @param scene the scene where the event occurred
  36869. * @param evt The original (browser) event
  36870. * @returns the new ActionEvent
  36871. */
  36872. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36873. /**
  36874. * Helper function to auto-create an ActionEvent from a primitive
  36875. * @param prim defines the target primitive
  36876. * @param pointerPos defines the pointer position
  36877. * @param evt The original (browser) event
  36878. * @param additionalData additional data for the event
  36879. * @returns the new ActionEvent
  36880. */
  36881. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36882. }
  36883. }
  36884. declare module BABYLON {
  36885. /**
  36886. * Abstract class used to decouple action Manager from scene and meshes.
  36887. * Do not instantiate.
  36888. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36889. */
  36890. export abstract class AbstractActionManager implements IDisposable {
  36891. /** Gets the list of active triggers */
  36892. static Triggers: {
  36893. [key: string]: number;
  36894. };
  36895. /** Gets the cursor to use when hovering items */
  36896. hoverCursor: string;
  36897. /** Gets the list of actions */
  36898. actions: IAction[];
  36899. /**
  36900. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36901. */
  36902. isRecursive: boolean;
  36903. /**
  36904. * Releases all associated resources
  36905. */
  36906. abstract dispose(): void;
  36907. /**
  36908. * Does this action manager has pointer triggers
  36909. */
  36910. abstract get hasPointerTriggers(): boolean;
  36911. /**
  36912. * Does this action manager has pick triggers
  36913. */
  36914. abstract get hasPickTriggers(): boolean;
  36915. /**
  36916. * Process a specific trigger
  36917. * @param trigger defines the trigger to process
  36918. * @param evt defines the event details to be processed
  36919. */
  36920. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36921. /**
  36922. * Does this action manager handles actions of any of the given triggers
  36923. * @param triggers defines the triggers to be tested
  36924. * @return a boolean indicating whether one (or more) of the triggers is handled
  36925. */
  36926. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36927. /**
  36928. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36929. * speed.
  36930. * @param triggerA defines the trigger to be tested
  36931. * @param triggerB defines the trigger to be tested
  36932. * @return a boolean indicating whether one (or more) of the triggers is handled
  36933. */
  36934. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36935. /**
  36936. * Does this action manager handles actions of a given trigger
  36937. * @param trigger defines the trigger to be tested
  36938. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36939. * @return whether the trigger is handled
  36940. */
  36941. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36942. /**
  36943. * Serialize this manager to a JSON object
  36944. * @param name defines the property name to store this manager
  36945. * @returns a JSON representation of this manager
  36946. */
  36947. abstract serialize(name: string): any;
  36948. /**
  36949. * Registers an action to this action manager
  36950. * @param action defines the action to be registered
  36951. * @return the action amended (prepared) after registration
  36952. */
  36953. abstract registerAction(action: IAction): Nullable<IAction>;
  36954. /**
  36955. * Unregisters an action to this action manager
  36956. * @param action defines the action to be unregistered
  36957. * @return a boolean indicating whether the action has been unregistered
  36958. */
  36959. abstract unregisterAction(action: IAction): Boolean;
  36960. /**
  36961. * Does exist one action manager with at least one trigger
  36962. **/
  36963. static get HasTriggers(): boolean;
  36964. /**
  36965. * Does exist one action manager with at least one pick trigger
  36966. **/
  36967. static get HasPickTriggers(): boolean;
  36968. /**
  36969. * Does exist one action manager that handles actions of a given trigger
  36970. * @param trigger defines the trigger to be tested
  36971. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36972. **/
  36973. static HasSpecificTrigger(trigger: number): boolean;
  36974. }
  36975. }
  36976. declare module BABYLON {
  36977. /**
  36978. * Defines how a node can be built from a string name.
  36979. */
  36980. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36981. /**
  36982. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36983. */
  36984. export class Node implements IBehaviorAware<Node> {
  36985. /** @hidden */
  36986. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36987. private static _NodeConstructors;
  36988. /**
  36989. * Add a new node constructor
  36990. * @param type defines the type name of the node to construct
  36991. * @param constructorFunc defines the constructor function
  36992. */
  36993. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36994. /**
  36995. * Returns a node constructor based on type name
  36996. * @param type defines the type name
  36997. * @param name defines the new node name
  36998. * @param scene defines the hosting scene
  36999. * @param options defines optional options to transmit to constructors
  37000. * @returns the new constructor or null
  37001. */
  37002. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37003. /**
  37004. * Gets or sets the name of the node
  37005. */
  37006. name: string;
  37007. /**
  37008. * Gets or sets the id of the node
  37009. */
  37010. id: string;
  37011. /**
  37012. * Gets or sets the unique id of the node
  37013. */
  37014. uniqueId: number;
  37015. /**
  37016. * Gets or sets a string used to store user defined state for the node
  37017. */
  37018. state: string;
  37019. /**
  37020. * Gets or sets an object used to store user defined information for the node
  37021. */
  37022. metadata: any;
  37023. /**
  37024. * For internal use only. Please do not use.
  37025. */
  37026. reservedDataStore: any;
  37027. /**
  37028. * List of inspectable custom properties (used by the Inspector)
  37029. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37030. */
  37031. inspectableCustomProperties: IInspectable[];
  37032. private _doNotSerialize;
  37033. /**
  37034. * Gets or sets a boolean used to define if the node must be serialized
  37035. */
  37036. get doNotSerialize(): boolean;
  37037. set doNotSerialize(value: boolean);
  37038. /** @hidden */
  37039. _isDisposed: boolean;
  37040. /**
  37041. * Gets a list of Animations associated with the node
  37042. */
  37043. animations: Animation[];
  37044. protected _ranges: {
  37045. [name: string]: Nullable<AnimationRange>;
  37046. };
  37047. /**
  37048. * Callback raised when the node is ready to be used
  37049. */
  37050. onReady: Nullable<(node: Node) => void>;
  37051. private _isEnabled;
  37052. private _isParentEnabled;
  37053. private _isReady;
  37054. /** @hidden */
  37055. _currentRenderId: number;
  37056. private _parentUpdateId;
  37057. /** @hidden */
  37058. _childUpdateId: number;
  37059. /** @hidden */
  37060. _waitingParentId: Nullable<string>;
  37061. /** @hidden */
  37062. _scene: Scene;
  37063. /** @hidden */
  37064. _cache: any;
  37065. private _parentNode;
  37066. private _children;
  37067. /** @hidden */
  37068. _worldMatrix: Matrix;
  37069. /** @hidden */
  37070. _worldMatrixDeterminant: number;
  37071. /** @hidden */
  37072. _worldMatrixDeterminantIsDirty: boolean;
  37073. /** @hidden */
  37074. private _sceneRootNodesIndex;
  37075. /**
  37076. * Gets a boolean indicating if the node has been disposed
  37077. * @returns true if the node was disposed
  37078. */
  37079. isDisposed(): boolean;
  37080. /**
  37081. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37082. * @see https://doc.babylonjs.com/how_to/parenting
  37083. */
  37084. set parent(parent: Nullable<Node>);
  37085. get parent(): Nullable<Node>;
  37086. /** @hidden */
  37087. _addToSceneRootNodes(): void;
  37088. /** @hidden */
  37089. _removeFromSceneRootNodes(): void;
  37090. private _animationPropertiesOverride;
  37091. /**
  37092. * Gets or sets the animation properties override
  37093. */
  37094. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37095. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37096. /**
  37097. * Gets a string identifying the name of the class
  37098. * @returns "Node" string
  37099. */
  37100. getClassName(): string;
  37101. /** @hidden */
  37102. readonly _isNode: boolean;
  37103. /**
  37104. * An event triggered when the mesh is disposed
  37105. */
  37106. onDisposeObservable: Observable<Node>;
  37107. private _onDisposeObserver;
  37108. /**
  37109. * Sets a callback that will be raised when the node will be disposed
  37110. */
  37111. set onDispose(callback: () => void);
  37112. /**
  37113. * Creates a new Node
  37114. * @param name the name and id to be given to this node
  37115. * @param scene the scene this node will be added to
  37116. */
  37117. constructor(name: string, scene?: Nullable<Scene>);
  37118. /**
  37119. * Gets the scene of the node
  37120. * @returns a scene
  37121. */
  37122. getScene(): Scene;
  37123. /**
  37124. * Gets the engine of the node
  37125. * @returns a Engine
  37126. */
  37127. getEngine(): Engine;
  37128. private _behaviors;
  37129. /**
  37130. * Attach a behavior to the node
  37131. * @see https://doc.babylonjs.com/features/behaviour
  37132. * @param behavior defines the behavior to attach
  37133. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37134. * @returns the current Node
  37135. */
  37136. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37137. /**
  37138. * Remove an attached behavior
  37139. * @see https://doc.babylonjs.com/features/behaviour
  37140. * @param behavior defines the behavior to attach
  37141. * @returns the current Node
  37142. */
  37143. removeBehavior(behavior: Behavior<Node>): Node;
  37144. /**
  37145. * Gets the list of attached behaviors
  37146. * @see https://doc.babylonjs.com/features/behaviour
  37147. */
  37148. get behaviors(): Behavior<Node>[];
  37149. /**
  37150. * Gets an attached behavior by name
  37151. * @param name defines the name of the behavior to look for
  37152. * @see https://doc.babylonjs.com/features/behaviour
  37153. * @returns null if behavior was not found else the requested behavior
  37154. */
  37155. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37156. /**
  37157. * Returns the latest update of the World matrix
  37158. * @returns a Matrix
  37159. */
  37160. getWorldMatrix(): Matrix;
  37161. /** @hidden */
  37162. _getWorldMatrixDeterminant(): number;
  37163. /**
  37164. * Returns directly the latest state of the mesh World matrix.
  37165. * A Matrix is returned.
  37166. */
  37167. get worldMatrixFromCache(): Matrix;
  37168. /** @hidden */
  37169. _initCache(): void;
  37170. /** @hidden */
  37171. updateCache(force?: boolean): void;
  37172. /** @hidden */
  37173. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37174. /** @hidden */
  37175. _updateCache(ignoreParentClass?: boolean): void;
  37176. /** @hidden */
  37177. _isSynchronized(): boolean;
  37178. /** @hidden */
  37179. _markSyncedWithParent(): void;
  37180. /** @hidden */
  37181. isSynchronizedWithParent(): boolean;
  37182. /** @hidden */
  37183. isSynchronized(): boolean;
  37184. /**
  37185. * Is this node ready to be used/rendered
  37186. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37187. * @return true if the node is ready
  37188. */
  37189. isReady(completeCheck?: boolean): boolean;
  37190. /**
  37191. * Is this node enabled?
  37192. * 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
  37193. * @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
  37194. * @return whether this node (and its parent) is enabled
  37195. */
  37196. isEnabled(checkAncestors?: boolean): boolean;
  37197. /** @hidden */
  37198. protected _syncParentEnabledState(): void;
  37199. /**
  37200. * Set the enabled state of this node
  37201. * @param value defines the new enabled state
  37202. */
  37203. setEnabled(value: boolean): void;
  37204. /**
  37205. * Is this node a descendant of the given node?
  37206. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37207. * @param ancestor defines the parent node to inspect
  37208. * @returns a boolean indicating if this node is a descendant of the given node
  37209. */
  37210. isDescendantOf(ancestor: Node): boolean;
  37211. /** @hidden */
  37212. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37213. /**
  37214. * Will return all nodes that have this node as ascendant
  37215. * @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
  37216. * @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
  37217. * @return all children nodes of all types
  37218. */
  37219. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37220. /**
  37221. * Get all child-meshes of this node
  37222. * @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)
  37223. * @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
  37224. * @returns an array of AbstractMesh
  37225. */
  37226. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37227. /**
  37228. * Get all direct children of this node
  37229. * @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
  37230. * @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)
  37231. * @returns an array of Node
  37232. */
  37233. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37234. /** @hidden */
  37235. _setReady(state: boolean): void;
  37236. /**
  37237. * Get an animation by name
  37238. * @param name defines the name of the animation to look for
  37239. * @returns null if not found else the requested animation
  37240. */
  37241. getAnimationByName(name: string): Nullable<Animation>;
  37242. /**
  37243. * Creates an animation range for this node
  37244. * @param name defines the name of the range
  37245. * @param from defines the starting key
  37246. * @param to defines the end key
  37247. */
  37248. createAnimationRange(name: string, from: number, to: number): void;
  37249. /**
  37250. * Delete a specific animation range
  37251. * @param name defines the name of the range to delete
  37252. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37253. */
  37254. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37255. /**
  37256. * Get an animation range by name
  37257. * @param name defines the name of the animation range to look for
  37258. * @returns null if not found else the requested animation range
  37259. */
  37260. getAnimationRange(name: string): Nullable<AnimationRange>;
  37261. /**
  37262. * Gets the list of all animation ranges defined on this node
  37263. * @returns an array
  37264. */
  37265. getAnimationRanges(): Nullable<AnimationRange>[];
  37266. /**
  37267. * Will start the animation sequence
  37268. * @param name defines the range frames for animation sequence
  37269. * @param loop defines if the animation should loop (false by default)
  37270. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37271. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37272. * @returns the object created for this animation. If range does not exist, it will return null
  37273. */
  37274. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37275. /**
  37276. * Serialize animation ranges into a JSON compatible object
  37277. * @returns serialization object
  37278. */
  37279. serializeAnimationRanges(): any;
  37280. /**
  37281. * Computes the world matrix of the node
  37282. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37283. * @returns the world matrix
  37284. */
  37285. computeWorldMatrix(force?: boolean): Matrix;
  37286. /**
  37287. * Releases resources associated with this node.
  37288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37290. */
  37291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37292. /**
  37293. * Parse animation range data from a serialization object and store them into a given node
  37294. * @param node defines where to store the animation ranges
  37295. * @param parsedNode defines the serialization object to read data from
  37296. * @param scene defines the hosting scene
  37297. */
  37298. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37299. /**
  37300. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37301. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37302. * @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
  37303. * @returns the new bounding vectors
  37304. */
  37305. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37306. min: Vector3;
  37307. max: Vector3;
  37308. };
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /**
  37313. * @hidden
  37314. */
  37315. export class _IAnimationState {
  37316. key: number;
  37317. repeatCount: number;
  37318. workValue?: any;
  37319. loopMode?: number;
  37320. offsetValue?: any;
  37321. highLimitValue?: any;
  37322. }
  37323. /**
  37324. * Class used to store any kind of animation
  37325. */
  37326. export class Animation {
  37327. /**Name of the animation */
  37328. name: string;
  37329. /**Property to animate */
  37330. targetProperty: string;
  37331. /**The frames per second of the animation */
  37332. framePerSecond: number;
  37333. /**The data type of the animation */
  37334. dataType: number;
  37335. /**The loop mode of the animation */
  37336. loopMode?: number | undefined;
  37337. /**Specifies if blending should be enabled */
  37338. enableBlending?: boolean | undefined;
  37339. /**
  37340. * Use matrix interpolation instead of using direct key value when animating matrices
  37341. */
  37342. static AllowMatricesInterpolation: boolean;
  37343. /**
  37344. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37345. */
  37346. static AllowMatrixDecomposeForInterpolation: boolean;
  37347. /** Define the Url to load snippets */
  37348. static SnippetUrl: string;
  37349. /** Snippet ID if the animation was created from the snippet server */
  37350. snippetId: string;
  37351. /**
  37352. * Stores the key frames of the animation
  37353. */
  37354. private _keys;
  37355. /**
  37356. * Stores the easing function of the animation
  37357. */
  37358. private _easingFunction;
  37359. /**
  37360. * @hidden Internal use only
  37361. */
  37362. _runtimeAnimations: RuntimeAnimation[];
  37363. /**
  37364. * The set of event that will be linked to this animation
  37365. */
  37366. private _events;
  37367. /**
  37368. * Stores an array of target property paths
  37369. */
  37370. targetPropertyPath: string[];
  37371. /**
  37372. * Stores the blending speed of the animation
  37373. */
  37374. blendingSpeed: number;
  37375. /**
  37376. * Stores the animation ranges for the animation
  37377. */
  37378. private _ranges;
  37379. /**
  37380. * @hidden Internal use
  37381. */
  37382. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37383. /**
  37384. * Sets up an animation
  37385. * @param property The property to animate
  37386. * @param animationType The animation type to apply
  37387. * @param framePerSecond The frames per second of the animation
  37388. * @param easingFunction The easing function used in the animation
  37389. * @returns The created animation
  37390. */
  37391. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37392. /**
  37393. * Create and start an animation on a node
  37394. * @param name defines the name of the global animation that will be run on all nodes
  37395. * @param node defines the root node where the animation will take place
  37396. * @param targetProperty defines property to animate
  37397. * @param framePerSecond defines the number of frame per second yo use
  37398. * @param totalFrame defines the number of frames in total
  37399. * @param from defines the initial value
  37400. * @param to defines the final value
  37401. * @param loopMode defines which loop mode you want to use (off by default)
  37402. * @param easingFunction defines the easing function to use (linear by default)
  37403. * @param onAnimationEnd defines the callback to call when animation end
  37404. * @returns the animatable created for this animation
  37405. */
  37406. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37407. /**
  37408. * Create and start an animation on a node and its descendants
  37409. * @param name defines the name of the global animation that will be run on all nodes
  37410. * @param node defines the root node where the animation will take place
  37411. * @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
  37412. * @param targetProperty defines property to animate
  37413. * @param framePerSecond defines the number of frame per second to use
  37414. * @param totalFrame defines the number of frames in total
  37415. * @param from defines the initial value
  37416. * @param to defines the final value
  37417. * @param loopMode defines which loop mode you want to use (off by default)
  37418. * @param easingFunction defines the easing function to use (linear by default)
  37419. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37420. * @returns the list of animatables created for all nodes
  37421. * @example https://www.babylonjs-playground.com/#MH0VLI
  37422. */
  37423. 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[]>;
  37424. /**
  37425. * Creates a new animation, merges it with the existing animations and starts it
  37426. * @param name Name of the animation
  37427. * @param node Node which contains the scene that begins the animations
  37428. * @param targetProperty Specifies which property to animate
  37429. * @param framePerSecond The frames per second of the animation
  37430. * @param totalFrame The total number of frames
  37431. * @param from The frame at the beginning of the animation
  37432. * @param to The frame at the end of the animation
  37433. * @param loopMode Specifies the loop mode of the animation
  37434. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37435. * @param onAnimationEnd Callback to run once the animation is complete
  37436. * @returns Nullable animation
  37437. */
  37438. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37439. /**
  37440. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37441. * @param sourceAnimation defines the Animation containing keyframes to convert
  37442. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37443. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37444. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37445. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37446. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37447. */
  37448. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37449. /**
  37450. * Transition property of an host to the target Value
  37451. * @param property The property to transition
  37452. * @param targetValue The target Value of the property
  37453. * @param host The object where the property to animate belongs
  37454. * @param scene Scene used to run the animation
  37455. * @param frameRate Framerate (in frame/s) to use
  37456. * @param transition The transition type we want to use
  37457. * @param duration The duration of the animation, in milliseconds
  37458. * @param onAnimationEnd Callback trigger at the end of the animation
  37459. * @returns Nullable animation
  37460. */
  37461. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37462. /**
  37463. * Return the array of runtime animations currently using this animation
  37464. */
  37465. get runtimeAnimations(): RuntimeAnimation[];
  37466. /**
  37467. * Specifies if any of the runtime animations are currently running
  37468. */
  37469. get hasRunningRuntimeAnimations(): boolean;
  37470. /**
  37471. * Initializes the animation
  37472. * @param name Name of the animation
  37473. * @param targetProperty Property to animate
  37474. * @param framePerSecond The frames per second of the animation
  37475. * @param dataType The data type of the animation
  37476. * @param loopMode The loop mode of the animation
  37477. * @param enableBlending Specifies if blending should be enabled
  37478. */
  37479. constructor(
  37480. /**Name of the animation */
  37481. name: string,
  37482. /**Property to animate */
  37483. targetProperty: string,
  37484. /**The frames per second of the animation */
  37485. framePerSecond: number,
  37486. /**The data type of the animation */
  37487. dataType: number,
  37488. /**The loop mode of the animation */
  37489. loopMode?: number | undefined,
  37490. /**Specifies if blending should be enabled */
  37491. enableBlending?: boolean | undefined);
  37492. /**
  37493. * Converts the animation to a string
  37494. * @param fullDetails support for multiple levels of logging within scene loading
  37495. * @returns String form of the animation
  37496. */
  37497. toString(fullDetails?: boolean): string;
  37498. /**
  37499. * Add an event to this animation
  37500. * @param event Event to add
  37501. */
  37502. addEvent(event: AnimationEvent): void;
  37503. /**
  37504. * Remove all events found at the given frame
  37505. * @param frame The frame to remove events from
  37506. */
  37507. removeEvents(frame: number): void;
  37508. /**
  37509. * Retrieves all the events from the animation
  37510. * @returns Events from the animation
  37511. */
  37512. getEvents(): AnimationEvent[];
  37513. /**
  37514. * Creates an animation range
  37515. * @param name Name of the animation range
  37516. * @param from Starting frame of the animation range
  37517. * @param to Ending frame of the animation
  37518. */
  37519. createRange(name: string, from: number, to: number): void;
  37520. /**
  37521. * Deletes an animation range by name
  37522. * @param name Name of the animation range to delete
  37523. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37524. */
  37525. deleteRange(name: string, deleteFrames?: boolean): void;
  37526. /**
  37527. * Gets the animation range by name, or null if not defined
  37528. * @param name Name of the animation range
  37529. * @returns Nullable animation range
  37530. */
  37531. getRange(name: string): Nullable<AnimationRange>;
  37532. /**
  37533. * Gets the key frames from the animation
  37534. * @returns The key frames of the animation
  37535. */
  37536. getKeys(): Array<IAnimationKey>;
  37537. /**
  37538. * Gets the highest frame rate of the animation
  37539. * @returns Highest frame rate of the animation
  37540. */
  37541. getHighestFrame(): number;
  37542. /**
  37543. * Gets the easing function of the animation
  37544. * @returns Easing function of the animation
  37545. */
  37546. getEasingFunction(): IEasingFunction;
  37547. /**
  37548. * Sets the easing function of the animation
  37549. * @param easingFunction A custom mathematical formula for animation
  37550. */
  37551. setEasingFunction(easingFunction: EasingFunction): void;
  37552. /**
  37553. * Interpolates a scalar linearly
  37554. * @param startValue Start value of the animation curve
  37555. * @param endValue End value of the animation curve
  37556. * @param gradient Scalar amount to interpolate
  37557. * @returns Interpolated scalar value
  37558. */
  37559. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37560. /**
  37561. * Interpolates a scalar cubically
  37562. * @param startValue Start value of the animation curve
  37563. * @param outTangent End tangent of the animation
  37564. * @param endValue End value of the animation curve
  37565. * @param inTangent Start tangent of the animation curve
  37566. * @param gradient Scalar amount to interpolate
  37567. * @returns Interpolated scalar value
  37568. */
  37569. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37570. /**
  37571. * Interpolates a quaternion using a spherical linear interpolation
  37572. * @param startValue Start value of the animation curve
  37573. * @param endValue End value of the animation curve
  37574. * @param gradient Scalar amount to interpolate
  37575. * @returns Interpolated quaternion value
  37576. */
  37577. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37578. /**
  37579. * Interpolates a quaternion cubically
  37580. * @param startValue Start value of the animation curve
  37581. * @param outTangent End tangent of the animation curve
  37582. * @param endValue End value of the animation curve
  37583. * @param inTangent Start tangent of the animation curve
  37584. * @param gradient Scalar amount to interpolate
  37585. * @returns Interpolated quaternion value
  37586. */
  37587. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37588. /**
  37589. * Interpolates a Vector3 linearl
  37590. * @param startValue Start value of the animation curve
  37591. * @param endValue End value of the animation curve
  37592. * @param gradient Scalar amount to interpolate
  37593. * @returns Interpolated scalar value
  37594. */
  37595. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37596. /**
  37597. * Interpolates a Vector3 cubically
  37598. * @param startValue Start value of the animation curve
  37599. * @param outTangent End tangent of the animation
  37600. * @param endValue End value of the animation curve
  37601. * @param inTangent Start tangent of the animation curve
  37602. * @param gradient Scalar amount to interpolate
  37603. * @returns InterpolatedVector3 value
  37604. */
  37605. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37606. /**
  37607. * Interpolates a Vector2 linearly
  37608. * @param startValue Start value of the animation curve
  37609. * @param endValue End value of the animation curve
  37610. * @param gradient Scalar amount to interpolate
  37611. * @returns Interpolated Vector2 value
  37612. */
  37613. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37614. /**
  37615. * Interpolates a Vector2 cubically
  37616. * @param startValue Start value of the animation curve
  37617. * @param outTangent End tangent of the animation
  37618. * @param endValue End value of the animation curve
  37619. * @param inTangent Start tangent of the animation curve
  37620. * @param gradient Scalar amount to interpolate
  37621. * @returns Interpolated Vector2 value
  37622. */
  37623. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37624. /**
  37625. * Interpolates a size linearly
  37626. * @param startValue Start value of the animation curve
  37627. * @param endValue End value of the animation curve
  37628. * @param gradient Scalar amount to interpolate
  37629. * @returns Interpolated Size value
  37630. */
  37631. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37632. /**
  37633. * Interpolates a Color3 linearly
  37634. * @param startValue Start value of the animation curve
  37635. * @param endValue End value of the animation curve
  37636. * @param gradient Scalar amount to interpolate
  37637. * @returns Interpolated Color3 value
  37638. */
  37639. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37640. /**
  37641. * Interpolates a Color4 linearly
  37642. * @param startValue Start value of the animation curve
  37643. * @param endValue End value of the animation curve
  37644. * @param gradient Scalar amount to interpolate
  37645. * @returns Interpolated Color3 value
  37646. */
  37647. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37648. /**
  37649. * @hidden Internal use only
  37650. */
  37651. _getKeyValue(value: any): any;
  37652. /**
  37653. * @hidden Internal use only
  37654. */
  37655. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37656. /**
  37657. * Defines the function to use to interpolate matrices
  37658. * @param startValue defines the start matrix
  37659. * @param endValue defines the end matrix
  37660. * @param gradient defines the gradient between both matrices
  37661. * @param result defines an optional target matrix where to store the interpolation
  37662. * @returns the interpolated matrix
  37663. */
  37664. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37665. /**
  37666. * Makes a copy of the animation
  37667. * @returns Cloned animation
  37668. */
  37669. clone(): Animation;
  37670. /**
  37671. * Sets the key frames of the animation
  37672. * @param values The animation key frames to set
  37673. */
  37674. setKeys(values: Array<IAnimationKey>): void;
  37675. /**
  37676. * Serializes the animation to an object
  37677. * @returns Serialized object
  37678. */
  37679. serialize(): any;
  37680. /**
  37681. * Float animation type
  37682. */
  37683. static readonly ANIMATIONTYPE_FLOAT: number;
  37684. /**
  37685. * Vector3 animation type
  37686. */
  37687. static readonly ANIMATIONTYPE_VECTOR3: number;
  37688. /**
  37689. * Quaternion animation type
  37690. */
  37691. static readonly ANIMATIONTYPE_QUATERNION: number;
  37692. /**
  37693. * Matrix animation type
  37694. */
  37695. static readonly ANIMATIONTYPE_MATRIX: number;
  37696. /**
  37697. * Color3 animation type
  37698. */
  37699. static readonly ANIMATIONTYPE_COLOR3: number;
  37700. /**
  37701. * Color3 animation type
  37702. */
  37703. static readonly ANIMATIONTYPE_COLOR4: number;
  37704. /**
  37705. * Vector2 animation type
  37706. */
  37707. static readonly ANIMATIONTYPE_VECTOR2: number;
  37708. /**
  37709. * Size animation type
  37710. */
  37711. static readonly ANIMATIONTYPE_SIZE: number;
  37712. /**
  37713. * Relative Loop Mode
  37714. */
  37715. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37716. /**
  37717. * Cycle Loop Mode
  37718. */
  37719. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37720. /**
  37721. * Constant Loop Mode
  37722. */
  37723. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37724. /** @hidden */
  37725. static _UniversalLerp(left: any, right: any, amount: number): any;
  37726. /**
  37727. * Parses an animation object and creates an animation
  37728. * @param parsedAnimation Parsed animation object
  37729. * @returns Animation object
  37730. */
  37731. static Parse(parsedAnimation: any): Animation;
  37732. /**
  37733. * Appends the serialized animations from the source animations
  37734. * @param source Source containing the animations
  37735. * @param destination Target to store the animations
  37736. */
  37737. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37738. /**
  37739. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37740. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37741. * @param url defines the url to load from
  37742. * @returns a promise that will resolve to the new animation or an array of animations
  37743. */
  37744. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37745. /**
  37746. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37747. * @param snippetId defines the snippet to load
  37748. * @returns a promise that will resolve to the new animation or a new array of animations
  37749. */
  37750. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37751. }
  37752. }
  37753. declare module BABYLON {
  37754. /**
  37755. * Interface containing an array of animations
  37756. */
  37757. export interface IAnimatable {
  37758. /**
  37759. * Array of animations
  37760. */
  37761. animations: Nullable<Array<Animation>>;
  37762. }
  37763. }
  37764. declare module BABYLON {
  37765. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37766. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37767. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37768. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37769. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37770. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37771. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37772. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37773. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37774. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37775. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37776. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37777. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37778. /**
  37779. * Decorator used to define property that can be serialized as reference to a camera
  37780. * @param sourceName defines the name of the property to decorate
  37781. */
  37782. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37783. /**
  37784. * Class used to help serialization objects
  37785. */
  37786. export class SerializationHelper {
  37787. /** @hidden */
  37788. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37789. /** @hidden */
  37790. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37791. /** @hidden */
  37792. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37793. /** @hidden */
  37794. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37795. /**
  37796. * Appends the serialized animations from the source animations
  37797. * @param source Source containing the animations
  37798. * @param destination Target to store the animations
  37799. */
  37800. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37801. /**
  37802. * Static function used to serialized a specific entity
  37803. * @param entity defines the entity to serialize
  37804. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37805. * @returns a JSON compatible object representing the serialization of the entity
  37806. */
  37807. static Serialize<T>(entity: T, serializationObject?: any): any;
  37808. /**
  37809. * Creates a new entity from a serialization data object
  37810. * @param creationFunction defines a function used to instanciated the new entity
  37811. * @param source defines the source serialization data
  37812. * @param scene defines the hosting scene
  37813. * @param rootUrl defines the root url for resources
  37814. * @returns a new entity
  37815. */
  37816. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37817. /**
  37818. * Clones an object
  37819. * @param creationFunction defines the function used to instanciate the new object
  37820. * @param source defines the source object
  37821. * @returns the cloned object
  37822. */
  37823. static Clone<T>(creationFunction: () => T, source: T): T;
  37824. /**
  37825. * Instanciates a new object based on a source one (some data will be shared between both object)
  37826. * @param creationFunction defines the function used to instanciate the new object
  37827. * @param source defines the source object
  37828. * @returns the new object
  37829. */
  37830. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37831. }
  37832. }
  37833. declare module BABYLON {
  37834. /**
  37835. * This is the base class of all the camera used in the application.
  37836. * @see https://doc.babylonjs.com/features/cameras
  37837. */
  37838. export class Camera extends Node {
  37839. /** @hidden */
  37840. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37841. /**
  37842. * This is the default projection mode used by the cameras.
  37843. * It helps recreating a feeling of perspective and better appreciate depth.
  37844. * This is the best way to simulate real life cameras.
  37845. */
  37846. static readonly PERSPECTIVE_CAMERA: number;
  37847. /**
  37848. * This helps creating camera with an orthographic mode.
  37849. * 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.
  37850. */
  37851. static readonly ORTHOGRAPHIC_CAMERA: number;
  37852. /**
  37853. * This is the default FOV mode for perspective cameras.
  37854. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37855. */
  37856. static readonly FOVMODE_VERTICAL_FIXED: number;
  37857. /**
  37858. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37859. */
  37860. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37861. /**
  37862. * This specifies ther is no need for a camera rig.
  37863. * Basically only one eye is rendered corresponding to the camera.
  37864. */
  37865. static readonly RIG_MODE_NONE: number;
  37866. /**
  37867. * Simulates a camera Rig with one blue eye and one red eye.
  37868. * This can be use with 3d blue and red glasses.
  37869. */
  37870. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37871. /**
  37872. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37873. */
  37874. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37875. /**
  37876. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37877. */
  37878. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37879. /**
  37880. * Defines that both eyes of the camera will be rendered over under each other.
  37881. */
  37882. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37883. /**
  37884. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37885. */
  37886. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37887. /**
  37888. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37889. */
  37890. static readonly RIG_MODE_VR: number;
  37891. /**
  37892. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37893. */
  37894. static readonly RIG_MODE_WEBVR: number;
  37895. /**
  37896. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37897. */
  37898. static readonly RIG_MODE_CUSTOM: number;
  37899. /**
  37900. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37901. */
  37902. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37903. /**
  37904. * Define the input manager associated with the camera.
  37905. */
  37906. inputs: CameraInputsManager<Camera>;
  37907. /** @hidden */
  37908. _position: Vector3;
  37909. /**
  37910. * Define the current local position of the camera in the scene
  37911. */
  37912. get position(): Vector3;
  37913. set position(newPosition: Vector3);
  37914. protected _upVector: Vector3;
  37915. /**
  37916. * The vector the camera should consider as up.
  37917. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37918. */
  37919. set upVector(vec: Vector3);
  37920. get upVector(): Vector3;
  37921. /**
  37922. * Define the current limit on the left side for an orthographic camera
  37923. * In scene unit
  37924. */
  37925. orthoLeft: Nullable<number>;
  37926. /**
  37927. * Define the current limit on the right side for an orthographic camera
  37928. * In scene unit
  37929. */
  37930. orthoRight: Nullable<number>;
  37931. /**
  37932. * Define the current limit on the bottom side for an orthographic camera
  37933. * In scene unit
  37934. */
  37935. orthoBottom: Nullable<number>;
  37936. /**
  37937. * Define the current limit on the top side for an orthographic camera
  37938. * In scene unit
  37939. */
  37940. orthoTop: Nullable<number>;
  37941. /**
  37942. * Field Of View is set in Radians. (default is 0.8)
  37943. */
  37944. fov: number;
  37945. /**
  37946. * Define the minimum distance the camera can see from.
  37947. * This is important to note that the depth buffer are not infinite and the closer it starts
  37948. * the more your scene might encounter depth fighting issue.
  37949. */
  37950. minZ: number;
  37951. /**
  37952. * Define the maximum distance the camera can see to.
  37953. * This is important to note that the depth buffer are not infinite and the further it end
  37954. * the more your scene might encounter depth fighting issue.
  37955. */
  37956. maxZ: number;
  37957. /**
  37958. * Define the default inertia of the camera.
  37959. * This helps giving a smooth feeling to the camera movement.
  37960. */
  37961. inertia: number;
  37962. /**
  37963. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37964. */
  37965. mode: number;
  37966. /**
  37967. * Define whether the camera is intermediate.
  37968. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37969. */
  37970. isIntermediate: boolean;
  37971. /**
  37972. * Define the viewport of the camera.
  37973. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37974. */
  37975. viewport: Viewport;
  37976. /**
  37977. * Restricts the camera to viewing objects with the same layerMask.
  37978. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37979. */
  37980. layerMask: number;
  37981. /**
  37982. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37983. */
  37984. fovMode: number;
  37985. /**
  37986. * Rig mode of the camera.
  37987. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37988. * This is normally controlled byt the camera themselves as internal use.
  37989. */
  37990. cameraRigMode: number;
  37991. /**
  37992. * Defines the distance between both "eyes" in case of a RIG
  37993. */
  37994. interaxialDistance: number;
  37995. /**
  37996. * Defines if stereoscopic rendering is done side by side or over under.
  37997. */
  37998. isStereoscopicSideBySide: boolean;
  37999. /**
  38000. * 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
  38001. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38002. * else in the scene. (Eg. security camera)
  38003. *
  38004. * 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)
  38005. */
  38006. customRenderTargets: RenderTargetTexture[];
  38007. /**
  38008. * When set, the camera will render to this render target instead of the default canvas
  38009. *
  38010. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38011. */
  38012. outputRenderTarget: Nullable<RenderTargetTexture>;
  38013. /**
  38014. * Observable triggered when the camera view matrix has changed.
  38015. */
  38016. onViewMatrixChangedObservable: Observable<Camera>;
  38017. /**
  38018. * Observable triggered when the camera Projection matrix has changed.
  38019. */
  38020. onProjectionMatrixChangedObservable: Observable<Camera>;
  38021. /**
  38022. * Observable triggered when the inputs have been processed.
  38023. */
  38024. onAfterCheckInputsObservable: Observable<Camera>;
  38025. /**
  38026. * Observable triggered when reset has been called and applied to the camera.
  38027. */
  38028. onRestoreStateObservable: Observable<Camera>;
  38029. /**
  38030. * Is this camera a part of a rig system?
  38031. */
  38032. isRigCamera: boolean;
  38033. /**
  38034. * If isRigCamera set to true this will be set with the parent camera.
  38035. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38036. */
  38037. rigParent?: Camera;
  38038. /** @hidden */
  38039. _cameraRigParams: any;
  38040. /** @hidden */
  38041. _rigCameras: Camera[];
  38042. /** @hidden */
  38043. _rigPostProcess: Nullable<PostProcess>;
  38044. protected _webvrViewMatrix: Matrix;
  38045. /** @hidden */
  38046. _skipRendering: boolean;
  38047. /** @hidden */
  38048. _projectionMatrix: Matrix;
  38049. /** @hidden */
  38050. _postProcesses: Nullable<PostProcess>[];
  38051. /** @hidden */
  38052. _activeMeshes: SmartArray<AbstractMesh>;
  38053. protected _globalPosition: Vector3;
  38054. /** @hidden */
  38055. _computedViewMatrix: Matrix;
  38056. private _doNotComputeProjectionMatrix;
  38057. private _transformMatrix;
  38058. private _frustumPlanes;
  38059. private _refreshFrustumPlanes;
  38060. private _storedFov;
  38061. private _stateStored;
  38062. /**
  38063. * Instantiates a new camera object.
  38064. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38065. * @see https://doc.babylonjs.com/features/cameras
  38066. * @param name Defines the name of the camera in the scene
  38067. * @param position Defines the position of the camera
  38068. * @param scene Defines the scene the camera belongs too
  38069. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38070. */
  38071. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38072. /**
  38073. * Store current camera state (fov, position, etc..)
  38074. * @returns the camera
  38075. */
  38076. storeState(): Camera;
  38077. /**
  38078. * Restores the camera state values if it has been stored. You must call storeState() first
  38079. */
  38080. protected _restoreStateValues(): boolean;
  38081. /**
  38082. * Restored camera state. You must call storeState() first.
  38083. * @returns true if restored and false otherwise
  38084. */
  38085. restoreState(): boolean;
  38086. /**
  38087. * Gets the class name of the camera.
  38088. * @returns the class name
  38089. */
  38090. getClassName(): string;
  38091. /** @hidden */
  38092. readonly _isCamera: boolean;
  38093. /**
  38094. * Gets a string representation of the camera useful for debug purpose.
  38095. * @param fullDetails Defines that a more verboe level of logging is required
  38096. * @returns the string representation
  38097. */
  38098. toString(fullDetails?: boolean): string;
  38099. /**
  38100. * Gets the current world space position of the camera.
  38101. */
  38102. get globalPosition(): Vector3;
  38103. /**
  38104. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38105. * @returns the active meshe list
  38106. */
  38107. getActiveMeshes(): SmartArray<AbstractMesh>;
  38108. /**
  38109. * Check whether a mesh is part of the current active mesh list of the camera
  38110. * @param mesh Defines the mesh to check
  38111. * @returns true if active, false otherwise
  38112. */
  38113. isActiveMesh(mesh: Mesh): boolean;
  38114. /**
  38115. * Is this camera ready to be used/rendered
  38116. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38117. * @return true if the camera is ready
  38118. */
  38119. isReady(completeCheck?: boolean): boolean;
  38120. /** @hidden */
  38121. _initCache(): void;
  38122. /** @hidden */
  38123. _updateCache(ignoreParentClass?: boolean): void;
  38124. /** @hidden */
  38125. _isSynchronized(): boolean;
  38126. /** @hidden */
  38127. _isSynchronizedViewMatrix(): boolean;
  38128. /** @hidden */
  38129. _isSynchronizedProjectionMatrix(): boolean;
  38130. /**
  38131. * Attach the input controls to a specific dom element to get the input from.
  38132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38133. */
  38134. attachControl(noPreventDefault?: boolean): void;
  38135. /**
  38136. * Attach the input controls to a specific dom element to get the input from.
  38137. * @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
  38138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38139. * BACK COMPAT SIGNATURE ONLY.
  38140. */
  38141. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38142. /**
  38143. * Detach the current controls from the specified dom element.
  38144. */
  38145. detachControl(): void;
  38146. /**
  38147. * Detach the current controls from the specified dom element.
  38148. * @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
  38149. */
  38150. detachControl(ignored: any): void;
  38151. /**
  38152. * Update the camera state according to the different inputs gathered during the frame.
  38153. */
  38154. update(): void;
  38155. /** @hidden */
  38156. _checkInputs(): void;
  38157. /** @hidden */
  38158. get rigCameras(): Camera[];
  38159. /**
  38160. * Gets the post process used by the rig cameras
  38161. */
  38162. get rigPostProcess(): Nullable<PostProcess>;
  38163. /**
  38164. * Internal, gets the first post proces.
  38165. * @returns the first post process to be run on this camera.
  38166. */
  38167. _getFirstPostProcess(): Nullable<PostProcess>;
  38168. private _cascadePostProcessesToRigCams;
  38169. /**
  38170. * Attach a post process to the camera.
  38171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38172. * @param postProcess The post process to attach to the camera
  38173. * @param insertAt The position of the post process in case several of them are in use in the scene
  38174. * @returns the position the post process has been inserted at
  38175. */
  38176. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38177. /**
  38178. * Detach a post process to the camera.
  38179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38180. * @param postProcess The post process to detach from the camera
  38181. */
  38182. detachPostProcess(postProcess: PostProcess): void;
  38183. /**
  38184. * Gets the current world matrix of the camera
  38185. */
  38186. getWorldMatrix(): Matrix;
  38187. /** @hidden */
  38188. _getViewMatrix(): Matrix;
  38189. /**
  38190. * Gets the current view matrix of the camera.
  38191. * @param force forces the camera to recompute the matrix without looking at the cached state
  38192. * @returns the view matrix
  38193. */
  38194. getViewMatrix(force?: boolean): Matrix;
  38195. /**
  38196. * Freeze the projection matrix.
  38197. * It will prevent the cache check of the camera projection compute and can speed up perf
  38198. * if no parameter of the camera are meant to change
  38199. * @param projection Defines manually a projection if necessary
  38200. */
  38201. freezeProjectionMatrix(projection?: Matrix): void;
  38202. /**
  38203. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38204. */
  38205. unfreezeProjectionMatrix(): void;
  38206. /**
  38207. * Gets the current projection matrix of the camera.
  38208. * @param force forces the camera to recompute the matrix without looking at the cached state
  38209. * @returns the projection matrix
  38210. */
  38211. getProjectionMatrix(force?: boolean): Matrix;
  38212. /**
  38213. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38214. * @returns a Matrix
  38215. */
  38216. getTransformationMatrix(): Matrix;
  38217. private _updateFrustumPlanes;
  38218. /**
  38219. * Checks if a cullable object (mesh...) is in the camera frustum
  38220. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38221. * @param target The object to check
  38222. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38223. * @returns true if the object is in frustum otherwise false
  38224. */
  38225. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38226. /**
  38227. * Checks if a cullable object (mesh...) is in the camera frustum
  38228. * Unlike isInFrustum this cheks the full bounding box
  38229. * @param target The object to check
  38230. * @returns true if the object is in frustum otherwise false
  38231. */
  38232. isCompletelyInFrustum(target: ICullable): boolean;
  38233. /**
  38234. * Gets a ray in the forward direction from the camera.
  38235. * @param length Defines the length of the ray to create
  38236. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38237. * @param origin Defines the start point of the ray which defaults to the camera position
  38238. * @returns the forward ray
  38239. */
  38240. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38241. /**
  38242. * Gets a ray in the forward direction from the camera.
  38243. * @param refRay the ray to (re)use when setting the values
  38244. * @param length Defines the length of the ray to create
  38245. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38246. * @param origin Defines the start point of the ray which defaults to the camera position
  38247. * @returns the forward ray
  38248. */
  38249. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38250. /**
  38251. * Releases resources associated with this node.
  38252. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38253. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38254. */
  38255. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38256. /** @hidden */
  38257. _isLeftCamera: boolean;
  38258. /**
  38259. * Gets the left camera of a rig setup in case of Rigged Camera
  38260. */
  38261. get isLeftCamera(): boolean;
  38262. /** @hidden */
  38263. _isRightCamera: boolean;
  38264. /**
  38265. * Gets the right camera of a rig setup in case of Rigged Camera
  38266. */
  38267. get isRightCamera(): boolean;
  38268. /**
  38269. * Gets the left camera of a rig setup in case of Rigged Camera
  38270. */
  38271. get leftCamera(): Nullable<FreeCamera>;
  38272. /**
  38273. * Gets the right camera of a rig setup in case of Rigged Camera
  38274. */
  38275. get rightCamera(): Nullable<FreeCamera>;
  38276. /**
  38277. * Gets the left camera target of a rig setup in case of Rigged Camera
  38278. * @returns the target position
  38279. */
  38280. getLeftTarget(): Nullable<Vector3>;
  38281. /**
  38282. * Gets the right camera target of a rig setup in case of Rigged Camera
  38283. * @returns the target position
  38284. */
  38285. getRightTarget(): Nullable<Vector3>;
  38286. /**
  38287. * @hidden
  38288. */
  38289. setCameraRigMode(mode: number, rigParams: any): void;
  38290. /** @hidden */
  38291. static _setStereoscopicRigMode(camera: Camera): void;
  38292. /** @hidden */
  38293. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38294. /** @hidden */
  38295. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38296. /** @hidden */
  38297. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38298. /** @hidden */
  38299. _getVRProjectionMatrix(): Matrix;
  38300. protected _updateCameraRotationMatrix(): void;
  38301. protected _updateWebVRCameraRotationMatrix(): void;
  38302. /**
  38303. * This function MUST be overwritten by the different WebVR cameras available.
  38304. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38305. * @hidden
  38306. */
  38307. _getWebVRProjectionMatrix(): Matrix;
  38308. /**
  38309. * This function MUST be overwritten by the different WebVR cameras available.
  38310. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38311. * @hidden
  38312. */
  38313. _getWebVRViewMatrix(): Matrix;
  38314. /** @hidden */
  38315. setCameraRigParameter(name: string, value: any): void;
  38316. /**
  38317. * needs to be overridden by children so sub has required properties to be copied
  38318. * @hidden
  38319. */
  38320. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38321. /**
  38322. * May need to be overridden by children
  38323. * @hidden
  38324. */
  38325. _updateRigCameras(): void;
  38326. /** @hidden */
  38327. _setupInputs(): void;
  38328. /**
  38329. * Serialiaze the camera setup to a json represention
  38330. * @returns the JSON representation
  38331. */
  38332. serialize(): any;
  38333. /**
  38334. * Clones the current camera.
  38335. * @param name The cloned camera name
  38336. * @returns the cloned camera
  38337. */
  38338. clone(name: string): Camera;
  38339. /**
  38340. * Gets the direction of the camera relative to a given local axis.
  38341. * @param localAxis Defines the reference axis to provide a relative direction.
  38342. * @return the direction
  38343. */
  38344. getDirection(localAxis: Vector3): Vector3;
  38345. /**
  38346. * Returns the current camera absolute rotation
  38347. */
  38348. get absoluteRotation(): Quaternion;
  38349. /**
  38350. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38351. * @param localAxis Defines the reference axis to provide a relative direction.
  38352. * @param result Defines the vector to store the result in
  38353. */
  38354. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38355. /**
  38356. * Gets a camera constructor for a given camera type
  38357. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38358. * @param name The name of the camera the result will be able to instantiate
  38359. * @param scene The scene the result will construct the camera in
  38360. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38361. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38362. * @returns a factory method to construc the camera
  38363. */
  38364. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38365. /**
  38366. * Compute the world matrix of the camera.
  38367. * @returns the camera world matrix
  38368. */
  38369. computeWorldMatrix(): Matrix;
  38370. /**
  38371. * Parse a JSON and creates the camera from the parsed information
  38372. * @param parsedCamera The JSON to parse
  38373. * @param scene The scene to instantiate the camera in
  38374. * @returns the newly constructed camera
  38375. */
  38376. static Parse(parsedCamera: any, scene: Scene): Camera;
  38377. }
  38378. }
  38379. declare module BABYLON {
  38380. /**
  38381. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38382. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38383. */
  38384. export class PostProcessManager {
  38385. private _scene;
  38386. private _indexBuffer;
  38387. private _vertexBuffers;
  38388. /**
  38389. * Creates a new instance PostProcess
  38390. * @param scene The scene that the post process is associated with.
  38391. */
  38392. constructor(scene: Scene);
  38393. private _prepareBuffers;
  38394. private _buildIndexBuffer;
  38395. /**
  38396. * Rebuilds the vertex buffers of the manager.
  38397. * @hidden
  38398. */
  38399. _rebuild(): void;
  38400. /**
  38401. * Prepares a frame to be run through a post process.
  38402. * @param sourceTexture The input texture to the post procesess. (default: null)
  38403. * @param postProcesses An array of post processes to be run. (default: null)
  38404. * @returns True if the post processes were able to be run.
  38405. * @hidden
  38406. */
  38407. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38408. /**
  38409. * Manually render a set of post processes to a texture.
  38410. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38411. * @param postProcesses An array of post processes to be run.
  38412. * @param targetTexture The target texture to render to.
  38413. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38414. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38415. * @param lodLevel defines which lod of the texture to render to
  38416. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38417. */
  38418. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38419. /**
  38420. * Finalize the result of the output of the postprocesses.
  38421. * @param doNotPresent If true the result will not be displayed to the screen.
  38422. * @param targetTexture The target texture to render to.
  38423. * @param faceIndex The index of the face to bind the target texture to.
  38424. * @param postProcesses The array of post processes to render.
  38425. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38426. * @hidden
  38427. */
  38428. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38429. /**
  38430. * Disposes of the post process manager.
  38431. */
  38432. dispose(): void;
  38433. }
  38434. }
  38435. declare module BABYLON {
  38436. /**
  38437. * This Helps creating a texture that will be created from a camera in your scene.
  38438. * It is basically a dynamic texture that could be used to create special effects for instance.
  38439. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38440. */
  38441. export class RenderTargetTexture extends Texture {
  38442. /**
  38443. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38444. */
  38445. static readonly REFRESHRATE_RENDER_ONCE: number;
  38446. /**
  38447. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38448. */
  38449. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38450. /**
  38451. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38452. * the central point of your effect and can save a lot of performances.
  38453. */
  38454. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38455. /**
  38456. * Use this predicate to dynamically define the list of mesh you want to render.
  38457. * If set, the renderList property will be overwritten.
  38458. */
  38459. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38460. private _renderList;
  38461. /**
  38462. * Use this list to define the list of mesh you want to render.
  38463. */
  38464. get renderList(): Nullable<Array<AbstractMesh>>;
  38465. set renderList(value: Nullable<Array<AbstractMesh>>);
  38466. /**
  38467. * Use this function to overload the renderList array at rendering time.
  38468. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38469. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38470. * the cube (if the RTT is a cube, else layerOrFace=0).
  38471. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38472. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38473. * hold dummy elements!
  38474. */
  38475. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38476. private _hookArray;
  38477. /**
  38478. * Define if particles should be rendered in your texture.
  38479. */
  38480. renderParticles: boolean;
  38481. /**
  38482. * Define if sprites should be rendered in your texture.
  38483. */
  38484. renderSprites: boolean;
  38485. /**
  38486. * Define the camera used to render the texture.
  38487. */
  38488. activeCamera: Nullable<Camera>;
  38489. /**
  38490. * Override the mesh isReady function with your own one.
  38491. */
  38492. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38493. /**
  38494. * Override the render function of the texture with your own one.
  38495. */
  38496. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38497. /**
  38498. * Define if camera post processes should be use while rendering the texture.
  38499. */
  38500. useCameraPostProcesses: boolean;
  38501. /**
  38502. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38503. */
  38504. ignoreCameraViewport: boolean;
  38505. private _postProcessManager;
  38506. private _postProcesses;
  38507. private _resizeObserver;
  38508. /**
  38509. * An event triggered when the texture is unbind.
  38510. */
  38511. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38512. /**
  38513. * An event triggered when the texture is unbind.
  38514. */
  38515. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38516. private _onAfterUnbindObserver;
  38517. /**
  38518. * Set a after unbind callback in the texture.
  38519. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38520. */
  38521. set onAfterUnbind(callback: () => void);
  38522. /**
  38523. * An event triggered before rendering the texture
  38524. */
  38525. onBeforeRenderObservable: Observable<number>;
  38526. private _onBeforeRenderObserver;
  38527. /**
  38528. * Set a before render callback in the texture.
  38529. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38530. */
  38531. set onBeforeRender(callback: (faceIndex: number) => void);
  38532. /**
  38533. * An event triggered after rendering the texture
  38534. */
  38535. onAfterRenderObservable: Observable<number>;
  38536. private _onAfterRenderObserver;
  38537. /**
  38538. * Set a after render callback in the texture.
  38539. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38540. */
  38541. set onAfterRender(callback: (faceIndex: number) => void);
  38542. /**
  38543. * An event triggered after the texture clear
  38544. */
  38545. onClearObservable: Observable<Engine>;
  38546. private _onClearObserver;
  38547. /**
  38548. * Set a clear callback in the texture.
  38549. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38550. */
  38551. set onClear(callback: (Engine: Engine) => void);
  38552. /**
  38553. * An event triggered when the texture is resized.
  38554. */
  38555. onResizeObservable: Observable<RenderTargetTexture>;
  38556. /**
  38557. * Define the clear color of the Render Target if it should be different from the scene.
  38558. */
  38559. clearColor: Color4;
  38560. protected _size: number | {
  38561. width: number;
  38562. height: number;
  38563. layers?: number;
  38564. };
  38565. protected _initialSizeParameter: number | {
  38566. width: number;
  38567. height: number;
  38568. } | {
  38569. ratio: number;
  38570. };
  38571. protected _sizeRatio: Nullable<number>;
  38572. /** @hidden */
  38573. _generateMipMaps: boolean;
  38574. protected _renderingManager: RenderingManager;
  38575. /** @hidden */
  38576. _waitingRenderList?: string[];
  38577. protected _doNotChangeAspectRatio: boolean;
  38578. protected _currentRefreshId: number;
  38579. protected _refreshRate: number;
  38580. protected _textureMatrix: Matrix;
  38581. protected _samples: number;
  38582. protected _renderTargetOptions: RenderTargetCreationOptions;
  38583. /**
  38584. * Gets render target creation options that were used.
  38585. */
  38586. get renderTargetOptions(): RenderTargetCreationOptions;
  38587. protected _onRatioRescale(): void;
  38588. /**
  38589. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38590. * It must define where the camera used to render the texture is set
  38591. */
  38592. boundingBoxPosition: Vector3;
  38593. private _boundingBoxSize;
  38594. /**
  38595. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38596. * When defined, the cubemap will switch to local mode
  38597. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38598. * @example https://www.babylonjs-playground.com/#RNASML
  38599. */
  38600. set boundingBoxSize(value: Vector3);
  38601. get boundingBoxSize(): Vector3;
  38602. /**
  38603. * In case the RTT has been created with a depth texture, get the associated
  38604. * depth texture.
  38605. * Otherwise, return null.
  38606. */
  38607. get depthStencilTexture(): Nullable<InternalTexture>;
  38608. /**
  38609. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38610. * or used a shadow, depth texture...
  38611. * @param name The friendly name of the texture
  38612. * @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)
  38613. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38614. * @param generateMipMaps True if mip maps need to be generated after render.
  38615. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38616. * @param type The type of the buffer in the RTT (int, half float, float...)
  38617. * @param isCube True if a cube texture needs to be created
  38618. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38619. * @param generateDepthBuffer True to generate a depth buffer
  38620. * @param generateStencilBuffer True to generate a stencil buffer
  38621. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38622. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38623. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38624. * @param samples sample count to use when creating the RTT
  38625. */
  38626. constructor(name: string, size: number | {
  38627. width: number;
  38628. height: number;
  38629. layers?: number;
  38630. } | {
  38631. ratio: number;
  38632. }, 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);
  38633. /**
  38634. * Creates a depth stencil texture.
  38635. * This is only available in WebGL 2 or with the depth texture extension available.
  38636. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38637. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38638. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38639. * @param samples sample count of the depth/stencil texture
  38640. */
  38641. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38642. private _processSizeParameter;
  38643. /**
  38644. * Define the number of samples to use in case of MSAA.
  38645. * It defaults to one meaning no MSAA has been enabled.
  38646. */
  38647. get samples(): number;
  38648. set samples(value: number);
  38649. /**
  38650. * Resets the refresh counter of the texture and start bak from scratch.
  38651. * Could be useful to regenerate the texture if it is setup to render only once.
  38652. */
  38653. resetRefreshCounter(): void;
  38654. /**
  38655. * Define the refresh rate of the texture or the rendering frequency.
  38656. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38657. */
  38658. get refreshRate(): number;
  38659. set refreshRate(value: number);
  38660. /**
  38661. * Adds a post process to the render target rendering passes.
  38662. * @param postProcess define the post process to add
  38663. */
  38664. addPostProcess(postProcess: PostProcess): void;
  38665. /**
  38666. * Clear all the post processes attached to the render target
  38667. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38668. */
  38669. clearPostProcesses(dispose?: boolean): void;
  38670. /**
  38671. * Remove one of the post process from the list of attached post processes to the texture
  38672. * @param postProcess define the post process to remove from the list
  38673. */
  38674. removePostProcess(postProcess: PostProcess): void;
  38675. /** @hidden */
  38676. _shouldRender(): boolean;
  38677. /**
  38678. * Gets the actual render size of the texture.
  38679. * @returns the width of the render size
  38680. */
  38681. getRenderSize(): number;
  38682. /**
  38683. * Gets the actual render width of the texture.
  38684. * @returns the width of the render size
  38685. */
  38686. getRenderWidth(): number;
  38687. /**
  38688. * Gets the actual render height of the texture.
  38689. * @returns the height of the render size
  38690. */
  38691. getRenderHeight(): number;
  38692. /**
  38693. * Gets the actual number of layers of the texture.
  38694. * @returns the number of layers
  38695. */
  38696. getRenderLayers(): number;
  38697. /**
  38698. * Get if the texture can be rescaled or not.
  38699. */
  38700. get canRescale(): boolean;
  38701. /**
  38702. * Resize the texture using a ratio.
  38703. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38704. */
  38705. scale(ratio: number): void;
  38706. /**
  38707. * Get the texture reflection matrix used to rotate/transform the reflection.
  38708. * @returns the reflection matrix
  38709. */
  38710. getReflectionTextureMatrix(): Matrix;
  38711. /**
  38712. * Resize the texture to a new desired size.
  38713. * Be carrefull as it will recreate all the data in the new texture.
  38714. * @param size Define the new size. It can be:
  38715. * - a number for squared texture,
  38716. * - an object containing { width: number, height: number }
  38717. * - or an object containing a ratio { ratio: number }
  38718. */
  38719. resize(size: number | {
  38720. width: number;
  38721. height: number;
  38722. } | {
  38723. ratio: number;
  38724. }): void;
  38725. private _defaultRenderListPrepared;
  38726. /**
  38727. * Renders all the objects from the render list into the texture.
  38728. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38729. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38730. */
  38731. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38732. private _bestReflectionRenderTargetDimension;
  38733. private _prepareRenderingManager;
  38734. /**
  38735. * @hidden
  38736. * @param faceIndex face index to bind to if this is a cubetexture
  38737. * @param layer defines the index of the texture to bind in the array
  38738. */
  38739. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38741. private renderToTarget;
  38742. /**
  38743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38744. * This allowed control for front to back rendering or reversly depending of the special needs.
  38745. *
  38746. * @param renderingGroupId The rendering group id corresponding to its index
  38747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38750. */
  38751. 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;
  38752. /**
  38753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38754. *
  38755. * @param renderingGroupId The rendering group id corresponding to its index
  38756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38757. */
  38758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38759. /**
  38760. * Clones the texture.
  38761. * @returns the cloned texture
  38762. */
  38763. clone(): RenderTargetTexture;
  38764. /**
  38765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38766. * @returns The JSON representation of the texture
  38767. */
  38768. serialize(): any;
  38769. /**
  38770. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38771. */
  38772. disposeFramebufferObjects(): void;
  38773. /**
  38774. * Dispose the texture and release its associated resources.
  38775. */
  38776. dispose(): void;
  38777. /** @hidden */
  38778. _rebuild(): void;
  38779. /**
  38780. * Clear the info related to rendering groups preventing retention point in material dispose.
  38781. */
  38782. freeRenderingGroups(): void;
  38783. /**
  38784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38785. * @returns the view count
  38786. */
  38787. getViewCount(): number;
  38788. }
  38789. }
  38790. declare module BABYLON {
  38791. /**
  38792. * Options to be used when creating an effect.
  38793. */
  38794. export interface IEffectCreationOptions {
  38795. /**
  38796. * Atrributes that will be used in the shader.
  38797. */
  38798. attributes: string[];
  38799. /**
  38800. * Uniform varible names that will be set in the shader.
  38801. */
  38802. uniformsNames: string[];
  38803. /**
  38804. * Uniform buffer variable names that will be set in the shader.
  38805. */
  38806. uniformBuffersNames: string[];
  38807. /**
  38808. * Sampler texture variable names that will be set in the shader.
  38809. */
  38810. samplers: string[];
  38811. /**
  38812. * Define statements that will be set in the shader.
  38813. */
  38814. defines: any;
  38815. /**
  38816. * Possible fallbacks for this effect to improve performance when needed.
  38817. */
  38818. fallbacks: Nullable<IEffectFallbacks>;
  38819. /**
  38820. * Callback that will be called when the shader is compiled.
  38821. */
  38822. onCompiled: Nullable<(effect: Effect) => void>;
  38823. /**
  38824. * Callback that will be called if an error occurs during shader compilation.
  38825. */
  38826. onError: Nullable<(effect: Effect, errors: string) => void>;
  38827. /**
  38828. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38829. */
  38830. indexParameters?: any;
  38831. /**
  38832. * Max number of lights that can be used in the shader.
  38833. */
  38834. maxSimultaneousLights?: number;
  38835. /**
  38836. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38837. */
  38838. transformFeedbackVaryings?: Nullable<string[]>;
  38839. /**
  38840. * 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
  38841. */
  38842. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38843. /**
  38844. * Is this effect rendering to several color attachments ?
  38845. */
  38846. multiTarget?: boolean;
  38847. }
  38848. /**
  38849. * Effect containing vertex and fragment shader that can be executed on an object.
  38850. */
  38851. export class Effect implements IDisposable {
  38852. /**
  38853. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38854. */
  38855. static ShadersRepository: string;
  38856. /**
  38857. * Enable logging of the shader code when a compilation error occurs
  38858. */
  38859. static LogShaderCodeOnCompilationError: boolean;
  38860. /**
  38861. * Name of the effect.
  38862. */
  38863. name: any;
  38864. /**
  38865. * String container all the define statements that should be set on the shader.
  38866. */
  38867. defines: string;
  38868. /**
  38869. * Callback that will be called when the shader is compiled.
  38870. */
  38871. onCompiled: Nullable<(effect: Effect) => void>;
  38872. /**
  38873. * Callback that will be called if an error occurs during shader compilation.
  38874. */
  38875. onError: Nullable<(effect: Effect, errors: string) => void>;
  38876. /**
  38877. * Callback that will be called when effect is bound.
  38878. */
  38879. onBind: Nullable<(effect: Effect) => void>;
  38880. /**
  38881. * Unique ID of the effect.
  38882. */
  38883. uniqueId: number;
  38884. /**
  38885. * Observable that will be called when the shader is compiled.
  38886. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38887. */
  38888. onCompileObservable: Observable<Effect>;
  38889. /**
  38890. * Observable that will be called if an error occurs during shader compilation.
  38891. */
  38892. onErrorObservable: Observable<Effect>;
  38893. /** @hidden */
  38894. _onBindObservable: Nullable<Observable<Effect>>;
  38895. /**
  38896. * @hidden
  38897. * Specifies if the effect was previously ready
  38898. */
  38899. _wasPreviouslyReady: boolean;
  38900. /**
  38901. * Observable that will be called when effect is bound.
  38902. */
  38903. get onBindObservable(): Observable<Effect>;
  38904. /** @hidden */
  38905. _bonesComputationForcedToCPU: boolean;
  38906. /** @hidden */
  38907. _uniformBuffersNames: {
  38908. [key: string]: number;
  38909. };
  38910. /** @hidden */
  38911. _samplerList: string[];
  38912. /** @hidden */
  38913. _multiTarget: boolean;
  38914. private static _uniqueIdSeed;
  38915. private _engine;
  38916. private _uniformBuffersNamesList;
  38917. private _uniformsNames;
  38918. private _samplers;
  38919. private _isReady;
  38920. private _compilationError;
  38921. private _allFallbacksProcessed;
  38922. private _attributesNames;
  38923. private _attributes;
  38924. private _attributeLocationByName;
  38925. private _uniforms;
  38926. /**
  38927. * Key for the effect.
  38928. * @hidden
  38929. */
  38930. _key: string;
  38931. private _indexParameters;
  38932. private _fallbacks;
  38933. private _vertexSourceCodeOverride;
  38934. private _fragmentSourceCodeOverride;
  38935. private _transformFeedbackVaryings;
  38936. /**
  38937. * Compiled shader to webGL program.
  38938. * @hidden
  38939. */
  38940. _pipelineContext: Nullable<IPipelineContext>;
  38941. /** @hidden */
  38942. _vertexSourceCode: string;
  38943. /** @hidden */
  38944. _fragmentSourceCode: string;
  38945. /** @hidden */
  38946. private _rawVertexSourceCode;
  38947. /** @hidden */
  38948. private _rawFragmentSourceCode;
  38949. private static _baseCache;
  38950. private _processingContext;
  38951. /**
  38952. * Instantiates an effect.
  38953. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38954. * @param baseName Name of the effect.
  38955. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38956. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38957. * @param samplers List of sampler variables that will be passed to the shader.
  38958. * @param engine Engine to be used to render the effect
  38959. * @param defines Define statements to be added to the shader.
  38960. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38961. * @param onCompiled Callback that will be called when the shader is compiled.
  38962. * @param onError Callback that will be called if an error occurs during shader compilation.
  38963. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38964. * @param key Effect Key identifying uniquely compiled shader variants
  38965. */
  38966. 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);
  38967. private _useFinalCode;
  38968. /**
  38969. * Unique key for this effect
  38970. */
  38971. get key(): string;
  38972. /**
  38973. * If the effect has been compiled and prepared.
  38974. * @returns if the effect is compiled and prepared.
  38975. */
  38976. isReady(): boolean;
  38977. private _isReadyInternal;
  38978. /**
  38979. * The engine the effect was initialized with.
  38980. * @returns the engine.
  38981. */
  38982. getEngine(): Engine;
  38983. /**
  38984. * The pipeline context for this effect
  38985. * @returns the associated pipeline context
  38986. */
  38987. getPipelineContext(): Nullable<IPipelineContext>;
  38988. /**
  38989. * The set of names of attribute variables for the shader.
  38990. * @returns An array of attribute names.
  38991. */
  38992. getAttributesNames(): string[];
  38993. /**
  38994. * Returns the attribute at the given index.
  38995. * @param index The index of the attribute.
  38996. * @returns The location of the attribute.
  38997. */
  38998. getAttributeLocation(index: number): number;
  38999. /**
  39000. * Returns the attribute based on the name of the variable.
  39001. * @param name of the attribute to look up.
  39002. * @returns the attribute location.
  39003. */
  39004. getAttributeLocationByName(name: string): number;
  39005. /**
  39006. * The number of attributes.
  39007. * @returns the numnber of attributes.
  39008. */
  39009. getAttributesCount(): number;
  39010. /**
  39011. * Gets the index of a uniform variable.
  39012. * @param uniformName of the uniform to look up.
  39013. * @returns the index.
  39014. */
  39015. getUniformIndex(uniformName: string): number;
  39016. /**
  39017. * Returns the attribute based on the name of the variable.
  39018. * @param uniformName of the uniform to look up.
  39019. * @returns the location of the uniform.
  39020. */
  39021. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39022. /**
  39023. * Returns an array of sampler variable names
  39024. * @returns The array of sampler variable names.
  39025. */
  39026. getSamplers(): string[];
  39027. /**
  39028. * Returns an array of uniform variable names
  39029. * @returns The array of uniform variable names.
  39030. */
  39031. getUniformNames(): string[];
  39032. /**
  39033. * Returns an array of uniform buffer variable names
  39034. * @returns The array of uniform buffer variable names.
  39035. */
  39036. getUniformBuffersNames(): string[];
  39037. /**
  39038. * Returns the index parameters used to create the effect
  39039. * @returns The index parameters object
  39040. */
  39041. getIndexParameters(): any;
  39042. /**
  39043. * The error from the last compilation.
  39044. * @returns the error string.
  39045. */
  39046. getCompilationError(): string;
  39047. /**
  39048. * Gets a boolean indicating that all fallbacks were used during compilation
  39049. * @returns true if all fallbacks were used
  39050. */
  39051. allFallbacksProcessed(): boolean;
  39052. /**
  39053. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39054. * @param func The callback to be used.
  39055. */
  39056. executeWhenCompiled(func: (effect: Effect) => void): void;
  39057. private _checkIsReady;
  39058. private _loadShader;
  39059. /**
  39060. * Gets the vertex shader source code of this effect
  39061. */
  39062. get vertexSourceCode(): string;
  39063. /**
  39064. * Gets the fragment shader source code of this effect
  39065. */
  39066. get fragmentSourceCode(): string;
  39067. /**
  39068. * Gets the vertex shader source code before it has been processed by the preprocessor
  39069. */
  39070. get rawVertexSourceCode(): string;
  39071. /**
  39072. * Gets the fragment shader source code before it has been processed by the preprocessor
  39073. */
  39074. get rawFragmentSourceCode(): string;
  39075. /**
  39076. * Recompiles the webGL program
  39077. * @param vertexSourceCode The source code for the vertex shader.
  39078. * @param fragmentSourceCode The source code for the fragment shader.
  39079. * @param onCompiled Callback called when completed.
  39080. * @param onError Callback called on error.
  39081. * @hidden
  39082. */
  39083. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39084. /**
  39085. * Prepares the effect
  39086. * @hidden
  39087. */
  39088. _prepareEffect(): void;
  39089. private _getShaderCodeAndErrorLine;
  39090. private _processCompilationErrors;
  39091. /**
  39092. * Checks if the effect is supported. (Must be called after compilation)
  39093. */
  39094. get isSupported(): boolean;
  39095. /**
  39096. * Binds a texture to the engine to be used as output of the shader.
  39097. * @param channel Name of the output variable.
  39098. * @param texture Texture to bind.
  39099. * @hidden
  39100. */
  39101. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39102. /**
  39103. * Sets a texture on the engine to be used in the shader.
  39104. * @param channel Name of the sampler variable.
  39105. * @param texture Texture to set.
  39106. */
  39107. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39108. /**
  39109. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39110. * @param channel Name of the sampler variable.
  39111. * @param texture Texture to set.
  39112. */
  39113. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39114. /**
  39115. * Sets an array of textures on the engine to be used in the shader.
  39116. * @param channel Name of the variable.
  39117. * @param textures Textures to set.
  39118. */
  39119. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39120. /**
  39121. * 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)
  39122. * @param channel Name of the sampler variable.
  39123. * @param postProcess Post process to get the input texture from.
  39124. */
  39125. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39126. /**
  39127. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39128. * 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)
  39129. * @param channel Name of the sampler variable.
  39130. * @param postProcess Post process to get the output texture from.
  39131. */
  39132. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39133. /**
  39134. * Binds a buffer to a uniform.
  39135. * @param buffer Buffer to bind.
  39136. * @param name Name of the uniform variable to bind to.
  39137. */
  39138. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39139. /**
  39140. * Binds block to a uniform.
  39141. * @param blockName Name of the block to bind.
  39142. * @param index Index to bind.
  39143. */
  39144. bindUniformBlock(blockName: string, index: number): void;
  39145. /**
  39146. * Sets an interger value on a uniform variable.
  39147. * @param uniformName Name of the variable.
  39148. * @param value Value to be set.
  39149. * @returns this effect.
  39150. */
  39151. setInt(uniformName: string, value: number): Effect;
  39152. /**
  39153. * Sets an int2 value on a uniform variable.
  39154. * @param uniformName Name of the variable.
  39155. * @param x First int in int2.
  39156. * @param y Second int in int2.
  39157. * @returns this effect.
  39158. */
  39159. setInt2(uniformName: string, x: number, y: number): Effect;
  39160. /**
  39161. * Sets an int3 value on a uniform variable.
  39162. * @param uniformName Name of the variable.
  39163. * @param x First int in int3.
  39164. * @param y Second int in int3.
  39165. * @param z Third int in int3.
  39166. * @returns this effect.
  39167. */
  39168. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39169. /**
  39170. * Sets an int4 value on a uniform variable.
  39171. * @param uniformName Name of the variable.
  39172. * @param x First int in int4.
  39173. * @param y Second int in int4.
  39174. * @param z Third int in int4.
  39175. * @param w Fourth int in int4.
  39176. * @returns this effect.
  39177. */
  39178. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39179. /**
  39180. * Sets an int array on a uniform variable.
  39181. * @param uniformName Name of the variable.
  39182. * @param array array to be set.
  39183. * @returns this effect.
  39184. */
  39185. setIntArray(uniformName: string, array: Int32Array): Effect;
  39186. /**
  39187. * 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)
  39188. * @param uniformName Name of the variable.
  39189. * @param array array to be set.
  39190. * @returns this effect.
  39191. */
  39192. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39193. /**
  39194. * 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)
  39195. * @param uniformName Name of the variable.
  39196. * @param array array to be set.
  39197. * @returns this effect.
  39198. */
  39199. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39200. /**
  39201. * 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)
  39202. * @param uniformName Name of the variable.
  39203. * @param array array to be set.
  39204. * @returns this effect.
  39205. */
  39206. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39207. /**
  39208. * Sets an float array on a uniform variable.
  39209. * @param uniformName Name of the variable.
  39210. * @param array array to be set.
  39211. * @returns this effect.
  39212. */
  39213. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39214. /**
  39215. * 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)
  39216. * @param uniformName Name of the variable.
  39217. * @param array array to be set.
  39218. * @returns this effect.
  39219. */
  39220. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39221. /**
  39222. * 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)
  39223. * @param uniformName Name of the variable.
  39224. * @param array array to be set.
  39225. * @returns this effect.
  39226. */
  39227. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39228. /**
  39229. * 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)
  39230. * @param uniformName Name of the variable.
  39231. * @param array array to be set.
  39232. * @returns this effect.
  39233. */
  39234. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39235. /**
  39236. * Sets an array on a uniform variable.
  39237. * @param uniformName Name of the variable.
  39238. * @param array array to be set.
  39239. * @returns this effect.
  39240. */
  39241. setArray(uniformName: string, array: number[]): Effect;
  39242. /**
  39243. * 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)
  39244. * @param uniformName Name of the variable.
  39245. * @param array array to be set.
  39246. * @returns this effect.
  39247. */
  39248. setArray2(uniformName: string, array: number[]): Effect;
  39249. /**
  39250. * 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)
  39251. * @param uniformName Name of the variable.
  39252. * @param array array to be set.
  39253. * @returns this effect.
  39254. */
  39255. setArray3(uniformName: string, array: number[]): Effect;
  39256. /**
  39257. * 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)
  39258. * @param uniformName Name of the variable.
  39259. * @param array array to be set.
  39260. * @returns this effect.
  39261. */
  39262. setArray4(uniformName: string, array: number[]): Effect;
  39263. /**
  39264. * Sets matrices on a uniform variable.
  39265. * @param uniformName Name of the variable.
  39266. * @param matrices matrices to be set.
  39267. * @returns this effect.
  39268. */
  39269. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39270. /**
  39271. * Sets matrix on a uniform variable.
  39272. * @param uniformName Name of the variable.
  39273. * @param matrix matrix to be set.
  39274. * @returns this effect.
  39275. */
  39276. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39277. /**
  39278. * 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)
  39279. * @param uniformName Name of the variable.
  39280. * @param matrix matrix to be set.
  39281. * @returns this effect.
  39282. */
  39283. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39284. /**
  39285. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39286. * @param uniformName Name of the variable.
  39287. * @param matrix matrix to be set.
  39288. * @returns this effect.
  39289. */
  39290. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39291. /**
  39292. * Sets a float on a uniform variable.
  39293. * @param uniformName Name of the variable.
  39294. * @param value value to be set.
  39295. * @returns this effect.
  39296. */
  39297. setFloat(uniformName: string, value: number): Effect;
  39298. /**
  39299. * Sets a boolean on a uniform variable.
  39300. * @param uniformName Name of the variable.
  39301. * @param bool value to be set.
  39302. * @returns this effect.
  39303. */
  39304. setBool(uniformName: string, bool: boolean): Effect;
  39305. /**
  39306. * Sets a Vector2 on a uniform variable.
  39307. * @param uniformName Name of the variable.
  39308. * @param vector2 vector2 to be set.
  39309. * @returns this effect.
  39310. */
  39311. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39312. /**
  39313. * Sets a float2 on a uniform variable.
  39314. * @param uniformName Name of the variable.
  39315. * @param x First float in float2.
  39316. * @param y Second float in float2.
  39317. * @returns this effect.
  39318. */
  39319. setFloat2(uniformName: string, x: number, y: number): Effect;
  39320. /**
  39321. * Sets a Vector3 on a uniform variable.
  39322. * @param uniformName Name of the variable.
  39323. * @param vector3 Value to be set.
  39324. * @returns this effect.
  39325. */
  39326. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39327. /**
  39328. * Sets a float3 on a uniform variable.
  39329. * @param uniformName Name of the variable.
  39330. * @param x First float in float3.
  39331. * @param y Second float in float3.
  39332. * @param z Third float in float3.
  39333. * @returns this effect.
  39334. */
  39335. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39336. /**
  39337. * Sets a Vector4 on a uniform variable.
  39338. * @param uniformName Name of the variable.
  39339. * @param vector4 Value to be set.
  39340. * @returns this effect.
  39341. */
  39342. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39343. /**
  39344. * Sets a float4 on a uniform variable.
  39345. * @param uniformName Name of the variable.
  39346. * @param x First float in float4.
  39347. * @param y Second float in float4.
  39348. * @param z Third float in float4.
  39349. * @param w Fourth float in float4.
  39350. * @returns this effect.
  39351. */
  39352. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39353. /**
  39354. * Sets a Color3 on a uniform variable.
  39355. * @param uniformName Name of the variable.
  39356. * @param color3 Value to be set.
  39357. * @returns this effect.
  39358. */
  39359. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39360. /**
  39361. * Sets a Color4 on a uniform variable.
  39362. * @param uniformName Name of the variable.
  39363. * @param color3 Value to be set.
  39364. * @param alpha Alpha value to be set.
  39365. * @returns this effect.
  39366. */
  39367. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39368. /**
  39369. * Sets a Color4 on a uniform variable
  39370. * @param uniformName defines the name of the variable
  39371. * @param color4 defines the value to be set
  39372. * @returns this effect.
  39373. */
  39374. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39375. /**
  39376. * Release all associated resources.
  39377. **/
  39378. dispose(): void;
  39379. /**
  39380. * This function will add a new shader to the shader store
  39381. * @param name the name of the shader
  39382. * @param pixelShader optional pixel shader content
  39383. * @param vertexShader optional vertex shader content
  39384. */
  39385. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39386. /**
  39387. * Store of each shader (The can be looked up using effect.key)
  39388. */
  39389. static ShadersStore: {
  39390. [key: string]: string;
  39391. };
  39392. /**
  39393. * Store of each included file for a shader (The can be looked up using effect.key)
  39394. */
  39395. static IncludesShadersStore: {
  39396. [key: string]: string;
  39397. };
  39398. /**
  39399. * Resets the cache of effects.
  39400. */
  39401. static ResetCache(): void;
  39402. }
  39403. }
  39404. declare module BABYLON {
  39405. /**
  39406. * Interface used to describe the capabilities of the engine relatively to the current browser
  39407. */
  39408. export interface EngineCapabilities {
  39409. /** Maximum textures units per fragment shader */
  39410. maxTexturesImageUnits: number;
  39411. /** Maximum texture units per vertex shader */
  39412. maxVertexTextureImageUnits: number;
  39413. /** Maximum textures units in the entire pipeline */
  39414. maxCombinedTexturesImageUnits: number;
  39415. /** Maximum texture size */
  39416. maxTextureSize: number;
  39417. /** Maximum texture samples */
  39418. maxSamples?: number;
  39419. /** Maximum cube texture size */
  39420. maxCubemapTextureSize: number;
  39421. /** Maximum render texture size */
  39422. maxRenderTextureSize: number;
  39423. /** Maximum number of vertex attributes */
  39424. maxVertexAttribs: number;
  39425. /** Maximum number of varyings */
  39426. maxVaryingVectors: number;
  39427. /** Maximum number of uniforms per vertex shader */
  39428. maxVertexUniformVectors: number;
  39429. /** Maximum number of uniforms per fragment shader */
  39430. maxFragmentUniformVectors: number;
  39431. /** Defines if standard derivates (dx/dy) are supported */
  39432. standardDerivatives: boolean;
  39433. /** Defines if s3tc texture compression is supported */
  39434. s3tc?: WEBGL_compressed_texture_s3tc;
  39435. /** Defines if pvrtc texture compression is supported */
  39436. pvrtc: any;
  39437. /** Defines if etc1 texture compression is supported */
  39438. etc1: any;
  39439. /** Defines if etc2 texture compression is supported */
  39440. etc2: any;
  39441. /** Defines if astc texture compression is supported */
  39442. astc: any;
  39443. /** Defines if bptc texture compression is supported */
  39444. bptc: any;
  39445. /** Defines if float textures are supported */
  39446. textureFloat: boolean;
  39447. /** Defines if vertex array objects are supported */
  39448. vertexArrayObject: boolean;
  39449. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39450. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39451. /** Gets the maximum level of anisotropy supported */
  39452. maxAnisotropy: number;
  39453. /** Defines if instancing is supported */
  39454. instancedArrays: boolean;
  39455. /** Defines if 32 bits indices are supported */
  39456. uintIndices: boolean;
  39457. /** Defines if high precision shaders are supported */
  39458. highPrecisionShaderSupported: boolean;
  39459. /** Defines if depth reading in the fragment shader is supported */
  39460. fragmentDepthSupported: boolean;
  39461. /** Defines if float texture linear filtering is supported*/
  39462. textureFloatLinearFiltering: boolean;
  39463. /** Defines if rendering to float textures is supported */
  39464. textureFloatRender: boolean;
  39465. /** Defines if half float textures are supported*/
  39466. textureHalfFloat: boolean;
  39467. /** Defines if half float texture linear filtering is supported*/
  39468. textureHalfFloatLinearFiltering: boolean;
  39469. /** Defines if rendering to half float textures is supported */
  39470. textureHalfFloatRender: boolean;
  39471. /** Defines if textureLOD shader command is supported */
  39472. textureLOD: boolean;
  39473. /** Defines if draw buffers extension is supported */
  39474. drawBuffersExtension: boolean;
  39475. /** Defines if depth textures are supported */
  39476. depthTextureExtension: boolean;
  39477. /** Defines if float color buffer are supported */
  39478. colorBufferFloat: boolean;
  39479. /** Gets disjoint timer query extension (null if not supported) */
  39480. timerQuery?: EXT_disjoint_timer_query;
  39481. /** Defines if timestamp can be used with timer query */
  39482. canUseTimestampForTimerQuery: boolean;
  39483. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39484. multiview?: any;
  39485. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39486. oculusMultiview?: any;
  39487. /** Function used to let the system compiles shaders in background */
  39488. parallelShaderCompile?: {
  39489. COMPLETION_STATUS_KHR: number;
  39490. };
  39491. /** Max number of texture samples for MSAA */
  39492. maxMSAASamples: number;
  39493. /** Defines if the blend min max extension is supported */
  39494. blendMinMax: boolean;
  39495. /** 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 */
  39496. canUseGLInstanceID: boolean;
  39497. }
  39498. }
  39499. declare module BABYLON {
  39500. /**
  39501. * @hidden
  39502. **/
  39503. export class DepthCullingState {
  39504. private _isDepthTestDirty;
  39505. private _isDepthMaskDirty;
  39506. private _isDepthFuncDirty;
  39507. private _isCullFaceDirty;
  39508. private _isCullDirty;
  39509. private _isZOffsetDirty;
  39510. private _isFrontFaceDirty;
  39511. private _depthTest;
  39512. private _depthMask;
  39513. private _depthFunc;
  39514. private _cull;
  39515. private _cullFace;
  39516. private _zOffset;
  39517. private _frontFace;
  39518. /**
  39519. * Initializes the state.
  39520. */
  39521. constructor();
  39522. get isDirty(): boolean;
  39523. get zOffset(): number;
  39524. set zOffset(value: number);
  39525. get cullFace(): Nullable<number>;
  39526. set cullFace(value: Nullable<number>);
  39527. get cull(): Nullable<boolean>;
  39528. set cull(value: Nullable<boolean>);
  39529. get depthFunc(): Nullable<number>;
  39530. set depthFunc(value: Nullable<number>);
  39531. get depthMask(): boolean;
  39532. set depthMask(value: boolean);
  39533. get depthTest(): boolean;
  39534. set depthTest(value: boolean);
  39535. get frontFace(): Nullable<number>;
  39536. set frontFace(value: Nullable<number>);
  39537. reset(): void;
  39538. apply(gl: WebGLRenderingContext): void;
  39539. }
  39540. }
  39541. declare module BABYLON {
  39542. /**
  39543. * @hidden
  39544. **/
  39545. export class StencilState {
  39546. /** 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 */
  39547. static readonly ALWAYS: number;
  39548. /** Passed to stencilOperation to specify that stencil value must be kept */
  39549. static readonly KEEP: number;
  39550. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39551. static readonly REPLACE: number;
  39552. private _isStencilTestDirty;
  39553. private _isStencilMaskDirty;
  39554. private _isStencilFuncDirty;
  39555. private _isStencilOpDirty;
  39556. private _stencilTest;
  39557. private _stencilMask;
  39558. private _stencilFunc;
  39559. private _stencilFuncRef;
  39560. private _stencilFuncMask;
  39561. private _stencilOpStencilFail;
  39562. private _stencilOpDepthFail;
  39563. private _stencilOpStencilDepthPass;
  39564. get isDirty(): boolean;
  39565. get stencilFunc(): number;
  39566. set stencilFunc(value: number);
  39567. get stencilFuncRef(): number;
  39568. set stencilFuncRef(value: number);
  39569. get stencilFuncMask(): number;
  39570. set stencilFuncMask(value: number);
  39571. get stencilOpStencilFail(): number;
  39572. set stencilOpStencilFail(value: number);
  39573. get stencilOpDepthFail(): number;
  39574. set stencilOpDepthFail(value: number);
  39575. get stencilOpStencilDepthPass(): number;
  39576. set stencilOpStencilDepthPass(value: number);
  39577. get stencilMask(): number;
  39578. set stencilMask(value: number);
  39579. get stencilTest(): boolean;
  39580. set stencilTest(value: boolean);
  39581. constructor();
  39582. reset(): void;
  39583. apply(gl: WebGLRenderingContext): void;
  39584. }
  39585. }
  39586. declare module BABYLON {
  39587. /**
  39588. * @hidden
  39589. **/
  39590. export class AlphaState {
  39591. _blendFunctionParameters: Nullable<number>[];
  39592. _blendEquationParameters: Nullable<number>[];
  39593. _blendConstants: Nullable<number>[];
  39594. _isBlendConstantsDirty: boolean;
  39595. private _alphaBlend;
  39596. private _isAlphaBlendDirty;
  39597. private _isBlendFunctionParametersDirty;
  39598. private _isBlendEquationParametersDirty;
  39599. /**
  39600. * Initializes the state.
  39601. */
  39602. constructor();
  39603. get isDirty(): boolean;
  39604. get alphaBlend(): boolean;
  39605. set alphaBlend(value: boolean);
  39606. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39607. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39608. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39609. reset(): void;
  39610. apply(gl: WebGLRenderingContext): void;
  39611. }
  39612. }
  39613. declare module BABYLON {
  39614. /** @hidden */
  39615. export class WebGLShaderProcessor implements IShaderProcessor {
  39616. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39617. }
  39618. }
  39619. declare module BABYLON {
  39620. /** @hidden */
  39621. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39622. attributeProcessor(attribute: string): string;
  39623. varyingProcessor(varying: string, isFragment: boolean): string;
  39624. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39625. }
  39626. }
  39627. declare module BABYLON {
  39628. /**
  39629. * Interface for attribute information associated with buffer instanciation
  39630. */
  39631. export interface InstancingAttributeInfo {
  39632. /**
  39633. * Name of the GLSL attribute
  39634. * if attribute index is not specified, this is used to retrieve the index from the effect
  39635. */
  39636. attributeName: string;
  39637. /**
  39638. * Index/offset of the attribute in the vertex shader
  39639. * if not specified, this will be computes from the name.
  39640. */
  39641. index?: number;
  39642. /**
  39643. * size of the attribute, 1, 2, 3 or 4
  39644. */
  39645. attributeSize: number;
  39646. /**
  39647. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39648. */
  39649. offset: number;
  39650. /**
  39651. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39652. * default to 1
  39653. */
  39654. divisor?: number;
  39655. /**
  39656. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39657. * default is FLOAT
  39658. */
  39659. attributeType?: number;
  39660. /**
  39661. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39662. */
  39663. normalized?: boolean;
  39664. }
  39665. }
  39666. declare module BABYLON {
  39667. /** @hidden */
  39668. export interface EngineFeatures {
  39669. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39670. forceBitmapOverHTMLImageElement: boolean;
  39671. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39672. supportRenderAndCopyToLodForFloatTextures: boolean;
  39673. /** Indicates that the engine support handling depth/stencil textures */
  39674. supportDepthStencilTexture: boolean;
  39675. /** Indicates that the engine support shadow samplers */
  39676. supportShadowSamplers: boolean;
  39677. /** 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 */
  39678. uniformBufferHardCheckMatrix: boolean;
  39679. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39680. allowTexturePrefiltering: boolean;
  39681. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39682. trackUbosInFrame: boolean;
  39683. /** Indicates that the Cascaded Shadow Map technic is supported */
  39684. supportCSM: boolean;
  39685. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39686. basisNeedsPOT: boolean;
  39687. /** Indicates that the engine supports 3D textures */
  39688. support3DTextures: boolean;
  39689. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39690. needTypeSuffixInShaderConstants: boolean;
  39691. /** Indicates that MSAA is supported */
  39692. supportMSAA: boolean;
  39693. /** Indicates that SSAO2 is supported */
  39694. supportSSAO2: boolean;
  39695. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39696. supportExtendedTextureFormats: boolean;
  39697. /** Indicates that the switch/case construct is supported in shaders */
  39698. supportSwitchCaseInShader: boolean;
  39699. /** Indicates that synchronous texture reading is supported */
  39700. supportSyncTextureRead: boolean;
  39701. /** @hidden */
  39702. _collectUbosUpdatedInFrame: boolean;
  39703. }
  39704. }
  39705. declare module BABYLON {
  39706. /** @hidden */
  39707. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39708. private _webGLTexture;
  39709. private _context;
  39710. get underlyingResource(): Nullable<WebGLTexture>;
  39711. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39712. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39713. set(hardwareTexture: WebGLTexture): void;
  39714. reset(): void;
  39715. release(): void;
  39716. }
  39717. }
  39718. declare module BABYLON {
  39719. interface ThinEngine {
  39720. /**
  39721. * Update a video texture
  39722. * @param texture defines the texture to update
  39723. * @param video defines the video element to use
  39724. * @param invertY defines if data must be stored with Y axis inverted
  39725. */
  39726. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39727. }
  39728. }
  39729. declare module BABYLON {
  39730. interface ThinEngine {
  39731. /**
  39732. * Creates a dynamic texture
  39733. * @param width defines the width of the texture
  39734. * @param height defines the height of the texture
  39735. * @param generateMipMaps defines if the engine should generate the mip levels
  39736. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39737. * @returns the dynamic texture inside an InternalTexture
  39738. */
  39739. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39740. /**
  39741. * Update the content of a dynamic texture
  39742. * @param texture defines the texture to update
  39743. * @param source defines the source containing the data
  39744. * @param invertY defines if data must be stored with Y axis inverted
  39745. * @param premulAlpha defines if alpha is stored as premultiplied
  39746. * @param format defines the format of the data
  39747. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39748. */
  39749. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39750. }
  39751. }
  39752. declare module BABYLON {
  39753. /**
  39754. * Settings for finer control over video usage
  39755. */
  39756. export interface VideoTextureSettings {
  39757. /**
  39758. * Applies `autoplay` to video, if specified
  39759. */
  39760. autoPlay?: boolean;
  39761. /**
  39762. * Applies `muted` to video, if specified
  39763. */
  39764. muted?: boolean;
  39765. /**
  39766. * Applies `loop` to video, if specified
  39767. */
  39768. loop?: boolean;
  39769. /**
  39770. * Automatically updates internal texture from video at every frame in the render loop
  39771. */
  39772. autoUpdateTexture: boolean;
  39773. /**
  39774. * Image src displayed during the video loading or until the user interacts with the video.
  39775. */
  39776. poster?: string;
  39777. }
  39778. /**
  39779. * If you want to display a video in your scene, this is the special texture for that.
  39780. * This special texture works similar to other textures, with the exception of a few parameters.
  39781. * @see https://doc.babylonjs.com/how_to/video_texture
  39782. */
  39783. export class VideoTexture extends Texture {
  39784. /**
  39785. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39786. */
  39787. readonly autoUpdateTexture: boolean;
  39788. /**
  39789. * The video instance used by the texture internally
  39790. */
  39791. readonly video: HTMLVideoElement;
  39792. private _onUserActionRequestedObservable;
  39793. /**
  39794. * Event triggerd when a dom action is required by the user to play the video.
  39795. * This happens due to recent changes in browser policies preventing video to auto start.
  39796. */
  39797. get onUserActionRequestedObservable(): Observable<Texture>;
  39798. private _generateMipMaps;
  39799. private _stillImageCaptured;
  39800. private _displayingPosterTexture;
  39801. private _settings;
  39802. private _createInternalTextureOnEvent;
  39803. private _frameId;
  39804. private _currentSrc;
  39805. /**
  39806. * Creates a video texture.
  39807. * If you want to display a video in your scene, this is the special texture for that.
  39808. * This special texture works similar to other textures, with the exception of a few parameters.
  39809. * @see https://doc.babylonjs.com/how_to/video_texture
  39810. * @param name optional name, will detect from video source, if not defined
  39811. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39812. * @param scene is obviously the current scene.
  39813. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39814. * @param invertY is false by default but can be used to invert video on Y axis
  39815. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39816. * @param settings allows finer control over video usage
  39817. */
  39818. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39819. private _getName;
  39820. private _getVideo;
  39821. private _createInternalTexture;
  39822. private reset;
  39823. /**
  39824. * @hidden Internal method to initiate `update`.
  39825. */
  39826. _rebuild(): void;
  39827. /**
  39828. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39829. */
  39830. update(): void;
  39831. /**
  39832. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39833. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39834. */
  39835. updateTexture(isVisible: boolean): void;
  39836. protected _updateInternalTexture: () => void;
  39837. /**
  39838. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39839. * @param url New url.
  39840. */
  39841. updateURL(url: string): void;
  39842. /**
  39843. * Clones the texture.
  39844. * @returns the cloned texture
  39845. */
  39846. clone(): VideoTexture;
  39847. /**
  39848. * Dispose the texture and release its associated resources.
  39849. */
  39850. dispose(): void;
  39851. /**
  39852. * Creates a video texture straight from a stream.
  39853. * @param scene Define the scene the texture should be created in
  39854. * @param stream Define the stream the texture should be created from
  39855. * @returns The created video texture as a promise
  39856. */
  39857. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39858. /**
  39859. * Creates a video texture straight from your WebCam video feed.
  39860. * @param scene Define the scene the texture should be created in
  39861. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39862. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39863. * @returns The created video texture as a promise
  39864. */
  39865. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39866. minWidth: number;
  39867. maxWidth: number;
  39868. minHeight: number;
  39869. maxHeight: number;
  39870. deviceId: string;
  39871. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39872. /**
  39873. * Creates a video texture straight from your WebCam video feed.
  39874. * @param scene Define the scene the texture should be created in
  39875. * @param onReady Define a callback to triggered once the texture will be ready
  39876. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39877. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39878. */
  39879. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39880. minWidth: number;
  39881. maxWidth: number;
  39882. minHeight: number;
  39883. maxHeight: number;
  39884. deviceId: string;
  39885. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39886. }
  39887. }
  39888. declare module BABYLON {
  39889. /**
  39890. * Defines the interface used by objects working like Scene
  39891. * @hidden
  39892. */
  39893. export interface ISceneLike {
  39894. _addPendingData(data: any): void;
  39895. _removePendingData(data: any): void;
  39896. offlineProvider: IOfflineProvider;
  39897. }
  39898. /**
  39899. * Information about the current host
  39900. */
  39901. export interface HostInformation {
  39902. /**
  39903. * Defines if the current host is a mobile
  39904. */
  39905. isMobile: boolean;
  39906. }
  39907. /** Interface defining initialization parameters for Engine class */
  39908. export interface EngineOptions extends WebGLContextAttributes {
  39909. /**
  39910. * Defines if the engine should no exceed a specified device ratio
  39911. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39912. */
  39913. limitDeviceRatio?: number;
  39914. /**
  39915. * Defines if webvr should be enabled automatically
  39916. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39917. */
  39918. autoEnableWebVR?: boolean;
  39919. /**
  39920. * Defines if webgl2 should be turned off even if supported
  39921. * @see https://doc.babylonjs.com/features/webgl2
  39922. */
  39923. disableWebGL2Support?: boolean;
  39924. /**
  39925. * Defines if webaudio should be initialized as well
  39926. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39927. */
  39928. audioEngine?: boolean;
  39929. /**
  39930. * Defines if animations should run using a deterministic lock step
  39931. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39932. */
  39933. deterministicLockstep?: boolean;
  39934. /** Defines the maximum steps to use with deterministic lock step mode */
  39935. lockstepMaxSteps?: number;
  39936. /** Defines the seconds between each deterministic lock step */
  39937. timeStep?: number;
  39938. /**
  39939. * Defines that engine should ignore context lost events
  39940. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39941. */
  39942. doNotHandleContextLost?: boolean;
  39943. /**
  39944. * Defines that engine should ignore modifying touch action attribute and style
  39945. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39946. */
  39947. doNotHandleTouchAction?: boolean;
  39948. /**
  39949. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39950. */
  39951. useHighPrecisionFloats?: boolean;
  39952. /**
  39953. * Make the canvas XR Compatible for XR sessions
  39954. */
  39955. xrCompatible?: boolean;
  39956. /**
  39957. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39958. */
  39959. useHighPrecisionMatrix?: boolean;
  39960. /**
  39961. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39962. */
  39963. failIfMajorPerformanceCaveat?: boolean;
  39964. /**
  39965. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39966. */
  39967. adaptToDeviceRatio?: boolean;
  39968. }
  39969. /**
  39970. * The base engine class (root of all engines)
  39971. */
  39972. export class ThinEngine {
  39973. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39974. static ExceptionList: ({
  39975. key: string;
  39976. capture: string;
  39977. captureConstraint: number;
  39978. targets: string[];
  39979. } | {
  39980. key: string;
  39981. capture: null;
  39982. captureConstraint: null;
  39983. targets: string[];
  39984. })[];
  39985. /** @hidden */
  39986. static _TextureLoaders: IInternalTextureLoader[];
  39987. /**
  39988. * Returns the current npm package of the sdk
  39989. */
  39990. static get NpmPackage(): string;
  39991. /**
  39992. * Returns the current version of the framework
  39993. */
  39994. static get Version(): string;
  39995. /**
  39996. * Returns a string describing the current engine
  39997. */
  39998. get description(): string;
  39999. /**
  40000. * Returns the name of the engine
  40001. */
  40002. get name(): string;
  40003. /**
  40004. * Returns the version of the engine
  40005. */
  40006. get version(): number;
  40007. /**
  40008. * Gets or sets the epsilon value used by collision engine
  40009. */
  40010. static CollisionsEpsilon: number;
  40011. /**
  40012. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40013. */
  40014. static get ShadersRepository(): string;
  40015. static set ShadersRepository(value: string);
  40016. /** @hidden */
  40017. _shaderProcessor: Nullable<IShaderProcessor>;
  40018. /**
  40019. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40020. */
  40021. forcePOTTextures: boolean;
  40022. /**
  40023. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40024. */
  40025. isFullscreen: boolean;
  40026. /**
  40027. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40028. */
  40029. cullBackFaces: boolean;
  40030. /**
  40031. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40032. */
  40033. renderEvenInBackground: boolean;
  40034. /**
  40035. * Gets or sets a boolean indicating that cache can be kept between frames
  40036. */
  40037. preventCacheWipeBetweenFrames: boolean;
  40038. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40039. validateShaderPrograms: boolean;
  40040. /**
  40041. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40042. * This can provide greater z depth for distant objects.
  40043. */
  40044. useReverseDepthBuffer: boolean;
  40045. /**
  40046. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40047. */
  40048. disableUniformBuffers: boolean;
  40049. private _frameId;
  40050. /**
  40051. * Gets the current frame id
  40052. */
  40053. get frameId(): number;
  40054. /** @hidden */
  40055. _uniformBuffers: UniformBuffer[];
  40056. /**
  40057. * Gets a boolean indicating that the engine supports uniform buffers
  40058. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40059. */
  40060. get supportsUniformBuffers(): boolean;
  40061. /** @hidden */
  40062. _gl: WebGLRenderingContext;
  40063. /** @hidden */
  40064. _webGLVersion: number;
  40065. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40066. protected _windowIsBackground: boolean;
  40067. protected _creationOptions: EngineOptions;
  40068. protected _highPrecisionShadersAllowed: boolean;
  40069. /** @hidden */
  40070. get _shouldUseHighPrecisionShader(): boolean;
  40071. /**
  40072. * Gets a boolean indicating that only power of 2 textures are supported
  40073. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40074. */
  40075. get needPOTTextures(): boolean;
  40076. /** @hidden */
  40077. _badOS: boolean;
  40078. /** @hidden */
  40079. _badDesktopOS: boolean;
  40080. protected _hardwareScalingLevel: number;
  40081. /** @hidden */
  40082. _caps: EngineCapabilities;
  40083. /** @hidden */
  40084. _features: EngineFeatures;
  40085. protected _isStencilEnable: boolean;
  40086. private _glVersion;
  40087. private _glRenderer;
  40088. private _glVendor;
  40089. /** @hidden */
  40090. _videoTextureSupported: boolean;
  40091. protected _renderingQueueLaunched: boolean;
  40092. protected _activeRenderLoops: (() => void)[];
  40093. /**
  40094. * Observable signaled when a context lost event is raised
  40095. */
  40096. onContextLostObservable: Observable<ThinEngine>;
  40097. /**
  40098. * Observable signaled when a context restored event is raised
  40099. */
  40100. onContextRestoredObservable: Observable<ThinEngine>;
  40101. private _onContextLost;
  40102. private _onContextRestored;
  40103. protected _contextWasLost: boolean;
  40104. /** @hidden */
  40105. _doNotHandleContextLost: boolean;
  40106. /**
  40107. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40109. */
  40110. get doNotHandleContextLost(): boolean;
  40111. set doNotHandleContextLost(value: boolean);
  40112. /**
  40113. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40114. */
  40115. disableVertexArrayObjects: boolean;
  40116. /** @hidden */
  40117. protected _colorWrite: boolean;
  40118. /** @hidden */
  40119. protected _colorWriteChanged: boolean;
  40120. /** @hidden */
  40121. protected _depthCullingState: DepthCullingState;
  40122. /** @hidden */
  40123. protected _stencilState: StencilState;
  40124. /** @hidden */
  40125. _alphaState: AlphaState;
  40126. /** @hidden */
  40127. _alphaMode: number;
  40128. /** @hidden */
  40129. _alphaEquation: number;
  40130. /** @hidden */
  40131. _internalTexturesCache: InternalTexture[];
  40132. /** @hidden */
  40133. protected _activeChannel: number;
  40134. private _currentTextureChannel;
  40135. /** @hidden */
  40136. protected _boundTexturesCache: {
  40137. [key: string]: Nullable<InternalTexture>;
  40138. };
  40139. /** @hidden */
  40140. protected _currentEffect: Nullable<Effect>;
  40141. /** @hidden */
  40142. protected _currentProgram: Nullable<WebGLProgram>;
  40143. protected _compiledEffects: {
  40144. [key: string]: Effect;
  40145. };
  40146. private _vertexAttribArraysEnabled;
  40147. /** @hidden */
  40148. protected _cachedViewport: Nullable<IViewportLike>;
  40149. private _cachedVertexArrayObject;
  40150. /** @hidden */
  40151. protected _cachedVertexBuffers: any;
  40152. /** @hidden */
  40153. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40154. /** @hidden */
  40155. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40156. /** @hidden */
  40157. _currentRenderTarget: Nullable<InternalTexture>;
  40158. private _uintIndicesCurrentlySet;
  40159. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40160. /** @hidden */
  40161. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40162. /** @hidden */
  40163. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40164. private _currentBufferPointers;
  40165. private _currentInstanceLocations;
  40166. private _currentInstanceBuffers;
  40167. private _textureUnits;
  40168. /** @hidden */
  40169. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40170. /** @hidden */
  40171. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40172. /** @hidden */
  40173. _boundRenderFunction: any;
  40174. private _vaoRecordInProgress;
  40175. private _mustWipeVertexAttributes;
  40176. private _emptyTexture;
  40177. private _emptyCubeTexture;
  40178. private _emptyTexture3D;
  40179. private _emptyTexture2DArray;
  40180. /** @hidden */
  40181. _frameHandler: number;
  40182. private _nextFreeTextureSlots;
  40183. private _maxSimultaneousTextures;
  40184. private _activeRequests;
  40185. /** @hidden */
  40186. _transformTextureUrl: Nullable<(url: string) => string>;
  40187. /**
  40188. * Gets information about the current host
  40189. */
  40190. hostInformation: HostInformation;
  40191. protected get _supportsHardwareTextureRescaling(): boolean;
  40192. private _framebufferDimensionsObject;
  40193. /**
  40194. * sets the object from which width and height will be taken from when getting render width and height
  40195. * Will fallback to the gl object
  40196. * @param dimensions the framebuffer width and height that will be used.
  40197. */
  40198. set framebufferDimensionsObject(dimensions: Nullable<{
  40199. framebufferWidth: number;
  40200. framebufferHeight: number;
  40201. }>);
  40202. /**
  40203. * Gets the current viewport
  40204. */
  40205. get currentViewport(): Nullable<IViewportLike>;
  40206. /**
  40207. * Gets the default empty texture
  40208. */
  40209. get emptyTexture(): InternalTexture;
  40210. /**
  40211. * Gets the default empty 3D texture
  40212. */
  40213. get emptyTexture3D(): InternalTexture;
  40214. /**
  40215. * Gets the default empty 2D array texture
  40216. */
  40217. get emptyTexture2DArray(): InternalTexture;
  40218. /**
  40219. * Gets the default empty cube texture
  40220. */
  40221. get emptyCubeTexture(): InternalTexture;
  40222. /**
  40223. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40224. */
  40225. premultipliedAlpha: boolean;
  40226. /**
  40227. * Observable event triggered before each texture is initialized
  40228. */
  40229. onBeforeTextureInitObservable: Observable<Texture>;
  40230. /** @hidden */
  40231. protected _isWebGPU: boolean;
  40232. /**
  40233. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40234. */
  40235. get isWebGPU(): boolean;
  40236. /** @hidden */
  40237. protected _shaderPlatformName: string;
  40238. /**
  40239. * Gets the shader platfrom name used by the effects.
  40240. */
  40241. get shaderPlatformName(): string;
  40242. /**
  40243. * Creates a new engine
  40244. * @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
  40245. * @param antialias defines enable antialiasing (default: false)
  40246. * @param options defines further options to be sent to the getContext() function
  40247. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40248. */
  40249. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40250. /**
  40251. * @hidden
  40252. */
  40253. _debugPushGroup(groupName: string, targetObject?: number): void;
  40254. /**
  40255. * @hidden
  40256. */
  40257. _debugPopGroup(targetObject?: number): void;
  40258. /**
  40259. * @hidden
  40260. */
  40261. _debugInsertMarker(text: string, targetObject?: number): void;
  40262. /**
  40263. * Shared initialization across engines types.
  40264. * @param canvas The canvas associated with this instance of the engine.
  40265. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40266. * @param audioEngine Defines if an audio engine should be created by default
  40267. */
  40268. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40269. /**
  40270. * Gets a shader processor implementation fitting with the current engine type.
  40271. * @returns The shader processor implementation.
  40272. */
  40273. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40274. /** @hidden */
  40275. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40276. private _rebuildInternalTextures;
  40277. private _rebuildEffects;
  40278. /**
  40279. * Gets a boolean indicating if all created effects are ready
  40280. * @returns true if all effects are ready
  40281. */
  40282. areAllEffectsReady(): boolean;
  40283. protected _rebuildBuffers(): void;
  40284. protected _initGLContext(): void;
  40285. protected _initFeatures(): void;
  40286. /**
  40287. * Gets version of the current webGL context
  40288. * Keep it for back compat - use version instead
  40289. */
  40290. get webGLVersion(): number;
  40291. /**
  40292. * Gets a string identifying the name of the class
  40293. * @returns "Engine" string
  40294. */
  40295. getClassName(): string;
  40296. /**
  40297. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40298. */
  40299. get isStencilEnable(): boolean;
  40300. /** @hidden */
  40301. _prepareWorkingCanvas(): void;
  40302. /**
  40303. * Reset the texture cache to empty state
  40304. */
  40305. resetTextureCache(): void;
  40306. /**
  40307. * Gets an object containing information about the current webGL context
  40308. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40309. */
  40310. getGlInfo(): {
  40311. vendor: string;
  40312. renderer: string;
  40313. version: string;
  40314. };
  40315. /**
  40316. * Defines the hardware scaling level.
  40317. * By default the hardware scaling level is computed from the window device ratio.
  40318. * 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.
  40319. * @param level defines the level to use
  40320. */
  40321. setHardwareScalingLevel(level: number): void;
  40322. /**
  40323. * Gets the current hardware scaling level.
  40324. * By default the hardware scaling level is computed from the window device ratio.
  40325. * 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.
  40326. * @returns a number indicating the current hardware scaling level
  40327. */
  40328. getHardwareScalingLevel(): number;
  40329. /**
  40330. * Gets the list of loaded textures
  40331. * @returns an array containing all loaded textures
  40332. */
  40333. getLoadedTexturesCache(): InternalTexture[];
  40334. /**
  40335. * Gets the object containing all engine capabilities
  40336. * @returns the EngineCapabilities object
  40337. */
  40338. getCaps(): EngineCapabilities;
  40339. /**
  40340. * stop executing a render loop function and remove it from the execution array
  40341. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40342. */
  40343. stopRenderLoop(renderFunction?: () => void): void;
  40344. /** @hidden */
  40345. _renderLoop(): void;
  40346. /**
  40347. * Gets the HTML canvas attached with the current webGL context
  40348. * @returns a HTML canvas
  40349. */
  40350. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40351. /**
  40352. * Gets host window
  40353. * @returns the host window object
  40354. */
  40355. getHostWindow(): Nullable<Window>;
  40356. /**
  40357. * Gets the current render width
  40358. * @param useScreen defines if screen size must be used (or the current render target if any)
  40359. * @returns a number defining the current render width
  40360. */
  40361. getRenderWidth(useScreen?: boolean): number;
  40362. /**
  40363. * Gets the current render height
  40364. * @param useScreen defines if screen size must be used (or the current render target if any)
  40365. * @returns a number defining the current render height
  40366. */
  40367. getRenderHeight(useScreen?: boolean): number;
  40368. /**
  40369. * Can be used to override the current requestAnimationFrame requester.
  40370. * @hidden
  40371. */
  40372. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40373. /**
  40374. * Register and execute a render loop. The engine can have more than one render function
  40375. * @param renderFunction defines the function to continuously execute
  40376. */
  40377. runRenderLoop(renderFunction: () => void): void;
  40378. /**
  40379. * Clear the current render buffer or the current render target (if any is set up)
  40380. * @param color defines the color to use
  40381. * @param backBuffer defines if the back buffer must be cleared
  40382. * @param depth defines if the depth buffer must be cleared
  40383. * @param stencil defines if the stencil buffer must be cleared
  40384. */
  40385. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40386. protected _viewportCached: {
  40387. x: number;
  40388. y: number;
  40389. z: number;
  40390. w: number;
  40391. };
  40392. /** @hidden */
  40393. _viewport(x: number, y: number, width: number, height: number): void;
  40394. /**
  40395. * Set the WebGL's viewport
  40396. * @param viewport defines the viewport element to be used
  40397. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40398. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40399. */
  40400. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40401. /**
  40402. * Begin a new frame
  40403. */
  40404. beginFrame(): void;
  40405. /**
  40406. * Enf the current frame
  40407. */
  40408. endFrame(): void;
  40409. /**
  40410. * Resize the view according to the canvas' size
  40411. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40412. */
  40413. resize(forceSetSize?: boolean): void;
  40414. /**
  40415. * Force a specific size of the canvas
  40416. * @param width defines the new canvas' width
  40417. * @param height defines the new canvas' height
  40418. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40419. * @returns true if the size was changed
  40420. */
  40421. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40422. /**
  40423. * Binds the frame buffer to the specified texture.
  40424. * @param texture The texture to render to or null for the default canvas
  40425. * @param faceIndex The face of the texture to render to in case of cube texture
  40426. * @param requiredWidth The width of the target to render to
  40427. * @param requiredHeight The height of the target to render to
  40428. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40429. * @param lodLevel defines the lod level to bind to the frame buffer
  40430. * @param layer defines the 2d array index to bind to frame buffer to
  40431. */
  40432. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40433. /** @hidden */
  40434. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40435. /**
  40436. * Unbind the current render target texture from the webGL context
  40437. * @param texture defines the render target texture to unbind
  40438. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40439. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40440. */
  40441. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40442. /**
  40443. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40444. */
  40445. flushFramebuffer(): void;
  40446. /**
  40447. * Unbind the current render target and bind the default framebuffer
  40448. */
  40449. restoreDefaultFramebuffer(): void;
  40450. /** @hidden */
  40451. protected _resetVertexBufferBinding(): void;
  40452. /**
  40453. * Creates a vertex buffer
  40454. * @param data the data for the vertex buffer
  40455. * @returns the new WebGL static buffer
  40456. */
  40457. createVertexBuffer(data: DataArray): DataBuffer;
  40458. private _createVertexBuffer;
  40459. /**
  40460. * Creates a dynamic vertex buffer
  40461. * @param data the data for the dynamic vertex buffer
  40462. * @returns the new WebGL dynamic buffer
  40463. */
  40464. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40465. protected _resetIndexBufferBinding(): void;
  40466. /**
  40467. * Creates a new index buffer
  40468. * @param indices defines the content of the index buffer
  40469. * @param updatable defines if the index buffer must be updatable
  40470. * @returns a new webGL buffer
  40471. */
  40472. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40473. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40474. /**
  40475. * Bind a webGL buffer to the webGL context
  40476. * @param buffer defines the buffer to bind
  40477. */
  40478. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40479. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40480. private bindBuffer;
  40481. /**
  40482. * update the bound buffer with the given data
  40483. * @param data defines the data to update
  40484. */
  40485. updateArrayBuffer(data: Float32Array): void;
  40486. private _vertexAttribPointer;
  40487. /** @hidden */
  40488. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40489. private _bindVertexBuffersAttributes;
  40490. /**
  40491. * Records a vertex array object
  40492. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40493. * @param vertexBuffers defines the list of vertex buffers to store
  40494. * @param indexBuffer defines the index buffer to store
  40495. * @param effect defines the effect to store
  40496. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40497. * @returns the new vertex array object
  40498. */
  40499. recordVertexArrayObject(vertexBuffers: {
  40500. [key: string]: VertexBuffer;
  40501. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40502. [kind: string]: Nullable<VertexBuffer>;
  40503. }): WebGLVertexArrayObject;
  40504. /**
  40505. * Bind a specific vertex array object
  40506. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40507. * @param vertexArrayObject defines the vertex array object to bind
  40508. * @param indexBuffer defines the index buffer to bind
  40509. */
  40510. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40511. /**
  40512. * Bind webGl buffers directly to the webGL context
  40513. * @param vertexBuffer defines the vertex buffer to bind
  40514. * @param indexBuffer defines the index buffer to bind
  40515. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40516. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40517. * @param effect defines the effect associated with the vertex buffer
  40518. */
  40519. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40520. private _unbindVertexArrayObject;
  40521. /**
  40522. * Bind a list of vertex buffers to the webGL context
  40523. * @param vertexBuffers defines the list of vertex buffers to bind
  40524. * @param indexBuffer defines the index buffer to bind
  40525. * @param effect defines the effect associated with the vertex buffers
  40526. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40527. */
  40528. bindBuffers(vertexBuffers: {
  40529. [key: string]: Nullable<VertexBuffer>;
  40530. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40531. [kind: string]: Nullable<VertexBuffer>;
  40532. }): void;
  40533. /**
  40534. * Unbind all instance attributes
  40535. */
  40536. unbindInstanceAttributes(): void;
  40537. /**
  40538. * Release and free the memory of a vertex array object
  40539. * @param vao defines the vertex array object to delete
  40540. */
  40541. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40542. /** @hidden */
  40543. _releaseBuffer(buffer: DataBuffer): boolean;
  40544. protected _deleteBuffer(buffer: DataBuffer): void;
  40545. /**
  40546. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40547. * @param instancesBuffer defines the webGL buffer to update and bind
  40548. * @param data defines the data to store in the buffer
  40549. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40550. */
  40551. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40552. /**
  40553. * Bind the content of a webGL buffer used with instantiation
  40554. * @param instancesBuffer defines the webGL buffer to bind
  40555. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40556. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40557. */
  40558. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40559. /**
  40560. * Disable the instance attribute corresponding to the name in parameter
  40561. * @param name defines the name of the attribute to disable
  40562. */
  40563. disableInstanceAttributeByName(name: string): void;
  40564. /**
  40565. * Disable the instance attribute corresponding to the location in parameter
  40566. * @param attributeLocation defines the attribute location of the attribute to disable
  40567. */
  40568. disableInstanceAttribute(attributeLocation: number): void;
  40569. /**
  40570. * Disable the attribute corresponding to the location in parameter
  40571. * @param attributeLocation defines the attribute location of the attribute to disable
  40572. */
  40573. disableAttributeByIndex(attributeLocation: number): void;
  40574. /**
  40575. * Send a draw order
  40576. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40577. * @param indexStart defines the starting index
  40578. * @param indexCount defines the number of index to draw
  40579. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40580. */
  40581. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40582. /**
  40583. * Draw a list of points
  40584. * @param verticesStart defines the index of first vertex to draw
  40585. * @param verticesCount defines the count of vertices to draw
  40586. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40587. */
  40588. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40589. /**
  40590. * Draw a list of unindexed primitives
  40591. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40592. * @param verticesStart defines the index of first vertex to draw
  40593. * @param verticesCount defines the count of vertices to draw
  40594. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40595. */
  40596. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40597. /**
  40598. * Draw a list of indexed primitives
  40599. * @param fillMode defines the primitive to use
  40600. * @param indexStart defines the starting index
  40601. * @param indexCount defines the number of index to draw
  40602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40603. */
  40604. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40605. /**
  40606. * Draw a list of unindexed primitives
  40607. * @param fillMode defines the primitive to use
  40608. * @param verticesStart defines the index of first vertex to draw
  40609. * @param verticesCount defines the count of vertices to draw
  40610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40611. */
  40612. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40613. private _drawMode;
  40614. /** @hidden */
  40615. protected _reportDrawCall(): void;
  40616. /** @hidden */
  40617. _releaseEffect(effect: Effect): void;
  40618. /** @hidden */
  40619. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40620. /**
  40621. * Create a new effect (used to store vertex/fragment shaders)
  40622. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40623. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40624. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40625. * @param samplers defines an array of string used to represent textures
  40626. * @param defines defines the string containing the defines to use to compile the shaders
  40627. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40628. * @param onCompiled defines a function to call when the effect creation is successful
  40629. * @param onError defines a function to call when the effect creation has failed
  40630. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40631. * @returns the new Effect
  40632. */
  40633. 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;
  40634. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40635. private _compileShader;
  40636. private _compileRawShader;
  40637. /** @hidden */
  40638. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40639. /**
  40640. * Directly creates a webGL program
  40641. * @param pipelineContext defines the pipeline context to attach to
  40642. * @param vertexCode defines the vertex shader code to use
  40643. * @param fragmentCode defines the fragment shader code to use
  40644. * @param context defines the webGL context to use (if not set, the current one will be used)
  40645. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40646. * @returns the new webGL program
  40647. */
  40648. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40649. /**
  40650. * Creates a webGL program
  40651. * @param pipelineContext defines the pipeline context to attach to
  40652. * @param vertexCode defines the vertex shader code to use
  40653. * @param fragmentCode defines the fragment shader code to use
  40654. * @param defines defines the string containing the defines to use to compile the shaders
  40655. * @param context defines the webGL context to use (if not set, the current one will be used)
  40656. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40657. * @returns the new webGL program
  40658. */
  40659. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40660. /**
  40661. * Creates a new pipeline context
  40662. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40663. * @returns the new pipeline
  40664. */
  40665. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40666. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40667. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40668. /** @hidden */
  40669. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40670. /** @hidden */
  40671. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40672. /** @hidden */
  40673. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40674. /**
  40675. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40676. * @param pipelineContext defines the pipeline context to use
  40677. * @param uniformsNames defines the list of uniform names
  40678. * @returns an array of webGL uniform locations
  40679. */
  40680. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40681. /**
  40682. * Gets the list of active attributes for a given webGL program
  40683. * @param pipelineContext defines the pipeline context to use
  40684. * @param attributesNames defines the list of attribute names to get
  40685. * @returns an array of indices indicating the offset of each attribute
  40686. */
  40687. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40688. /**
  40689. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40690. * @param effect defines the effect to activate
  40691. */
  40692. enableEffect(effect: Nullable<Effect>): void;
  40693. /**
  40694. * Set the value of an uniform to a number (int)
  40695. * @param uniform defines the webGL uniform location where to store the value
  40696. * @param value defines the int number to store
  40697. * @returns true if the value was set
  40698. */
  40699. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40700. /**
  40701. * Set the value of an uniform to a int2
  40702. * @param uniform defines the webGL uniform location where to store the value
  40703. * @param x defines the 1st component of the value
  40704. * @param y defines the 2nd component of the value
  40705. * @returns true if the value was set
  40706. */
  40707. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40708. /**
  40709. * Set the value of an uniform to a int3
  40710. * @param uniform defines the webGL uniform location where to store the value
  40711. * @param x defines the 1st component of the value
  40712. * @param y defines the 2nd component of the value
  40713. * @param z defines the 3rd component of the value
  40714. * @returns true if the value was set
  40715. */
  40716. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40717. /**
  40718. * Set the value of an uniform to a int4
  40719. * @param uniform defines the webGL uniform location where to store the value
  40720. * @param x defines the 1st component of the value
  40721. * @param y defines the 2nd component of the value
  40722. * @param z defines the 3rd component of the value
  40723. * @param w defines the 4th component of the value
  40724. * @returns true if the value was set
  40725. */
  40726. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40727. /**
  40728. * Set the value of an uniform to an array of int32
  40729. * @param uniform defines the webGL uniform location where to store the value
  40730. * @param array defines the array of int32 to store
  40731. * @returns true if the value was set
  40732. */
  40733. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40734. /**
  40735. * Set the value of an uniform to an array of int32 (stored as vec2)
  40736. * @param uniform defines the webGL uniform location where to store the value
  40737. * @param array defines the array of int32 to store
  40738. * @returns true if the value was set
  40739. */
  40740. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40741. /**
  40742. * Set the value of an uniform to an array of int32 (stored as vec3)
  40743. * @param uniform defines the webGL uniform location where to store the value
  40744. * @param array defines the array of int32 to store
  40745. * @returns true if the value was set
  40746. */
  40747. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40748. /**
  40749. * Set the value of an uniform to an array of int32 (stored as vec4)
  40750. * @param uniform defines the webGL uniform location where to store the value
  40751. * @param array defines the array of int32 to store
  40752. * @returns true if the value was set
  40753. */
  40754. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40755. /**
  40756. * Set the value of an uniform to an array of number
  40757. * @param uniform defines the webGL uniform location where to store the value
  40758. * @param array defines the array of number to store
  40759. * @returns true if the value was set
  40760. */
  40761. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40762. /**
  40763. * Set the value of an uniform to an array of number (stored as vec2)
  40764. * @param uniform defines the webGL uniform location where to store the value
  40765. * @param array defines the array of number to store
  40766. * @returns true if the value was set
  40767. */
  40768. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40769. /**
  40770. * Set the value of an uniform to an array of number (stored as vec3)
  40771. * @param uniform defines the webGL uniform location where to store the value
  40772. * @param array defines the array of number to store
  40773. * @returns true if the value was set
  40774. */
  40775. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40776. /**
  40777. * Set the value of an uniform to an array of number (stored as vec4)
  40778. * @param uniform defines the webGL uniform location where to store the value
  40779. * @param array defines the array of number to store
  40780. * @returns true if the value was set
  40781. */
  40782. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40783. /**
  40784. * Set the value of an uniform to an array of float32 (stored as matrices)
  40785. * @param uniform defines the webGL uniform location where to store the value
  40786. * @param matrices defines the array of float32 to store
  40787. * @returns true if the value was set
  40788. */
  40789. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40790. /**
  40791. * Set the value of an uniform to a matrix (3x3)
  40792. * @param uniform defines the webGL uniform location where to store the value
  40793. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40794. * @returns true if the value was set
  40795. */
  40796. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40797. /**
  40798. * Set the value of an uniform to a matrix (2x2)
  40799. * @param uniform defines the webGL uniform location where to store the value
  40800. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40801. * @returns true if the value was set
  40802. */
  40803. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40804. /**
  40805. * Set the value of an uniform to a number (float)
  40806. * @param uniform defines the webGL uniform location where to store the value
  40807. * @param value defines the float number to store
  40808. * @returns true if the value was transfered
  40809. */
  40810. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40811. /**
  40812. * Set the value of an uniform to a vec2
  40813. * @param uniform defines the webGL uniform location where to store the value
  40814. * @param x defines the 1st component of the value
  40815. * @param y defines the 2nd component of the value
  40816. * @returns true if the value was set
  40817. */
  40818. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40819. /**
  40820. * Set the value of an uniform to a vec3
  40821. * @param uniform defines the webGL uniform location where to store the value
  40822. * @param x defines the 1st component of the value
  40823. * @param y defines the 2nd component of the value
  40824. * @param z defines the 3rd component of the value
  40825. * @returns true if the value was set
  40826. */
  40827. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40828. /**
  40829. * Set the value of an uniform to a vec4
  40830. * @param uniform defines the webGL uniform location where to store the value
  40831. * @param x defines the 1st component of the value
  40832. * @param y defines the 2nd component of the value
  40833. * @param z defines the 3rd component of the value
  40834. * @param w defines the 4th component of the value
  40835. * @returns true if the value was set
  40836. */
  40837. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40838. /**
  40839. * Apply all cached states (depth, culling, stencil and alpha)
  40840. */
  40841. applyStates(): void;
  40842. /**
  40843. * Enable or disable color writing
  40844. * @param enable defines the state to set
  40845. */
  40846. setColorWrite(enable: boolean): void;
  40847. /**
  40848. * Gets a boolean indicating if color writing is enabled
  40849. * @returns the current color writing state
  40850. */
  40851. getColorWrite(): boolean;
  40852. /**
  40853. * Gets the depth culling state manager
  40854. */
  40855. get depthCullingState(): DepthCullingState;
  40856. /**
  40857. * Gets the alpha state manager
  40858. */
  40859. get alphaState(): AlphaState;
  40860. /**
  40861. * Gets the stencil state manager
  40862. */
  40863. get stencilState(): StencilState;
  40864. /**
  40865. * Clears the list of texture accessible through engine.
  40866. * This can help preventing texture load conflict due to name collision.
  40867. */
  40868. clearInternalTexturesCache(): void;
  40869. /**
  40870. * Force the entire cache to be cleared
  40871. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40872. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40873. */
  40874. wipeCaches(bruteForce?: boolean): void;
  40875. /** @hidden */
  40876. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40877. min: number;
  40878. mag: number;
  40879. };
  40880. /** @hidden */
  40881. protected _createTexture(): WebGLTexture;
  40882. /** @hidden */
  40883. _createHardwareTexture(): HardwareTextureWrapper;
  40884. 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 | {
  40885. width: number;
  40886. height: number;
  40887. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40888. width: number;
  40889. height: number;
  40890. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40891. width: number;
  40892. height: number;
  40893. }, 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;
  40894. /**
  40895. * Usually called from Texture.ts.
  40896. * Passed information to create a WebGLTexture
  40897. * @param url defines a value which contains one of the following:
  40898. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40899. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40900. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40901. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40902. * @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)
  40903. * @param scene needed for loading to the correct scene
  40904. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40905. * @param onLoad optional callback to be called upon successful completion
  40906. * @param onError optional callback to be called upon failure
  40907. * @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
  40908. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40909. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40910. * @param forcedExtension defines the extension to use to pick the right loader
  40911. * @param mimeType defines an optional mime type
  40912. * @param loaderOptions options to be passed to the loader
  40913. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40914. */
  40915. 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;
  40916. /**
  40917. * Loads an image as an HTMLImageElement.
  40918. * @param input url string, ArrayBuffer, or Blob to load
  40919. * @param onLoad callback called when the image successfully loads
  40920. * @param onError callback called when the image fails to load
  40921. * @param offlineProvider offline provider for caching
  40922. * @param mimeType optional mime type
  40923. * @returns the HTMLImageElement of the loaded image
  40924. * @hidden
  40925. */
  40926. 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>;
  40927. /**
  40928. * @hidden
  40929. */
  40930. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40931. private _unpackFlipYCached;
  40932. /**
  40933. * In case you are sharing the context with other applications, it might
  40934. * be interested to not cache the unpack flip y state to ensure a consistent
  40935. * value would be set.
  40936. */
  40937. enableUnpackFlipYCached: boolean;
  40938. /** @hidden */
  40939. _unpackFlipY(value: boolean): void;
  40940. /** @hidden */
  40941. _getUnpackAlignement(): number;
  40942. private _getTextureTarget;
  40943. /**
  40944. * Update the sampling mode of a given texture
  40945. * @param samplingMode defines the required sampling mode
  40946. * @param texture defines the texture to update
  40947. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40948. */
  40949. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40950. /**
  40951. * Update the dimensions of a texture
  40952. * @param texture texture to update
  40953. * @param width new width of the texture
  40954. * @param height new height of the texture
  40955. * @param depth new depth of the texture
  40956. */
  40957. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40958. /**
  40959. * Update the sampling mode of a given texture
  40960. * @param texture defines the texture to update
  40961. * @param wrapU defines the texture wrap mode of the u coordinates
  40962. * @param wrapV defines the texture wrap mode of the v coordinates
  40963. * @param wrapR defines the texture wrap mode of the r coordinates
  40964. */
  40965. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40966. /** @hidden */
  40967. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40968. width: number;
  40969. height: number;
  40970. layers?: number;
  40971. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40972. /** @hidden */
  40973. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40974. /** @hidden */
  40975. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40976. /**
  40977. * Update a portion of an internal texture
  40978. * @param texture defines the texture to update
  40979. * @param imageData defines the data to store into the texture
  40980. * @param xOffset defines the x coordinates of the update rectangle
  40981. * @param yOffset defines the y coordinates of the update rectangle
  40982. * @param width defines the width of the update rectangle
  40983. * @param height defines the height of the update rectangle
  40984. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40985. * @param lod defines the lod level to update (0 by default)
  40986. */
  40987. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40988. /** @hidden */
  40989. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40990. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40991. private _prepareWebGLTexture;
  40992. /** @hidden */
  40993. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40994. private _getDepthStencilBuffer;
  40995. /** @hidden */
  40996. _releaseFramebufferObjects(texture: InternalTexture): void;
  40997. /** @hidden */
  40998. _releaseTexture(texture: InternalTexture): void;
  40999. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41000. protected _setProgram(program: WebGLProgram): void;
  41001. protected _boundUniforms: {
  41002. [key: number]: WebGLUniformLocation;
  41003. };
  41004. /**
  41005. * Binds an effect to the webGL context
  41006. * @param effect defines the effect to bind
  41007. */
  41008. bindSamplers(effect: Effect): void;
  41009. private _activateCurrentTexture;
  41010. /** @hidden */
  41011. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41012. /** @hidden */
  41013. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41014. /**
  41015. * Unbind all textures from the webGL context
  41016. */
  41017. unbindAllTextures(): void;
  41018. /**
  41019. * Sets a texture to the according uniform.
  41020. * @param channel The texture channel
  41021. * @param uniform The uniform to set
  41022. * @param texture The texture to apply
  41023. * @param name The name of the uniform in the effect
  41024. */
  41025. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41026. private _bindSamplerUniformToChannel;
  41027. private _getTextureWrapMode;
  41028. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41029. /**
  41030. * Sets an array of texture to the webGL context
  41031. * @param channel defines the channel where the texture array must be set
  41032. * @param uniform defines the associated uniform location
  41033. * @param textures defines the array of textures to bind
  41034. * @param name name of the channel
  41035. */
  41036. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41037. /** @hidden */
  41038. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41039. private _setTextureParameterFloat;
  41040. private _setTextureParameterInteger;
  41041. /**
  41042. * Unbind all vertex attributes from the webGL context
  41043. */
  41044. unbindAllAttributes(): void;
  41045. /**
  41046. * 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
  41047. */
  41048. releaseEffects(): void;
  41049. /**
  41050. * Dispose and release all associated resources
  41051. */
  41052. dispose(): void;
  41053. /**
  41054. * Attach a new callback raised when context lost event is fired
  41055. * @param callback defines the callback to call
  41056. */
  41057. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41058. /**
  41059. * Attach a new callback raised when context restored event is fired
  41060. * @param callback defines the callback to call
  41061. */
  41062. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41063. /**
  41064. * Get the current error code of the webGL context
  41065. * @returns the error code
  41066. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41067. */
  41068. getError(): number;
  41069. private _canRenderToFloatFramebuffer;
  41070. private _canRenderToHalfFloatFramebuffer;
  41071. private _canRenderToFramebuffer;
  41072. /** @hidden */
  41073. _getWebGLTextureType(type: number): number;
  41074. /** @hidden */
  41075. _getInternalFormat(format: number): number;
  41076. /** @hidden */
  41077. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41078. /** @hidden */
  41079. _getRGBAMultiSampleBufferFormat(type: number): number;
  41080. /** @hidden */
  41081. _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;
  41082. /**
  41083. * Loads a file from a url
  41084. * @param url url to load
  41085. * @param onSuccess callback called when the file successfully loads
  41086. * @param onProgress callback called while file is loading (if the server supports this mode)
  41087. * @param offlineProvider defines the offline provider for caching
  41088. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41089. * @param onError callback called when the file fails to load
  41090. * @returns a file request object
  41091. * @hidden
  41092. */
  41093. 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;
  41094. /**
  41095. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41096. * @param x defines the x coordinate of the rectangle where pixels must be read
  41097. * @param y defines the y coordinate of the rectangle where pixels must be read
  41098. * @param width defines the width of the rectangle where pixels must be read
  41099. * @param height defines the height of the rectangle where pixels must be read
  41100. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41101. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41102. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41103. */
  41104. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41105. private static _IsSupported;
  41106. private static _HasMajorPerformanceCaveat;
  41107. /**
  41108. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41109. */
  41110. static get IsSupported(): boolean;
  41111. /**
  41112. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41113. * @returns true if the engine can be created
  41114. * @ignorenaming
  41115. */
  41116. static isSupported(): boolean;
  41117. /**
  41118. * 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)
  41119. */
  41120. static get HasMajorPerformanceCaveat(): boolean;
  41121. /**
  41122. * Find the next highest power of two.
  41123. * @param x Number to start search from.
  41124. * @return Next highest power of two.
  41125. */
  41126. static CeilingPOT(x: number): number;
  41127. /**
  41128. * Find the next lowest power of two.
  41129. * @param x Number to start search from.
  41130. * @return Next lowest power of two.
  41131. */
  41132. static FloorPOT(x: number): number;
  41133. /**
  41134. * Find the nearest power of two.
  41135. * @param x Number to start search from.
  41136. * @return Next nearest power of two.
  41137. */
  41138. static NearestPOT(x: number): number;
  41139. /**
  41140. * Get the closest exponent of two
  41141. * @param value defines the value to approximate
  41142. * @param max defines the maximum value to return
  41143. * @param mode defines how to define the closest value
  41144. * @returns closest exponent of two of the given value
  41145. */
  41146. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41147. /**
  41148. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41149. * @param func - the function to be called
  41150. * @param requester - the object that will request the next frame. Falls back to window.
  41151. * @returns frame number
  41152. */
  41153. static QueueNewFrame(func: () => void, requester?: any): number;
  41154. /**
  41155. * Gets host document
  41156. * @returns the host document object
  41157. */
  41158. getHostDocument(): Nullable<Document>;
  41159. }
  41160. }
  41161. declare module BABYLON {
  41162. /**
  41163. * Defines the source of the internal texture
  41164. */
  41165. export enum InternalTextureSource {
  41166. /**
  41167. * The source of the texture data is unknown
  41168. */
  41169. Unknown = 0,
  41170. /**
  41171. * Texture data comes from an URL
  41172. */
  41173. Url = 1,
  41174. /**
  41175. * Texture data is only used for temporary storage
  41176. */
  41177. Temp = 2,
  41178. /**
  41179. * Texture data comes from raw data (ArrayBuffer)
  41180. */
  41181. Raw = 3,
  41182. /**
  41183. * Texture content is dynamic (video or dynamic texture)
  41184. */
  41185. Dynamic = 4,
  41186. /**
  41187. * Texture content is generated by rendering to it
  41188. */
  41189. RenderTarget = 5,
  41190. /**
  41191. * Texture content is part of a multi render target process
  41192. */
  41193. MultiRenderTarget = 6,
  41194. /**
  41195. * Texture data comes from a cube data file
  41196. */
  41197. Cube = 7,
  41198. /**
  41199. * Texture data comes from a raw cube data
  41200. */
  41201. CubeRaw = 8,
  41202. /**
  41203. * Texture data come from a prefiltered cube data file
  41204. */
  41205. CubePrefiltered = 9,
  41206. /**
  41207. * Texture content is raw 3D data
  41208. */
  41209. Raw3D = 10,
  41210. /**
  41211. * Texture content is raw 2D array data
  41212. */
  41213. Raw2DArray = 11,
  41214. /**
  41215. * Texture content is a depth texture
  41216. */
  41217. Depth = 12,
  41218. /**
  41219. * Texture data comes from a raw cube data encoded with RGBD
  41220. */
  41221. CubeRawRGBD = 13
  41222. }
  41223. /**
  41224. * Class used to store data associated with WebGL texture data for the engine
  41225. * This class should not be used directly
  41226. */
  41227. export class InternalTexture {
  41228. /** @hidden */
  41229. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41230. /**
  41231. * Defines if the texture is ready
  41232. */
  41233. isReady: boolean;
  41234. /**
  41235. * Defines if the texture is a cube texture
  41236. */
  41237. isCube: boolean;
  41238. /**
  41239. * Defines if the texture contains 3D data
  41240. */
  41241. is3D: boolean;
  41242. /**
  41243. * Defines if the texture contains 2D array data
  41244. */
  41245. is2DArray: boolean;
  41246. /**
  41247. * Defines if the texture contains multiview data
  41248. */
  41249. isMultiview: boolean;
  41250. /**
  41251. * Gets the URL used to load this texture
  41252. */
  41253. url: string;
  41254. /** @hidden */
  41255. _originalUrl: string;
  41256. /**
  41257. * Gets the sampling mode of the texture
  41258. */
  41259. samplingMode: number;
  41260. /**
  41261. * Gets a boolean indicating if the texture needs mipmaps generation
  41262. */
  41263. generateMipMaps: boolean;
  41264. /**
  41265. * Gets the number of samples used by the texture (WebGL2+ only)
  41266. */
  41267. samples: number;
  41268. /**
  41269. * Gets the type of the texture (int, float...)
  41270. */
  41271. type: number;
  41272. /**
  41273. * Gets the format of the texture (RGB, RGBA...)
  41274. */
  41275. format: number;
  41276. /**
  41277. * Observable called when the texture is loaded
  41278. */
  41279. onLoadedObservable: Observable<InternalTexture>;
  41280. /**
  41281. * Gets the width of the texture
  41282. */
  41283. width: number;
  41284. /**
  41285. * Gets the height of the texture
  41286. */
  41287. height: number;
  41288. /**
  41289. * Gets the depth of the texture
  41290. */
  41291. depth: number;
  41292. /**
  41293. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41294. */
  41295. baseWidth: number;
  41296. /**
  41297. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41298. */
  41299. baseHeight: number;
  41300. /**
  41301. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41302. */
  41303. baseDepth: number;
  41304. /**
  41305. * Gets a boolean indicating if the texture is inverted on Y axis
  41306. */
  41307. invertY: boolean;
  41308. /** @hidden */
  41309. _invertVScale: boolean;
  41310. /** @hidden */
  41311. _associatedChannel: number;
  41312. /** @hidden */
  41313. _source: InternalTextureSource;
  41314. /** @hidden */
  41315. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41316. /** @hidden */
  41317. _bufferView: Nullable<ArrayBufferView>;
  41318. /** @hidden */
  41319. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41320. /** @hidden */
  41321. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41322. /** @hidden */
  41323. _size: number;
  41324. /** @hidden */
  41325. _extension: string;
  41326. /** @hidden */
  41327. _files: Nullable<string[]>;
  41328. /** @hidden */
  41329. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41330. /** @hidden */
  41331. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41332. /** @hidden */
  41333. _framebuffer: Nullable<WebGLFramebuffer>;
  41334. /** @hidden */
  41335. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41336. /** @hidden */
  41337. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41338. /** @hidden */
  41339. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41340. /** @hidden */
  41341. _attachments: Nullable<number[]>;
  41342. /** @hidden */
  41343. _textureArray: Nullable<InternalTexture[]>;
  41344. /** @hidden */
  41345. _cachedCoordinatesMode: Nullable<number>;
  41346. /** @hidden */
  41347. _cachedWrapU: Nullable<number>;
  41348. /** @hidden */
  41349. _cachedWrapV: Nullable<number>;
  41350. /** @hidden */
  41351. _cachedWrapR: Nullable<number>;
  41352. /** @hidden */
  41353. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41354. /** @hidden */
  41355. _isDisabled: boolean;
  41356. /** @hidden */
  41357. _compression: Nullable<string>;
  41358. /** @hidden */
  41359. _generateStencilBuffer: boolean;
  41360. /** @hidden */
  41361. _generateDepthBuffer: boolean;
  41362. /** @hidden */
  41363. _comparisonFunction: number;
  41364. /** @hidden */
  41365. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41366. /** @hidden */
  41367. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41368. /** @hidden */
  41369. _sphericalPolynomialComputed: boolean;
  41370. /** @hidden */
  41371. _lodGenerationScale: number;
  41372. /** @hidden */
  41373. _lodGenerationOffset: number;
  41374. /** @hidden */
  41375. _depthStencilTexture: Nullable<InternalTexture>;
  41376. /** @hidden */
  41377. _colorTextureArray: Nullable<WebGLTexture>;
  41378. /** @hidden */
  41379. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41380. /** @hidden */
  41381. _lodTextureHigh: Nullable<BaseTexture>;
  41382. /** @hidden */
  41383. _lodTextureMid: Nullable<BaseTexture>;
  41384. /** @hidden */
  41385. _lodTextureLow: Nullable<BaseTexture>;
  41386. /** @hidden */
  41387. _isRGBD: boolean;
  41388. /** @hidden */
  41389. _linearSpecularLOD: boolean;
  41390. /** @hidden */
  41391. _irradianceTexture: Nullable<BaseTexture>;
  41392. /** @hidden */
  41393. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41394. /** @hidden */
  41395. _references: number;
  41396. /** @hidden */
  41397. _gammaSpace: Nullable<boolean>;
  41398. private _engine;
  41399. private _uniqueId;
  41400. private static _Counter;
  41401. /** Gets the unique id of the internal texture */
  41402. get uniqueId(): number;
  41403. /**
  41404. * Gets the Engine the texture belongs to.
  41405. * @returns The babylon engine
  41406. */
  41407. getEngine(): ThinEngine;
  41408. /**
  41409. * Gets the data source type of the texture
  41410. */
  41411. get source(): InternalTextureSource;
  41412. /**
  41413. * Creates a new InternalTexture
  41414. * @param engine defines the engine to use
  41415. * @param source defines the type of data that will be used
  41416. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41417. */
  41418. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41419. /**
  41420. * Increments the number of references (ie. the number of Texture that point to it)
  41421. */
  41422. incrementReferences(): void;
  41423. /**
  41424. * Change the size of the texture (not the size of the content)
  41425. * @param width defines the new width
  41426. * @param height defines the new height
  41427. * @param depth defines the new depth (1 by default)
  41428. */
  41429. updateSize(width: int, height: int, depth?: int): void;
  41430. /** @hidden */
  41431. _rebuild(): void;
  41432. /** @hidden */
  41433. _swapAndDie(target: InternalTexture): void;
  41434. /**
  41435. * Dispose the current allocated resources
  41436. */
  41437. dispose(): void;
  41438. }
  41439. }
  41440. declare module BABYLON {
  41441. /**
  41442. * Interface used to present a loading screen while loading a scene
  41443. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41444. */
  41445. export interface ILoadingScreen {
  41446. /**
  41447. * Function called to display the loading screen
  41448. */
  41449. displayLoadingUI: () => void;
  41450. /**
  41451. * Function called to hide the loading screen
  41452. */
  41453. hideLoadingUI: () => void;
  41454. /**
  41455. * Gets or sets the color to use for the background
  41456. */
  41457. loadingUIBackgroundColor: string;
  41458. /**
  41459. * Gets or sets the text to display while loading
  41460. */
  41461. loadingUIText: string;
  41462. }
  41463. /**
  41464. * Class used for the default loading screen
  41465. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41466. */
  41467. export class DefaultLoadingScreen implements ILoadingScreen {
  41468. private _renderingCanvas;
  41469. private _loadingText;
  41470. private _loadingDivBackgroundColor;
  41471. private _loadingDiv;
  41472. private _loadingTextDiv;
  41473. /** Gets or sets the logo url to use for the default loading screen */
  41474. static DefaultLogoUrl: string;
  41475. /** Gets or sets the spinner url to use for the default loading screen */
  41476. static DefaultSpinnerUrl: string;
  41477. /**
  41478. * Creates a new default loading screen
  41479. * @param _renderingCanvas defines the canvas used to render the scene
  41480. * @param _loadingText defines the default text to display
  41481. * @param _loadingDivBackgroundColor defines the default background color
  41482. */
  41483. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41484. /**
  41485. * Function called to display the loading screen
  41486. */
  41487. displayLoadingUI(): void;
  41488. /**
  41489. * Function called to hide the loading screen
  41490. */
  41491. hideLoadingUI(): void;
  41492. /**
  41493. * Gets or sets the text to display while loading
  41494. */
  41495. set loadingUIText(text: string);
  41496. get loadingUIText(): string;
  41497. /**
  41498. * Gets or sets the color to use for the background
  41499. */
  41500. get loadingUIBackgroundColor(): string;
  41501. set loadingUIBackgroundColor(color: string);
  41502. private _resizeLoadingUI;
  41503. }
  41504. }
  41505. declare module BABYLON {
  41506. /**
  41507. * Interface for any object that can request an animation frame
  41508. */
  41509. export interface ICustomAnimationFrameRequester {
  41510. /**
  41511. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41512. */
  41513. renderFunction?: Function;
  41514. /**
  41515. * Called to request the next frame to render to
  41516. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41517. */
  41518. requestAnimationFrame: Function;
  41519. /**
  41520. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41521. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41522. */
  41523. requestID?: number;
  41524. }
  41525. }
  41526. declare module BABYLON {
  41527. /**
  41528. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41529. */
  41530. export class PerformanceMonitor {
  41531. private _enabled;
  41532. private _rollingFrameTime;
  41533. private _lastFrameTimeMs;
  41534. /**
  41535. * constructor
  41536. * @param frameSampleSize The number of samples required to saturate the sliding window
  41537. */
  41538. constructor(frameSampleSize?: number);
  41539. /**
  41540. * Samples current frame
  41541. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41542. */
  41543. sampleFrame(timeMs?: number): void;
  41544. /**
  41545. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41546. */
  41547. get averageFrameTime(): number;
  41548. /**
  41549. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41550. */
  41551. get averageFrameTimeVariance(): number;
  41552. /**
  41553. * Returns the frame time of the most recent frame
  41554. */
  41555. get instantaneousFrameTime(): number;
  41556. /**
  41557. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41558. */
  41559. get averageFPS(): number;
  41560. /**
  41561. * Returns the average framerate in frames per second using the most recent frame time
  41562. */
  41563. get instantaneousFPS(): number;
  41564. /**
  41565. * Returns true if enough samples have been taken to completely fill the sliding window
  41566. */
  41567. get isSaturated(): boolean;
  41568. /**
  41569. * Enables contributions to the sliding window sample set
  41570. */
  41571. enable(): void;
  41572. /**
  41573. * Disables contributions to the sliding window sample set
  41574. * Samples will not be interpolated over the disabled period
  41575. */
  41576. disable(): void;
  41577. /**
  41578. * Returns true if sampling is enabled
  41579. */
  41580. get isEnabled(): boolean;
  41581. /**
  41582. * Resets performance monitor
  41583. */
  41584. reset(): void;
  41585. }
  41586. /**
  41587. * RollingAverage
  41588. *
  41589. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41590. */
  41591. export class RollingAverage {
  41592. /**
  41593. * Current average
  41594. */
  41595. average: number;
  41596. /**
  41597. * Current variance
  41598. */
  41599. variance: number;
  41600. protected _samples: Array<number>;
  41601. protected _sampleCount: number;
  41602. protected _pos: number;
  41603. protected _m2: number;
  41604. /**
  41605. * constructor
  41606. * @param length The number of samples required to saturate the sliding window
  41607. */
  41608. constructor(length: number);
  41609. /**
  41610. * Adds a sample to the sample set
  41611. * @param v The sample value
  41612. */
  41613. add(v: number): void;
  41614. /**
  41615. * Returns previously added values or null if outside of history or outside the sliding window domain
  41616. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41617. * @return Value previously recorded with add() or null if outside of range
  41618. */
  41619. history(i: number): number;
  41620. /**
  41621. * Returns true if enough samples have been taken to completely fill the sliding window
  41622. * @return true if sample-set saturated
  41623. */
  41624. isSaturated(): boolean;
  41625. /**
  41626. * Resets the rolling average (equivalent to 0 samples taken so far)
  41627. */
  41628. reset(): void;
  41629. /**
  41630. * Wraps a value around the sample range boundaries
  41631. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41632. * @return Wrapped position in sample range
  41633. */
  41634. protected _wrapPosition(i: number): number;
  41635. }
  41636. }
  41637. declare module BABYLON {
  41638. /**
  41639. * This class is used to track a performance counter which is number based.
  41640. * The user has access to many properties which give statistics of different nature.
  41641. *
  41642. * The implementer can track two kinds of Performance Counter: time and count.
  41643. * 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.
  41644. * 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.
  41645. */
  41646. export class PerfCounter {
  41647. /**
  41648. * Gets or sets a global boolean to turn on and off all the counters
  41649. */
  41650. static Enabled: boolean;
  41651. /**
  41652. * Returns the smallest value ever
  41653. */
  41654. get min(): number;
  41655. /**
  41656. * Returns the biggest value ever
  41657. */
  41658. get max(): number;
  41659. /**
  41660. * Returns the average value since the performance counter is running
  41661. */
  41662. get average(): number;
  41663. /**
  41664. * Returns the average value of the last second the counter was monitored
  41665. */
  41666. get lastSecAverage(): number;
  41667. /**
  41668. * Returns the current value
  41669. */
  41670. get current(): number;
  41671. /**
  41672. * Gets the accumulated total
  41673. */
  41674. get total(): number;
  41675. /**
  41676. * Gets the total value count
  41677. */
  41678. get count(): number;
  41679. /**
  41680. * Creates a new counter
  41681. */
  41682. constructor();
  41683. /**
  41684. * Call this method to start monitoring a new frame.
  41685. * 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.
  41686. */
  41687. fetchNewFrame(): void;
  41688. /**
  41689. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41690. * @param newCount the count value to add to the monitored count
  41691. * @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.
  41692. */
  41693. addCount(newCount: number, fetchResult: boolean): void;
  41694. /**
  41695. * Start monitoring this performance counter
  41696. */
  41697. beginMonitoring(): void;
  41698. /**
  41699. * Compute the time lapsed since the previous beginMonitoring() call.
  41700. * @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
  41701. */
  41702. endMonitoring(newFrame?: boolean): void;
  41703. private _fetchResult;
  41704. private _startMonitoringTime;
  41705. private _min;
  41706. private _max;
  41707. private _average;
  41708. private _current;
  41709. private _totalValueCount;
  41710. private _totalAccumulated;
  41711. private _lastSecAverage;
  41712. private _lastSecAccumulated;
  41713. private _lastSecTime;
  41714. private _lastSecValueCount;
  41715. }
  41716. }
  41717. declare module BABYLON {
  41718. interface ThinEngine {
  41719. /** @hidden */
  41720. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41721. /** @hidden */
  41722. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41729. */
  41730. export class Analyser {
  41731. /**
  41732. * Gets or sets the smoothing
  41733. * @ignorenaming
  41734. */
  41735. SMOOTHING: number;
  41736. /**
  41737. * Gets or sets the FFT table size
  41738. * @ignorenaming
  41739. */
  41740. FFT_SIZE: number;
  41741. /**
  41742. * Gets or sets the bar graph amplitude
  41743. * @ignorenaming
  41744. */
  41745. BARGRAPHAMPLITUDE: number;
  41746. /**
  41747. * Gets or sets the position of the debug canvas
  41748. * @ignorenaming
  41749. */
  41750. DEBUGCANVASPOS: {
  41751. x: number;
  41752. y: number;
  41753. };
  41754. /**
  41755. * Gets or sets the debug canvas size
  41756. * @ignorenaming
  41757. */
  41758. DEBUGCANVASSIZE: {
  41759. width: number;
  41760. height: number;
  41761. };
  41762. private _byteFreqs;
  41763. private _byteTime;
  41764. private _floatFreqs;
  41765. private _webAudioAnalyser;
  41766. private _debugCanvas;
  41767. private _debugCanvasContext;
  41768. private _scene;
  41769. private _registerFunc;
  41770. private _audioEngine;
  41771. /**
  41772. * Creates a new analyser
  41773. * @param scene defines hosting scene
  41774. */
  41775. constructor(scene: Scene);
  41776. /**
  41777. * Get the number of data values you will have to play with for the visualization
  41778. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41779. * @returns a number
  41780. */
  41781. getFrequencyBinCount(): number;
  41782. /**
  41783. * Gets the current frequency data as a byte array
  41784. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41785. * @returns a Uint8Array
  41786. */
  41787. getByteFrequencyData(): Uint8Array;
  41788. /**
  41789. * Gets the current waveform as a byte array
  41790. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41791. * @returns a Uint8Array
  41792. */
  41793. getByteTimeDomainData(): Uint8Array;
  41794. /**
  41795. * Gets the current frequency data as a float array
  41796. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41797. * @returns a Float32Array
  41798. */
  41799. getFloatFrequencyData(): Float32Array;
  41800. /**
  41801. * Renders the debug canvas
  41802. */
  41803. drawDebugCanvas(): void;
  41804. /**
  41805. * Stops rendering the debug canvas and removes it
  41806. */
  41807. stopDebugCanvas(): void;
  41808. /**
  41809. * Connects two audio nodes
  41810. * @param inputAudioNode defines first node to connect
  41811. * @param outputAudioNode defines second node to connect
  41812. */
  41813. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41814. /**
  41815. * Releases all associated resources
  41816. */
  41817. dispose(): void;
  41818. }
  41819. }
  41820. declare module BABYLON {
  41821. /**
  41822. * This represents an audio engine and it is responsible
  41823. * to play, synchronize and analyse sounds throughout the application.
  41824. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41825. */
  41826. export interface IAudioEngine extends IDisposable {
  41827. /**
  41828. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41829. */
  41830. readonly canUseWebAudio: boolean;
  41831. /**
  41832. * Gets the current AudioContext if available.
  41833. */
  41834. readonly audioContext: Nullable<AudioContext>;
  41835. /**
  41836. * The master gain node defines the global audio volume of your audio engine.
  41837. */
  41838. readonly masterGain: GainNode;
  41839. /**
  41840. * Gets whether or not mp3 are supported by your browser.
  41841. */
  41842. readonly isMP3supported: boolean;
  41843. /**
  41844. * Gets whether or not ogg are supported by your browser.
  41845. */
  41846. readonly isOGGsupported: boolean;
  41847. /**
  41848. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41849. * @ignoreNaming
  41850. */
  41851. WarnedWebAudioUnsupported: boolean;
  41852. /**
  41853. * Defines if the audio engine relies on a custom unlocked button.
  41854. * In this case, the embedded button will not be displayed.
  41855. */
  41856. useCustomUnlockedButton: boolean;
  41857. /**
  41858. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41859. */
  41860. readonly unlocked: boolean;
  41861. /**
  41862. * Event raised when audio has been unlocked on the browser.
  41863. */
  41864. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41865. /**
  41866. * Event raised when audio has been locked on the browser.
  41867. */
  41868. onAudioLockedObservable: Observable<IAudioEngine>;
  41869. /**
  41870. * Flags the audio engine in Locked state.
  41871. * This happens due to new browser policies preventing audio to autoplay.
  41872. */
  41873. lock(): void;
  41874. /**
  41875. * Unlocks the audio engine once a user action has been done on the dom.
  41876. * This is helpful to resume play once browser policies have been satisfied.
  41877. */
  41878. unlock(): void;
  41879. /**
  41880. * Gets the global volume sets on the master gain.
  41881. * @returns the global volume if set or -1 otherwise
  41882. */
  41883. getGlobalVolume(): number;
  41884. /**
  41885. * Sets the global volume of your experience (sets on the master gain).
  41886. * @param newVolume Defines the new global volume of the application
  41887. */
  41888. setGlobalVolume(newVolume: number): void;
  41889. /**
  41890. * Connect the audio engine to an audio analyser allowing some amazing
  41891. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41893. * @param analyser The analyser to connect to the engine
  41894. */
  41895. connectToAnalyser(analyser: Analyser): void;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. /**
  41900. * Defines the interface used by display changed events
  41901. */
  41902. export interface IDisplayChangedEventArgs {
  41903. /** Gets the vrDisplay object (if any) */
  41904. vrDisplay: Nullable<any>;
  41905. /** Gets a boolean indicating if webVR is supported */
  41906. vrSupported: boolean;
  41907. }
  41908. /**
  41909. * Defines the interface used by objects containing a viewport (like a camera)
  41910. */
  41911. interface IViewportOwnerLike {
  41912. /**
  41913. * Gets or sets the viewport
  41914. */
  41915. viewport: IViewportLike;
  41916. }
  41917. /**
  41918. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41919. */
  41920. export class Engine extends ThinEngine {
  41921. /** Defines that alpha blending is disabled */
  41922. static readonly ALPHA_DISABLE: number;
  41923. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41924. static readonly ALPHA_ADD: number;
  41925. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41926. static readonly ALPHA_COMBINE: number;
  41927. /** Defines that alpha blending to DEST - SRC * DEST */
  41928. static readonly ALPHA_SUBTRACT: number;
  41929. /** Defines that alpha blending to SRC * DEST */
  41930. static readonly ALPHA_MULTIPLY: number;
  41931. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41932. static readonly ALPHA_MAXIMIZED: number;
  41933. /** Defines that alpha blending to SRC + DEST */
  41934. static readonly ALPHA_ONEONE: number;
  41935. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41936. static readonly ALPHA_PREMULTIPLIED: number;
  41937. /**
  41938. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41939. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41940. */
  41941. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41942. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41943. static readonly ALPHA_INTERPOLATE: number;
  41944. /**
  41945. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41946. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41947. */
  41948. static readonly ALPHA_SCREENMODE: number;
  41949. /** Defines that the ressource is not delayed*/
  41950. static readonly DELAYLOADSTATE_NONE: number;
  41951. /** Defines that the ressource was successfully delay loaded */
  41952. static readonly DELAYLOADSTATE_LOADED: number;
  41953. /** Defines that the ressource is currently delay loading */
  41954. static readonly DELAYLOADSTATE_LOADING: number;
  41955. /** Defines that the ressource is delayed and has not started loading */
  41956. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41957. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41958. static readonly NEVER: number;
  41959. /** 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 */
  41960. static readonly ALWAYS: number;
  41961. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41962. static readonly LESS: number;
  41963. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41964. static readonly EQUAL: number;
  41965. /** 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 */
  41966. static readonly LEQUAL: number;
  41967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41968. static readonly GREATER: number;
  41969. /** 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 */
  41970. static readonly GEQUAL: number;
  41971. /** 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 */
  41972. static readonly NOTEQUAL: number;
  41973. /** Passed to stencilOperation to specify that stencil value must be kept */
  41974. static readonly KEEP: number;
  41975. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41976. static readonly REPLACE: number;
  41977. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41978. static readonly INCR: number;
  41979. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41980. static readonly DECR: number;
  41981. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41982. static readonly INVERT: number;
  41983. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41984. static readonly INCR_WRAP: number;
  41985. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41986. static readonly DECR_WRAP: number;
  41987. /** Texture is not repeating outside of 0..1 UVs */
  41988. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41989. /** Texture is repeating outside of 0..1 UVs */
  41990. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41991. /** Texture is repeating and mirrored */
  41992. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41993. /** ALPHA */
  41994. static readonly TEXTUREFORMAT_ALPHA: number;
  41995. /** LUMINANCE */
  41996. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41997. /** LUMINANCE_ALPHA */
  41998. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41999. /** RGB */
  42000. static readonly TEXTUREFORMAT_RGB: number;
  42001. /** RGBA */
  42002. static readonly TEXTUREFORMAT_RGBA: number;
  42003. /** RED */
  42004. static readonly TEXTUREFORMAT_RED: number;
  42005. /** RED (2nd reference) */
  42006. static readonly TEXTUREFORMAT_R: number;
  42007. /** RG */
  42008. static readonly TEXTUREFORMAT_RG: number;
  42009. /** RED_INTEGER */
  42010. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42011. /** RED_INTEGER (2nd reference) */
  42012. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42013. /** RG_INTEGER */
  42014. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42015. /** RGB_INTEGER */
  42016. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42017. /** RGBA_INTEGER */
  42018. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42019. /** UNSIGNED_BYTE */
  42020. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42021. /** UNSIGNED_BYTE (2nd reference) */
  42022. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42023. /** FLOAT */
  42024. static readonly TEXTURETYPE_FLOAT: number;
  42025. /** HALF_FLOAT */
  42026. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42027. /** BYTE */
  42028. static readonly TEXTURETYPE_BYTE: number;
  42029. /** SHORT */
  42030. static readonly TEXTURETYPE_SHORT: number;
  42031. /** UNSIGNED_SHORT */
  42032. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42033. /** INT */
  42034. static readonly TEXTURETYPE_INT: number;
  42035. /** UNSIGNED_INT */
  42036. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42037. /** UNSIGNED_SHORT_4_4_4_4 */
  42038. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42039. /** UNSIGNED_SHORT_5_5_5_1 */
  42040. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42041. /** UNSIGNED_SHORT_5_6_5 */
  42042. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42043. /** UNSIGNED_INT_2_10_10_10_REV */
  42044. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42045. /** UNSIGNED_INT_24_8 */
  42046. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42047. /** UNSIGNED_INT_10F_11F_11F_REV */
  42048. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42049. /** UNSIGNED_INT_5_9_9_9_REV */
  42050. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42051. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42052. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42053. /** nearest is mag = nearest and min = nearest and mip = none */
  42054. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42055. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42056. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42057. /** Trilinear is mag = linear and min = linear and mip = linear */
  42058. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42059. /** nearest is mag = nearest and min = nearest and mip = linear */
  42060. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42061. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42062. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42063. /** Trilinear is mag = linear and min = linear and mip = linear */
  42064. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42065. /** mag = nearest and min = nearest and mip = nearest */
  42066. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42067. /** mag = nearest and min = linear and mip = nearest */
  42068. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42069. /** mag = nearest and min = linear and mip = linear */
  42070. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42071. /** mag = nearest and min = linear and mip = none */
  42072. static readonly TEXTURE_NEAREST_LINEAR: number;
  42073. /** mag = nearest and min = nearest and mip = none */
  42074. static readonly TEXTURE_NEAREST_NEAREST: number;
  42075. /** mag = linear and min = nearest and mip = nearest */
  42076. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42077. /** mag = linear and min = nearest and mip = linear */
  42078. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42079. /** mag = linear and min = linear and mip = none */
  42080. static readonly TEXTURE_LINEAR_LINEAR: number;
  42081. /** mag = linear and min = nearest and mip = none */
  42082. static readonly TEXTURE_LINEAR_NEAREST: number;
  42083. /** Explicit coordinates mode */
  42084. static readonly TEXTURE_EXPLICIT_MODE: number;
  42085. /** Spherical coordinates mode */
  42086. static readonly TEXTURE_SPHERICAL_MODE: number;
  42087. /** Planar coordinates mode */
  42088. static readonly TEXTURE_PLANAR_MODE: number;
  42089. /** Cubic coordinates mode */
  42090. static readonly TEXTURE_CUBIC_MODE: number;
  42091. /** Projection coordinates mode */
  42092. static readonly TEXTURE_PROJECTION_MODE: number;
  42093. /** Skybox coordinates mode */
  42094. static readonly TEXTURE_SKYBOX_MODE: number;
  42095. /** Inverse Cubic coordinates mode */
  42096. static readonly TEXTURE_INVCUBIC_MODE: number;
  42097. /** Equirectangular coordinates mode */
  42098. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42099. /** Equirectangular Fixed coordinates mode */
  42100. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42101. /** Equirectangular Fixed Mirrored coordinates mode */
  42102. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42103. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42104. static readonly SCALEMODE_FLOOR: number;
  42105. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42106. static readonly SCALEMODE_NEAREST: number;
  42107. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42108. static readonly SCALEMODE_CEILING: number;
  42109. /**
  42110. * Returns the current npm package of the sdk
  42111. */
  42112. static get NpmPackage(): string;
  42113. /**
  42114. * Returns the current version of the framework
  42115. */
  42116. static get Version(): string;
  42117. /** Gets the list of created engines */
  42118. static get Instances(): Engine[];
  42119. /**
  42120. * Gets the latest created engine
  42121. */
  42122. static get LastCreatedEngine(): Nullable<Engine>;
  42123. /**
  42124. * Gets the latest created scene
  42125. */
  42126. static get LastCreatedScene(): Nullable<Scene>;
  42127. /**
  42128. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42129. * @param flag defines which part of the materials must be marked as dirty
  42130. * @param predicate defines a predicate used to filter which materials should be affected
  42131. */
  42132. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42133. /**
  42134. * Method called to create the default loading screen.
  42135. * This can be overriden in your own app.
  42136. * @param canvas The rendering canvas element
  42137. * @returns The loading screen
  42138. */
  42139. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42140. /**
  42141. * Method called to create the default rescale post process on each engine.
  42142. */
  42143. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42144. /**
  42145. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42146. **/
  42147. enableOfflineSupport: boolean;
  42148. /**
  42149. * 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)
  42150. **/
  42151. disableManifestCheck: boolean;
  42152. /**
  42153. * Gets the list of created scenes
  42154. */
  42155. scenes: Scene[];
  42156. /**
  42157. * Event raised when a new scene is created
  42158. */
  42159. onNewSceneAddedObservable: Observable<Scene>;
  42160. /**
  42161. * Gets the list of created postprocesses
  42162. */
  42163. postProcesses: PostProcess[];
  42164. /**
  42165. * Gets a boolean indicating if the pointer is currently locked
  42166. */
  42167. isPointerLock: boolean;
  42168. /**
  42169. * Observable event triggered each time the rendering canvas is resized
  42170. */
  42171. onResizeObservable: Observable<Engine>;
  42172. /**
  42173. * Observable event triggered each time the canvas loses focus
  42174. */
  42175. onCanvasBlurObservable: Observable<Engine>;
  42176. /**
  42177. * Observable event triggered each time the canvas gains focus
  42178. */
  42179. onCanvasFocusObservable: Observable<Engine>;
  42180. /**
  42181. * Observable event triggered each time the canvas receives pointerout event
  42182. */
  42183. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42184. /**
  42185. * Observable raised when the engine begins a new frame
  42186. */
  42187. onBeginFrameObservable: Observable<Engine>;
  42188. /**
  42189. * If set, will be used to request the next animation frame for the render loop
  42190. */
  42191. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42192. /**
  42193. * Observable raised when the engine ends the current frame
  42194. */
  42195. onEndFrameObservable: Observable<Engine>;
  42196. /**
  42197. * Observable raised when the engine is about to compile a shader
  42198. */
  42199. onBeforeShaderCompilationObservable: Observable<Engine>;
  42200. /**
  42201. * Observable raised when the engine has jsut compiled a shader
  42202. */
  42203. onAfterShaderCompilationObservable: Observable<Engine>;
  42204. /**
  42205. * Gets the audio engine
  42206. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42207. * @ignorenaming
  42208. */
  42209. static audioEngine: IAudioEngine;
  42210. /**
  42211. * Default AudioEngine factory responsible of creating the Audio Engine.
  42212. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42213. */
  42214. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42215. /**
  42216. * Default offline support factory responsible of creating a tool used to store data locally.
  42217. * By default, this will create a Database object if the workload has been embedded.
  42218. */
  42219. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42220. private _loadingScreen;
  42221. private _pointerLockRequested;
  42222. private _rescalePostProcess;
  42223. protected _deterministicLockstep: boolean;
  42224. protected _lockstepMaxSteps: number;
  42225. protected _timeStep: number;
  42226. protected get _supportsHardwareTextureRescaling(): boolean;
  42227. private _fps;
  42228. private _deltaTime;
  42229. /** @hidden */
  42230. _drawCalls: PerfCounter;
  42231. /** 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 */
  42232. canvasTabIndex: number;
  42233. /**
  42234. * Turn this value on if you want to pause FPS computation when in background
  42235. */
  42236. disablePerformanceMonitorInBackground: boolean;
  42237. private _performanceMonitor;
  42238. /**
  42239. * Gets the performance monitor attached to this engine
  42240. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42241. */
  42242. get performanceMonitor(): PerformanceMonitor;
  42243. private _onFocus;
  42244. private _onBlur;
  42245. private _onCanvasPointerOut;
  42246. private _onCanvasBlur;
  42247. private _onCanvasFocus;
  42248. private _onFullscreenChange;
  42249. private _onPointerLockChange;
  42250. /**
  42251. * Gets the HTML element used to attach event listeners
  42252. * @returns a HTML element
  42253. */
  42254. getInputElement(): Nullable<HTMLElement>;
  42255. /**
  42256. * Creates a new engine
  42257. * @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
  42258. * @param antialias defines enable antialiasing (default: false)
  42259. * @param options defines further options to be sent to the getContext() function
  42260. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42261. */
  42262. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42263. /**
  42264. * Shared initialization across engines types.
  42265. * @param canvas The canvas associated with this instance of the engine.
  42266. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42267. * @param audioEngine Defines if an audio engine should be created by default
  42268. */
  42269. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42270. /**
  42271. * Gets current aspect ratio
  42272. * @param viewportOwner defines the camera to use to get the aspect ratio
  42273. * @param useScreen defines if screen size must be used (or the current render target if any)
  42274. * @returns a number defining the aspect ratio
  42275. */
  42276. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42277. /**
  42278. * Gets current screen aspect ratio
  42279. * @returns a number defining the aspect ratio
  42280. */
  42281. getScreenAspectRatio(): number;
  42282. /**
  42283. * Gets the client rect of the HTML canvas attached with the current webGL context
  42284. * @returns a client rectanglee
  42285. */
  42286. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42287. /**
  42288. * Gets the client rect of the HTML element used for events
  42289. * @returns a client rectanglee
  42290. */
  42291. getInputElementClientRect(): Nullable<ClientRect>;
  42292. /**
  42293. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42294. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42295. * @returns true if engine is in deterministic lock step mode
  42296. */
  42297. isDeterministicLockStep(): boolean;
  42298. /**
  42299. * Gets the max steps when engine is running in deterministic lock step
  42300. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42301. * @returns the max steps
  42302. */
  42303. getLockstepMaxSteps(): number;
  42304. /**
  42305. * Returns the time in ms between steps when using deterministic lock step.
  42306. * @returns time step in (ms)
  42307. */
  42308. getTimeStep(): number;
  42309. /**
  42310. * Force the mipmap generation for the given render target texture
  42311. * @param texture defines the render target texture to use
  42312. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42313. */
  42314. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42315. /** States */
  42316. /**
  42317. * Set various states to the webGL context
  42318. * @param culling defines backface culling state
  42319. * @param zOffset defines the value to apply to zOffset (0 by default)
  42320. * @param force defines if states must be applied even if cache is up to date
  42321. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42322. */
  42323. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42324. /**
  42325. * Set the z offset to apply to current rendering
  42326. * @param value defines the offset to apply
  42327. */
  42328. setZOffset(value: number): void;
  42329. /**
  42330. * Gets the current value of the zOffset
  42331. * @returns the current zOffset state
  42332. */
  42333. getZOffset(): number;
  42334. /**
  42335. * Gets a boolean indicating if depth testing is enabled
  42336. * @returns the current state
  42337. */
  42338. getDepthBuffer(): boolean;
  42339. /**
  42340. * Enable or disable depth buffering
  42341. * @param enable defines the state to set
  42342. */
  42343. setDepthBuffer(enable: boolean): void;
  42344. /**
  42345. * Gets a boolean indicating if depth writing is enabled
  42346. * @returns the current depth writing state
  42347. */
  42348. getDepthWrite(): boolean;
  42349. /**
  42350. * Enable or disable depth writing
  42351. * @param enable defines the state to set
  42352. */
  42353. setDepthWrite(enable: boolean): void;
  42354. /**
  42355. * Gets a boolean indicating if stencil buffer is enabled
  42356. * @returns the current stencil buffer state
  42357. */
  42358. getStencilBuffer(): boolean;
  42359. /**
  42360. * Enable or disable the stencil buffer
  42361. * @param enable defines if the stencil buffer must be enabled or disabled
  42362. */
  42363. setStencilBuffer(enable: boolean): void;
  42364. /**
  42365. * Gets the current stencil mask
  42366. * @returns a number defining the new stencil mask to use
  42367. */
  42368. getStencilMask(): number;
  42369. /**
  42370. * Sets the current stencil mask
  42371. * @param mask defines the new stencil mask to use
  42372. */
  42373. setStencilMask(mask: number): void;
  42374. /**
  42375. * Gets the current stencil function
  42376. * @returns a number defining the stencil function to use
  42377. */
  42378. getStencilFunction(): number;
  42379. /**
  42380. * Gets the current stencil reference value
  42381. * @returns a number defining the stencil reference value to use
  42382. */
  42383. getStencilFunctionReference(): number;
  42384. /**
  42385. * Gets the current stencil mask
  42386. * @returns a number defining the stencil mask to use
  42387. */
  42388. getStencilFunctionMask(): number;
  42389. /**
  42390. * Sets the current stencil function
  42391. * @param stencilFunc defines the new stencil function to use
  42392. */
  42393. setStencilFunction(stencilFunc: number): void;
  42394. /**
  42395. * Sets the current stencil reference
  42396. * @param reference defines the new stencil reference to use
  42397. */
  42398. setStencilFunctionReference(reference: number): void;
  42399. /**
  42400. * Sets the current stencil mask
  42401. * @param mask defines the new stencil mask to use
  42402. */
  42403. setStencilFunctionMask(mask: number): void;
  42404. /**
  42405. * Gets the current stencil operation when stencil fails
  42406. * @returns a number defining stencil operation to use when stencil fails
  42407. */
  42408. getStencilOperationFail(): number;
  42409. /**
  42410. * Gets the current stencil operation when depth fails
  42411. * @returns a number defining stencil operation to use when depth fails
  42412. */
  42413. getStencilOperationDepthFail(): number;
  42414. /**
  42415. * Gets the current stencil operation when stencil passes
  42416. * @returns a number defining stencil operation to use when stencil passes
  42417. */
  42418. getStencilOperationPass(): number;
  42419. /**
  42420. * Sets the stencil operation to use when stencil fails
  42421. * @param operation defines the stencil operation to use when stencil fails
  42422. */
  42423. setStencilOperationFail(operation: number): void;
  42424. /**
  42425. * Sets the stencil operation to use when depth fails
  42426. * @param operation defines the stencil operation to use when depth fails
  42427. */
  42428. setStencilOperationDepthFail(operation: number): void;
  42429. /**
  42430. * Sets the stencil operation to use when stencil passes
  42431. * @param operation defines the stencil operation to use when stencil passes
  42432. */
  42433. setStencilOperationPass(operation: number): void;
  42434. /**
  42435. * Sets a boolean indicating if the dithering state is enabled or disabled
  42436. * @param value defines the dithering state
  42437. */
  42438. setDitheringState(value: boolean): void;
  42439. /**
  42440. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42441. * @param value defines the rasterizer state
  42442. */
  42443. setRasterizerState(value: boolean): void;
  42444. /**
  42445. * Gets the current depth function
  42446. * @returns a number defining the depth function
  42447. */
  42448. getDepthFunction(): Nullable<number>;
  42449. /**
  42450. * Sets the current depth function
  42451. * @param depthFunc defines the function to use
  42452. */
  42453. setDepthFunction(depthFunc: number): void;
  42454. /**
  42455. * Sets the current depth function to GREATER
  42456. */
  42457. setDepthFunctionToGreater(): void;
  42458. /**
  42459. * Sets the current depth function to GEQUAL
  42460. */
  42461. setDepthFunctionToGreaterOrEqual(): void;
  42462. /**
  42463. * Sets the current depth function to LESS
  42464. */
  42465. setDepthFunctionToLess(): void;
  42466. /**
  42467. * Sets the current depth function to LEQUAL
  42468. */
  42469. setDepthFunctionToLessOrEqual(): void;
  42470. private _cachedStencilBuffer;
  42471. private _cachedStencilFunction;
  42472. private _cachedStencilMask;
  42473. private _cachedStencilOperationPass;
  42474. private _cachedStencilOperationFail;
  42475. private _cachedStencilOperationDepthFail;
  42476. private _cachedStencilReference;
  42477. /**
  42478. * Caches the the state of the stencil buffer
  42479. */
  42480. cacheStencilState(): void;
  42481. /**
  42482. * Restores the state of the stencil buffer
  42483. */
  42484. restoreStencilState(): void;
  42485. /**
  42486. * Directly set the WebGL Viewport
  42487. * @param x defines the x coordinate of the viewport (in screen space)
  42488. * @param y defines the y coordinate of the viewport (in screen space)
  42489. * @param width defines the width of the viewport (in screen space)
  42490. * @param height defines the height of the viewport (in screen space)
  42491. * @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
  42492. */
  42493. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42494. /**
  42495. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42496. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42497. * @param y defines the y-coordinate of the corner of the clear rectangle
  42498. * @param width defines the width of the clear rectangle
  42499. * @param height defines the height of the clear rectangle
  42500. * @param clearColor defines the clear color
  42501. */
  42502. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42503. /**
  42504. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42505. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42506. * @param y defines the y-coordinate of the corner of the clear rectangle
  42507. * @param width defines the width of the clear rectangle
  42508. * @param height defines the height of the clear rectangle
  42509. */
  42510. enableScissor(x: number, y: number, width: number, height: number): void;
  42511. /**
  42512. * Disable previously set scissor test rectangle
  42513. */
  42514. disableScissor(): void;
  42515. protected _reportDrawCall(): void;
  42516. /**
  42517. * Initializes a webVR display and starts listening to display change events
  42518. * The onVRDisplayChangedObservable will be notified upon these changes
  42519. * @returns The onVRDisplayChangedObservable
  42520. */
  42521. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42522. /** @hidden */
  42523. _prepareVRComponent(): void;
  42524. /** @hidden */
  42525. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42526. /** @hidden */
  42527. _submitVRFrame(): void;
  42528. /**
  42529. * Call this function to leave webVR mode
  42530. * Will do nothing if webVR is not supported or if there is no webVR device
  42531. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42532. */
  42533. disableVR(): void;
  42534. /**
  42535. * Gets a boolean indicating that the system is in VR mode and is presenting
  42536. * @returns true if VR mode is engaged
  42537. */
  42538. isVRPresenting(): boolean;
  42539. /** @hidden */
  42540. _requestVRFrame(): void;
  42541. /** @hidden */
  42542. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42543. /**
  42544. * Gets the source code of the vertex shader associated with a specific webGL program
  42545. * @param program defines the program to use
  42546. * @returns a string containing the source code of the vertex shader associated with the program
  42547. */
  42548. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42549. /**
  42550. * Gets the source code of the fragment shader associated with a specific webGL program
  42551. * @param program defines the program to use
  42552. * @returns a string containing the source code of the fragment shader associated with the program
  42553. */
  42554. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42555. /**
  42556. * Sets a depth stencil texture from a render target to the according uniform.
  42557. * @param channel The texture channel
  42558. * @param uniform The uniform to set
  42559. * @param texture The render target texture containing the depth stencil texture to apply
  42560. * @param name The texture name
  42561. */
  42562. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42563. /**
  42564. * Sets a texture to the webGL context from a postprocess
  42565. * @param channel defines the channel to use
  42566. * @param postProcess defines the source postprocess
  42567. * @param name name of the channel
  42568. */
  42569. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42570. /**
  42571. * Binds the output of the passed in post process to the texture channel specified
  42572. * @param channel The channel the texture should be bound to
  42573. * @param postProcess The post process which's output should be bound
  42574. * @param name name of the channel
  42575. */
  42576. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42577. protected _rebuildBuffers(): void;
  42578. /** @hidden */
  42579. _renderFrame(): void;
  42580. _renderLoop(): void;
  42581. /** @hidden */
  42582. _renderViews(): boolean;
  42583. /**
  42584. * Toggle full screen mode
  42585. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42586. */
  42587. switchFullscreen(requestPointerLock: boolean): void;
  42588. /**
  42589. * Enters full screen mode
  42590. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42591. */
  42592. enterFullscreen(requestPointerLock: boolean): void;
  42593. /**
  42594. * Exits full screen mode
  42595. */
  42596. exitFullscreen(): void;
  42597. /**
  42598. * Enters Pointerlock mode
  42599. */
  42600. enterPointerlock(): void;
  42601. /**
  42602. * Exits Pointerlock mode
  42603. */
  42604. exitPointerlock(): void;
  42605. /**
  42606. * Begin a new frame
  42607. */
  42608. beginFrame(): void;
  42609. /**
  42610. * End the current frame
  42611. */
  42612. endFrame(): void;
  42613. /**
  42614. * Resize the view according to the canvas' size
  42615. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42616. */
  42617. resize(forceSetSize?: boolean): void;
  42618. /**
  42619. * Force a specific size of the canvas
  42620. * @param width defines the new canvas' width
  42621. * @param height defines the new canvas' height
  42622. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42623. * @returns true if the size was changed
  42624. */
  42625. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42626. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42627. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42628. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42629. _releaseTexture(texture: InternalTexture): void;
  42630. /**
  42631. * @hidden
  42632. * Rescales a texture
  42633. * @param source input texutre
  42634. * @param destination destination texture
  42635. * @param scene scene to use to render the resize
  42636. * @param internalFormat format to use when resizing
  42637. * @param onComplete callback to be called when resize has completed
  42638. */
  42639. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42640. /**
  42641. * Gets the current framerate
  42642. * @returns a number representing the framerate
  42643. */
  42644. getFps(): number;
  42645. /**
  42646. * Gets the time spent between current and previous frame
  42647. * @returns a number representing the delta time in ms
  42648. */
  42649. getDeltaTime(): number;
  42650. private _measureFps;
  42651. /** @hidden */
  42652. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42653. /**
  42654. * Updates the sample count of a render target texture
  42655. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42656. * @param texture defines the texture to update
  42657. * @param samples defines the sample count to set
  42658. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42659. */
  42660. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42661. /**
  42662. * Updates a depth texture Comparison Mode and Function.
  42663. * If the comparison Function is equal to 0, the mode will be set to none.
  42664. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42665. * @param texture The texture to set the comparison function for
  42666. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42667. */
  42668. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42669. /**
  42670. * Creates a webGL buffer to use with instanciation
  42671. * @param capacity defines the size of the buffer
  42672. * @returns the webGL buffer
  42673. */
  42674. createInstancesBuffer(capacity: number): DataBuffer;
  42675. /**
  42676. * Delete a webGL buffer used with instanciation
  42677. * @param buffer defines the webGL buffer to delete
  42678. */
  42679. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42680. private _clientWaitAsync;
  42681. /** @hidden */
  42682. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42683. dispose(): void;
  42684. private _disableTouchAction;
  42685. /**
  42686. * Display the loading screen
  42687. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42688. */
  42689. displayLoadingUI(): void;
  42690. /**
  42691. * Hide the loading screen
  42692. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42693. */
  42694. hideLoadingUI(): void;
  42695. /**
  42696. * Gets the current loading screen object
  42697. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42698. */
  42699. get loadingScreen(): ILoadingScreen;
  42700. /**
  42701. * Sets the current loading screen object
  42702. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42703. */
  42704. set loadingScreen(loadingScreen: ILoadingScreen);
  42705. /**
  42706. * Sets the current loading screen text
  42707. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42708. */
  42709. set loadingUIText(text: string);
  42710. /**
  42711. * Sets the current loading screen background color
  42712. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42713. */
  42714. set loadingUIBackgroundColor(color: string);
  42715. /** Pointerlock and fullscreen */
  42716. /**
  42717. * Ask the browser to promote the current element to pointerlock mode
  42718. * @param element defines the DOM element to promote
  42719. */
  42720. static _RequestPointerlock(element: HTMLElement): void;
  42721. /**
  42722. * Asks the browser to exit pointerlock mode
  42723. */
  42724. static _ExitPointerlock(): void;
  42725. /**
  42726. * Ask the browser to promote the current element to fullscreen rendering mode
  42727. * @param element defines the DOM element to promote
  42728. */
  42729. static _RequestFullscreen(element: HTMLElement): void;
  42730. /**
  42731. * Asks the browser to exit fullscreen mode
  42732. */
  42733. static _ExitFullscreen(): void;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42739. * during the life time of the application.
  42740. */
  42741. export class EngineStore {
  42742. /** Gets the list of created engines */
  42743. static Instances: Engine[];
  42744. /** @hidden */
  42745. static _LastCreatedScene: Nullable<Scene>;
  42746. /**
  42747. * Gets the latest created engine
  42748. */
  42749. static get LastCreatedEngine(): Nullable<Engine>;
  42750. /**
  42751. * Gets the latest created scene
  42752. */
  42753. static get LastCreatedScene(): Nullable<Scene>;
  42754. /**
  42755. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42756. * @ignorenaming
  42757. */
  42758. static UseFallbackTexture: boolean;
  42759. /**
  42760. * Texture content used if a texture cannot loaded
  42761. * @ignorenaming
  42762. */
  42763. static FallbackTexture: string;
  42764. }
  42765. }
  42766. declare module BABYLON {
  42767. /**
  42768. * Helper class that provides a small promise polyfill
  42769. */
  42770. export class PromisePolyfill {
  42771. /**
  42772. * Static function used to check if the polyfill is required
  42773. * If this is the case then the function will inject the polyfill to window.Promise
  42774. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42775. */
  42776. static Apply(force?: boolean): void;
  42777. }
  42778. }
  42779. declare module BABYLON {
  42780. /**
  42781. * Interface for screenshot methods with describe argument called `size` as object with options
  42782. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42783. */
  42784. export interface IScreenshotSize {
  42785. /**
  42786. * number in pixels for canvas height
  42787. */
  42788. height?: number;
  42789. /**
  42790. * multiplier allowing render at a higher or lower resolution
  42791. * If value is defined then height and width will be ignored and taken from camera
  42792. */
  42793. precision?: number;
  42794. /**
  42795. * number in pixels for canvas width
  42796. */
  42797. width?: number;
  42798. }
  42799. }
  42800. declare module BABYLON {
  42801. interface IColor4Like {
  42802. r: float;
  42803. g: float;
  42804. b: float;
  42805. a: float;
  42806. }
  42807. /**
  42808. * Class containing a set of static utilities functions
  42809. */
  42810. export class Tools {
  42811. /**
  42812. * Gets or sets the base URL to use to load assets
  42813. */
  42814. static get BaseUrl(): string;
  42815. static set BaseUrl(value: string);
  42816. /**
  42817. * Enable/Disable Custom HTTP Request Headers globally.
  42818. * default = false
  42819. * @see CustomRequestHeaders
  42820. */
  42821. static UseCustomRequestHeaders: boolean;
  42822. /**
  42823. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42824. * i.e. when loading files, where the server/service expects an Authorization header
  42825. */
  42826. static CustomRequestHeaders: {
  42827. [key: string]: string;
  42828. };
  42829. /**
  42830. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42831. */
  42832. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42833. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42834. /**
  42835. * Default behaviour for cors in the application.
  42836. * It can be a string if the expected behavior is identical in the entire app.
  42837. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42838. */
  42839. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42840. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42841. /**
  42842. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42843. * @ignorenaming
  42844. */
  42845. static get UseFallbackTexture(): boolean;
  42846. static set UseFallbackTexture(value: boolean);
  42847. /**
  42848. * Use this object to register external classes like custom textures or material
  42849. * to allow the laoders to instantiate them
  42850. */
  42851. static get RegisteredExternalClasses(): {
  42852. [key: string]: Object;
  42853. };
  42854. static set RegisteredExternalClasses(classes: {
  42855. [key: string]: Object;
  42856. });
  42857. /**
  42858. * Texture content used if a texture cannot loaded
  42859. * @ignorenaming
  42860. */
  42861. static get fallbackTexture(): string;
  42862. static set fallbackTexture(value: string);
  42863. /**
  42864. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42865. * @param u defines the coordinate on X axis
  42866. * @param v defines the coordinate on Y axis
  42867. * @param width defines the width of the source data
  42868. * @param height defines the height of the source data
  42869. * @param pixels defines the source byte array
  42870. * @param color defines the output color
  42871. */
  42872. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42873. /**
  42874. * Interpolates between a and b via alpha
  42875. * @param a The lower value (returned when alpha = 0)
  42876. * @param b The upper value (returned when alpha = 1)
  42877. * @param alpha The interpolation-factor
  42878. * @return The mixed value
  42879. */
  42880. static Mix(a: number, b: number, alpha: number): number;
  42881. /**
  42882. * Tries to instantiate a new object from a given class name
  42883. * @param className defines the class name to instantiate
  42884. * @returns the new object or null if the system was not able to do the instantiation
  42885. */
  42886. static Instantiate(className: string): any;
  42887. /**
  42888. * Provides a slice function that will work even on IE
  42889. * @param data defines the array to slice
  42890. * @param start defines the start of the data (optional)
  42891. * @param end defines the end of the data (optional)
  42892. * @returns the new sliced array
  42893. */
  42894. static Slice<T>(data: T, start?: number, end?: number): T;
  42895. /**
  42896. * Provides a slice function that will work even on IE
  42897. * The difference between this and Slice is that this will force-convert to array
  42898. * @param data defines the array to slice
  42899. * @param start defines the start of the data (optional)
  42900. * @param end defines the end of the data (optional)
  42901. * @returns the new sliced array
  42902. */
  42903. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42904. /**
  42905. * Polyfill for setImmediate
  42906. * @param action defines the action to execute after the current execution block
  42907. */
  42908. static SetImmediate(action: () => void): void;
  42909. /**
  42910. * Function indicating if a number is an exponent of 2
  42911. * @param value defines the value to test
  42912. * @returns true if the value is an exponent of 2
  42913. */
  42914. static IsExponentOfTwo(value: number): boolean;
  42915. private static _tmpFloatArray;
  42916. /**
  42917. * Returns the nearest 32-bit single precision float representation of a Number
  42918. * @param value A Number. If the parameter is of a different type, it will get converted
  42919. * to a number or to NaN if it cannot be converted
  42920. * @returns number
  42921. */
  42922. static FloatRound(value: number): number;
  42923. /**
  42924. * Extracts the filename from a path
  42925. * @param path defines the path to use
  42926. * @returns the filename
  42927. */
  42928. static GetFilename(path: string): string;
  42929. /**
  42930. * Extracts the "folder" part of a path (everything before the filename).
  42931. * @param uri The URI to extract the info from
  42932. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42933. * @returns The "folder" part of the path
  42934. */
  42935. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42936. /**
  42937. * Extracts text content from a DOM element hierarchy
  42938. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42939. */
  42940. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42941. /**
  42942. * Convert an angle in radians to degrees
  42943. * @param angle defines the angle to convert
  42944. * @returns the angle in degrees
  42945. */
  42946. static ToDegrees(angle: number): number;
  42947. /**
  42948. * Convert an angle in degrees to radians
  42949. * @param angle defines the angle to convert
  42950. * @returns the angle in radians
  42951. */
  42952. static ToRadians(angle: number): number;
  42953. /**
  42954. * Returns an array if obj is not an array
  42955. * @param obj defines the object to evaluate as an array
  42956. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42957. * @returns either obj directly if obj is an array or a new array containing obj
  42958. */
  42959. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42960. /**
  42961. * Gets the pointer prefix to use
  42962. * @param engine defines the engine we are finding the prefix for
  42963. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42964. */
  42965. static GetPointerPrefix(engine: Engine): string;
  42966. /**
  42967. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42968. * @param url define the url we are trying
  42969. * @param element define the dom element where to configure the cors policy
  42970. */
  42971. static SetCorsBehavior(url: string | string[], element: {
  42972. crossOrigin: string | null;
  42973. }): void;
  42974. /**
  42975. * Removes unwanted characters from an url
  42976. * @param url defines the url to clean
  42977. * @returns the cleaned url
  42978. */
  42979. static CleanUrl(url: string): string;
  42980. /**
  42981. * Gets or sets a function used to pre-process url before using them to load assets
  42982. */
  42983. static get PreprocessUrl(): (url: string) => string;
  42984. static set PreprocessUrl(processor: (url: string) => string);
  42985. /**
  42986. * Loads an image as an HTMLImageElement.
  42987. * @param input url string, ArrayBuffer, or Blob to load
  42988. * @param onLoad callback called when the image successfully loads
  42989. * @param onError callback called when the image fails to load
  42990. * @param offlineProvider offline provider for caching
  42991. * @param mimeType optional mime type
  42992. * @returns the HTMLImageElement of the loaded image
  42993. */
  42994. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42995. /**
  42996. * Loads a file from a url
  42997. * @param url url string, ArrayBuffer, or Blob to load
  42998. * @param onSuccess callback called when the file successfully loads
  42999. * @param onProgress callback called while file is loading (if the server supports this mode)
  43000. * @param offlineProvider defines the offline provider for caching
  43001. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43002. * @param onError callback called when the file fails to load
  43003. * @returns a file request object
  43004. */
  43005. 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;
  43006. /**
  43007. * Loads a file from a url
  43008. * @param url the file url to load
  43009. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43010. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43011. */
  43012. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43013. /**
  43014. * Load a script (identified by an url). When the url returns, the
  43015. * content of this file is added into a new script element, attached to the DOM (body element)
  43016. * @param scriptUrl defines the url of the script to laod
  43017. * @param onSuccess defines the callback called when the script is loaded
  43018. * @param onError defines the callback to call if an error occurs
  43019. * @param scriptId defines the id of the script element
  43020. */
  43021. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43022. /**
  43023. * Load an asynchronous script (identified by an url). When the url returns, the
  43024. * content of this file is added into a new script element, attached to the DOM (body element)
  43025. * @param scriptUrl defines the url of the script to laod
  43026. * @param scriptId defines the id of the script element
  43027. * @returns a promise request object
  43028. */
  43029. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43030. /**
  43031. * Loads a file from a blob
  43032. * @param fileToLoad defines the blob to use
  43033. * @param callback defines the callback to call when data is loaded
  43034. * @param progressCallback defines the callback to call during loading process
  43035. * @returns a file request object
  43036. */
  43037. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43038. /**
  43039. * Reads a file from a File object
  43040. * @param file defines the file to load
  43041. * @param onSuccess defines the callback to call when data is loaded
  43042. * @param onProgress defines the callback to call during loading process
  43043. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43044. * @param onError defines the callback to call when an error occurs
  43045. * @returns a file request object
  43046. */
  43047. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43048. /**
  43049. * Creates a data url from a given string content
  43050. * @param content defines the content to convert
  43051. * @returns the new data url link
  43052. */
  43053. static FileAsURL(content: string): string;
  43054. /**
  43055. * Format the given number to a specific decimal format
  43056. * @param value defines the number to format
  43057. * @param decimals defines the number of decimals to use
  43058. * @returns the formatted string
  43059. */
  43060. static Format(value: number, decimals?: number): string;
  43061. /**
  43062. * Tries to copy an object by duplicating every property
  43063. * @param source defines the source object
  43064. * @param destination defines the target object
  43065. * @param doNotCopyList defines a list of properties to avoid
  43066. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43067. */
  43068. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43069. /**
  43070. * Gets a boolean indicating if the given object has no own property
  43071. * @param obj defines the object to test
  43072. * @returns true if object has no own property
  43073. */
  43074. static IsEmpty(obj: any): boolean;
  43075. /**
  43076. * Function used to register events at window level
  43077. * @param windowElement defines the Window object to use
  43078. * @param events defines the events to register
  43079. */
  43080. static RegisterTopRootEvents(windowElement: Window, events: {
  43081. name: string;
  43082. handler: Nullable<(e: FocusEvent) => any>;
  43083. }[]): void;
  43084. /**
  43085. * Function used to unregister events from window level
  43086. * @param windowElement defines the Window object to use
  43087. * @param events defines the events to unregister
  43088. */
  43089. static UnregisterTopRootEvents(windowElement: Window, events: {
  43090. name: string;
  43091. handler: Nullable<(e: FocusEvent) => any>;
  43092. }[]): void;
  43093. /**
  43094. * @ignore
  43095. */
  43096. static _ScreenshotCanvas: HTMLCanvasElement;
  43097. /**
  43098. * Dumps the current bound framebuffer
  43099. * @param width defines the rendering width
  43100. * @param height defines the rendering height
  43101. * @param engine defines the hosting engine
  43102. * @param successCallback defines the callback triggered once the data are available
  43103. * @param mimeType defines the mime type of the result
  43104. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43105. * @return a void promise
  43106. */
  43107. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43108. /**
  43109. * Dumps an array buffer
  43110. * @param width defines the rendering width
  43111. * @param height defines the rendering height
  43112. * @param data the data array
  43113. * @param successCallback defines the callback triggered once the data are available
  43114. * @param mimeType defines the mime type of the result
  43115. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43116. * @param invertY true to invert the picture in the Y dimension
  43117. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43118. */
  43119. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43120. /**
  43121. * Dumps an array buffer
  43122. * @param width defines the rendering width
  43123. * @param height defines the rendering height
  43124. * @param data the data array
  43125. * @param successCallback defines the callback triggered once the data are available
  43126. * @param mimeType defines the mime type of the result
  43127. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43128. * @param invertY true to invert the picture in the Y dimension
  43129. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43130. * @return a promise that resolve to the final data
  43131. */
  43132. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43133. /**
  43134. * Converts the canvas data to blob.
  43135. * This acts as a polyfill for browsers not supporting the to blob function.
  43136. * @param canvas Defines the canvas to extract the data from
  43137. * @param successCallback Defines the callback triggered once the data are available
  43138. * @param mimeType Defines the mime type of the result
  43139. */
  43140. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43141. /**
  43142. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43143. * @param successCallback defines the callback triggered once the data are available
  43144. * @param mimeType defines the mime type of the result
  43145. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43146. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43147. */
  43148. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43149. /**
  43150. * Downloads a blob in the browser
  43151. * @param blob defines the blob to download
  43152. * @param fileName defines the name of the downloaded file
  43153. */
  43154. static Download(blob: Blob, fileName: string): void;
  43155. /**
  43156. * Will return the right value of the noPreventDefault variable
  43157. * Needed to keep backwards compatibility to the old API.
  43158. *
  43159. * @param args arguments passed to the attachControl function
  43160. * @returns the correct value for noPreventDefault
  43161. */
  43162. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43163. /**
  43164. * Captures a screenshot of the current rendering
  43165. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43166. * @param engine defines the rendering engine
  43167. * @param camera defines the source camera
  43168. * @param size This parameter can be set to a single number or to an object with the
  43169. * following (optional) properties: precision, width, height. If a single number is passed,
  43170. * it will be used for both width and height. If an object is passed, the screenshot size
  43171. * will be derived from the parameters. The precision property is a multiplier allowing
  43172. * rendering at a higher or lower resolution
  43173. * @param successCallback defines the callback receives a single parameter which contains the
  43174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43175. * src parameter of an <img> to display it
  43176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43177. * Check your browser for supported MIME types
  43178. */
  43179. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43180. /**
  43181. * Captures a screenshot of the current rendering
  43182. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43183. * @param engine defines the rendering engine
  43184. * @param camera defines the source camera
  43185. * @param size This parameter can be set to a single number or to an object with the
  43186. * following (optional) properties: precision, width, height. If a single number is passed,
  43187. * it will be used for both width and height. If an object is passed, the screenshot size
  43188. * will be derived from the parameters. The precision property is a multiplier allowing
  43189. * rendering at a higher or lower resolution
  43190. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43191. * Check your browser for supported MIME types
  43192. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43193. * to the src parameter of an <img> to display it
  43194. */
  43195. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43196. /**
  43197. * Generates an image screenshot from the specified camera.
  43198. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43199. * @param engine The engine to use for rendering
  43200. * @param camera The camera to use for rendering
  43201. * @param size This parameter can be set to a single number or to an object with the
  43202. * following (optional) properties: precision, width, height. If a single number is passed,
  43203. * it will be used for both width and height. If an object is passed, the screenshot size
  43204. * will be derived from the parameters. The precision property is a multiplier allowing
  43205. * rendering at a higher or lower resolution
  43206. * @param successCallback The callback receives a single parameter which contains the
  43207. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43208. * src parameter of an <img> to display it
  43209. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43210. * Check your browser for supported MIME types
  43211. * @param samples Texture samples (default: 1)
  43212. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43213. * @param fileName A name for for the downloaded file.
  43214. */
  43215. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43216. /**
  43217. * Generates an image screenshot from the specified camera.
  43218. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43219. * @param engine The engine to use for rendering
  43220. * @param camera The camera to use for rendering
  43221. * @param size This parameter can be set to a single number or to an object with the
  43222. * following (optional) properties: precision, width, height. If a single number is passed,
  43223. * it will be used for both width and height. If an object is passed, the screenshot size
  43224. * will be derived from the parameters. The precision property is a multiplier allowing
  43225. * rendering at a higher or lower resolution
  43226. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43227. * Check your browser for supported MIME types
  43228. * @param samples Texture samples (default: 1)
  43229. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43230. * @param fileName A name for for the downloaded file.
  43231. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43232. * to the src parameter of an <img> to display it
  43233. */
  43234. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43235. /**
  43236. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43237. * Be aware Math.random() could cause collisions, but:
  43238. * "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"
  43239. * @returns a pseudo random id
  43240. */
  43241. static RandomId(): string;
  43242. /**
  43243. * Test if the given uri is a base64 string
  43244. * @param uri The uri to test
  43245. * @return True if the uri is a base64 string or false otherwise
  43246. */
  43247. static IsBase64(uri: string): boolean;
  43248. /**
  43249. * Decode the given base64 uri.
  43250. * @param uri The uri to decode
  43251. * @return The decoded base64 data.
  43252. */
  43253. static DecodeBase64(uri: string): ArrayBuffer;
  43254. /**
  43255. * Gets the absolute url.
  43256. * @param url the input url
  43257. * @return the absolute url
  43258. */
  43259. static GetAbsoluteUrl(url: string): string;
  43260. /**
  43261. * No log
  43262. */
  43263. static readonly NoneLogLevel: number;
  43264. /**
  43265. * Only message logs
  43266. */
  43267. static readonly MessageLogLevel: number;
  43268. /**
  43269. * Only warning logs
  43270. */
  43271. static readonly WarningLogLevel: number;
  43272. /**
  43273. * Only error logs
  43274. */
  43275. static readonly ErrorLogLevel: number;
  43276. /**
  43277. * All logs
  43278. */
  43279. static readonly AllLogLevel: number;
  43280. /**
  43281. * Gets a value indicating the number of loading errors
  43282. * @ignorenaming
  43283. */
  43284. static get errorsCount(): number;
  43285. /**
  43286. * Callback called when a new log is added
  43287. */
  43288. static OnNewCacheEntry: (entry: string) => void;
  43289. /**
  43290. * Log a message to the console
  43291. * @param message defines the message to log
  43292. */
  43293. static Log(message: string): void;
  43294. /**
  43295. * Write a warning message to the console
  43296. * @param message defines the message to log
  43297. */
  43298. static Warn(message: string): void;
  43299. /**
  43300. * Write an error message to the console
  43301. * @param message defines the message to log
  43302. */
  43303. static Error(message: string): void;
  43304. /**
  43305. * Gets current log cache (list of logs)
  43306. */
  43307. static get LogCache(): string;
  43308. /**
  43309. * Clears the log cache
  43310. */
  43311. static ClearLogCache(): void;
  43312. /**
  43313. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43314. */
  43315. static set LogLevels(level: number);
  43316. /**
  43317. * Checks if the window object exists
  43318. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43319. */
  43320. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43321. /**
  43322. * No performance log
  43323. */
  43324. static readonly PerformanceNoneLogLevel: number;
  43325. /**
  43326. * Use user marks to log performance
  43327. */
  43328. static readonly PerformanceUserMarkLogLevel: number;
  43329. /**
  43330. * Log performance to the console
  43331. */
  43332. static readonly PerformanceConsoleLogLevel: number;
  43333. private static _performance;
  43334. /**
  43335. * Sets the current performance log level
  43336. */
  43337. static set PerformanceLogLevel(level: number);
  43338. private static _StartPerformanceCounterDisabled;
  43339. private static _EndPerformanceCounterDisabled;
  43340. private static _StartUserMark;
  43341. private static _EndUserMark;
  43342. private static _StartPerformanceConsole;
  43343. private static _EndPerformanceConsole;
  43344. /**
  43345. * Starts a performance counter
  43346. */
  43347. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43348. /**
  43349. * Ends a specific performance coutner
  43350. */
  43351. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43352. /**
  43353. * Gets either window.performance.now() if supported or Date.now() else
  43354. */
  43355. static get Now(): number;
  43356. /**
  43357. * This method will return the name of the class used to create the instance of the given object.
  43358. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43359. * @param object the object to get the class name from
  43360. * @param isType defines if the object is actually a type
  43361. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43362. */
  43363. static GetClassName(object: any, isType?: boolean): string;
  43364. /**
  43365. * Gets the first element of an array satisfying a given predicate
  43366. * @param array defines the array to browse
  43367. * @param predicate defines the predicate to use
  43368. * @returns null if not found or the element
  43369. */
  43370. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43371. /**
  43372. * This method will return the name of the full name of the class, including its owning module (if any).
  43373. * 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).
  43374. * @param object the object to get the class name from
  43375. * @param isType defines if the object is actually a type
  43376. * @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.
  43377. * @ignorenaming
  43378. */
  43379. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43380. /**
  43381. * Returns a promise that resolves after the given amount of time.
  43382. * @param delay Number of milliseconds to delay
  43383. * @returns Promise that resolves after the given amount of time
  43384. */
  43385. static DelayAsync(delay: number): Promise<void>;
  43386. /**
  43387. * Utility function to detect if the current user agent is Safari
  43388. * @returns whether or not the current user agent is safari
  43389. */
  43390. static IsSafari(): boolean;
  43391. }
  43392. /**
  43393. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43394. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43395. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43396. * @param name The name of the class, case should be preserved
  43397. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43398. */
  43399. export function className(name: string, module?: string): (target: Object) => void;
  43400. /**
  43401. * An implementation of a loop for asynchronous functions.
  43402. */
  43403. export class AsyncLoop {
  43404. /**
  43405. * Defines the number of iterations for the loop
  43406. */
  43407. iterations: number;
  43408. /**
  43409. * Defines the current index of the loop.
  43410. */
  43411. index: number;
  43412. private _done;
  43413. private _fn;
  43414. private _successCallback;
  43415. /**
  43416. * Constructor.
  43417. * @param iterations the number of iterations.
  43418. * @param func the function to run each iteration
  43419. * @param successCallback the callback that will be called upon succesful execution
  43420. * @param offset starting offset.
  43421. */
  43422. constructor(
  43423. /**
  43424. * Defines the number of iterations for the loop
  43425. */
  43426. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43427. /**
  43428. * Execute the next iteration. Must be called after the last iteration was finished.
  43429. */
  43430. executeNext(): void;
  43431. /**
  43432. * Break the loop and run the success callback.
  43433. */
  43434. breakLoop(): void;
  43435. /**
  43436. * Create and run an async loop.
  43437. * @param iterations the number of iterations.
  43438. * @param fn the function to run each iteration
  43439. * @param successCallback the callback that will be called upon succesful execution
  43440. * @param offset starting offset.
  43441. * @returns the created async loop object
  43442. */
  43443. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43444. /**
  43445. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43446. * @param iterations total number of iterations
  43447. * @param syncedIterations number of synchronous iterations in each async iteration.
  43448. * @param fn the function to call each iteration.
  43449. * @param callback a success call back that will be called when iterating stops.
  43450. * @param breakFunction a break condition (optional)
  43451. * @param timeout timeout settings for the setTimeout function. default - 0.
  43452. * @returns the created async loop object
  43453. */
  43454. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43455. }
  43456. }
  43457. declare module BABYLON {
  43458. /**
  43459. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43460. * The underlying implementation relies on an associative array to ensure the best performances.
  43461. * The value can be anything including 'null' but except 'undefined'
  43462. */
  43463. export class StringDictionary<T> {
  43464. /**
  43465. * This will clear this dictionary and copy the content from the 'source' one.
  43466. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43467. * @param source the dictionary to take the content from and copy to this dictionary
  43468. */
  43469. copyFrom(source: StringDictionary<T>): void;
  43470. /**
  43471. * Get a value based from its key
  43472. * @param key the given key to get the matching value from
  43473. * @return the value if found, otherwise undefined is returned
  43474. */
  43475. get(key: string): T | undefined;
  43476. /**
  43477. * Get a value from its key or add it if it doesn't exist.
  43478. * This method will ensure you that a given key/data will be present in the dictionary.
  43479. * @param key the given key to get the matching value from
  43480. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43481. * The factory will only be invoked if there's no data for the given key.
  43482. * @return the value corresponding to the key.
  43483. */
  43484. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43485. /**
  43486. * Get a value from its key if present in the dictionary otherwise add it
  43487. * @param key the key to get the value from
  43488. * @param val if there's no such key/value pair in the dictionary add it with this value
  43489. * @return the value corresponding to the key
  43490. */
  43491. getOrAdd(key: string, val: T): T;
  43492. /**
  43493. * Check if there's a given key in the dictionary
  43494. * @param key the key to check for
  43495. * @return true if the key is present, false otherwise
  43496. */
  43497. contains(key: string): boolean;
  43498. /**
  43499. * Add a new key and its corresponding value
  43500. * @param key the key to add
  43501. * @param value the value corresponding to the key
  43502. * @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
  43503. */
  43504. add(key: string, value: T): boolean;
  43505. /**
  43506. * Update a specific value associated to a key
  43507. * @param key defines the key to use
  43508. * @param value defines the value to store
  43509. * @returns true if the value was updated (or false if the key was not found)
  43510. */
  43511. set(key: string, value: T): boolean;
  43512. /**
  43513. * Get the element of the given key and remove it from the dictionary
  43514. * @param key defines the key to search
  43515. * @returns the value associated with the key or null if not found
  43516. */
  43517. getAndRemove(key: string): Nullable<T>;
  43518. /**
  43519. * Remove a key/value from the dictionary.
  43520. * @param key the key to remove
  43521. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43522. */
  43523. remove(key: string): boolean;
  43524. /**
  43525. * Clear the whole content of the dictionary
  43526. */
  43527. clear(): void;
  43528. /**
  43529. * Gets the current count
  43530. */
  43531. get count(): number;
  43532. /**
  43533. * Execute a callback on each key/val of the dictionary.
  43534. * Note that you can remove any element in this dictionary in the callback implementation
  43535. * @param callback the callback to execute on a given key/value pair
  43536. */
  43537. forEach(callback: (key: string, val: T) => void): void;
  43538. /**
  43539. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43540. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43541. * Note that you can remove any element in this dictionary in the callback implementation
  43542. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43543. * @returns the first item
  43544. */
  43545. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43546. private _count;
  43547. private _data;
  43548. }
  43549. }
  43550. declare module BABYLON {
  43551. /** @hidden */
  43552. export interface ICollisionCoordinator {
  43553. createCollider(): Collider;
  43554. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43555. init(scene: Scene): void;
  43556. }
  43557. /** @hidden */
  43558. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43559. private _scene;
  43560. private _scaledPosition;
  43561. private _scaledVelocity;
  43562. private _finalPosition;
  43563. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43564. createCollider(): Collider;
  43565. init(scene: Scene): void;
  43566. private _collideWithWorld;
  43567. }
  43568. }
  43569. declare module BABYLON {
  43570. /**
  43571. * Class used to manage all inputs for the scene.
  43572. */
  43573. export class InputManager {
  43574. /** The distance in pixel that you have to move to prevent some events */
  43575. static DragMovementThreshold: number;
  43576. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43577. static LongPressDelay: number;
  43578. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43579. static DoubleClickDelay: number;
  43580. /** If you need to check double click without raising a single click at first click, enable this flag */
  43581. static ExclusiveDoubleClickMode: boolean;
  43582. /** 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. */
  43583. private _alreadyAttached;
  43584. private _alreadyAttachedTo;
  43585. private _wheelEventName;
  43586. private _onPointerMove;
  43587. private _onPointerDown;
  43588. private _onPointerUp;
  43589. private _initClickEvent;
  43590. private _initActionManager;
  43591. private _delayedSimpleClick;
  43592. private _delayedSimpleClickTimeout;
  43593. private _previousDelayedSimpleClickTimeout;
  43594. private _meshPickProceed;
  43595. private _previousButtonPressed;
  43596. private _currentPickResult;
  43597. private _previousPickResult;
  43598. private _totalPointersPressed;
  43599. private _doubleClickOccured;
  43600. private _pointerOverMesh;
  43601. private _pickedDownMesh;
  43602. private _pickedUpMesh;
  43603. private _pointerX;
  43604. private _pointerY;
  43605. private _unTranslatedPointerX;
  43606. private _unTranslatedPointerY;
  43607. private _startingPointerPosition;
  43608. private _previousStartingPointerPosition;
  43609. private _startingPointerTime;
  43610. private _previousStartingPointerTime;
  43611. private _pointerCaptures;
  43612. private _meshUnderPointerId;
  43613. private _onKeyDown;
  43614. private _onKeyUp;
  43615. private _keyboardIsAttached;
  43616. private _onCanvasFocusObserver;
  43617. private _onCanvasBlurObserver;
  43618. private _scene;
  43619. /**
  43620. * Creates a new InputManager
  43621. * @param scene defines the hosting scene
  43622. */
  43623. constructor(scene: Scene);
  43624. /**
  43625. * Gets the mesh that is currently under the pointer
  43626. */
  43627. get meshUnderPointer(): Nullable<AbstractMesh>;
  43628. /**
  43629. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43630. * @param pointerId the pointer id to use
  43631. * @returns The mesh under this pointer id or null if not found
  43632. */
  43633. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43634. /**
  43635. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43636. */
  43637. get unTranslatedPointer(): Vector2;
  43638. /**
  43639. * Gets or sets the current on-screen X position of the pointer
  43640. */
  43641. get pointerX(): number;
  43642. set pointerX(value: number);
  43643. /**
  43644. * Gets or sets the current on-screen Y position of the pointer
  43645. */
  43646. get pointerY(): number;
  43647. set pointerY(value: number);
  43648. private _updatePointerPosition;
  43649. private _processPointerMove;
  43650. private _setRayOnPointerInfo;
  43651. private _checkPrePointerObservable;
  43652. /**
  43653. * Use this method to simulate a pointer move on a mesh
  43654. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43655. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43656. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43657. */
  43658. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43659. /**
  43660. * Use this method to simulate a pointer down on a mesh
  43661. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43662. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43663. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43664. */
  43665. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43666. private _processPointerDown;
  43667. /** @hidden */
  43668. _isPointerSwiping(): boolean;
  43669. /**
  43670. * Use this method to simulate a pointer up on a mesh
  43671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43674. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43675. */
  43676. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43677. private _processPointerUp;
  43678. /**
  43679. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43680. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43681. * @returns true if the pointer was captured
  43682. */
  43683. isPointerCaptured(pointerId?: number): boolean;
  43684. /**
  43685. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43686. * @param attachUp defines if you want to attach events to pointerup
  43687. * @param attachDown defines if you want to attach events to pointerdown
  43688. * @param attachMove defines if you want to attach events to pointermove
  43689. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43690. */
  43691. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43692. /**
  43693. * Detaches all event handlers
  43694. */
  43695. detachControl(): void;
  43696. /**
  43697. * Force the value of meshUnderPointer
  43698. * @param mesh defines the mesh to use
  43699. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43700. */
  43701. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43702. /**
  43703. * Gets the mesh under the pointer
  43704. * @returns a Mesh or null if no mesh is under the pointer
  43705. */
  43706. getPointerOverMesh(): Nullable<AbstractMesh>;
  43707. }
  43708. }
  43709. declare module BABYLON {
  43710. /**
  43711. * This class defines the direct association between an animation and a target
  43712. */
  43713. export class TargetedAnimation {
  43714. /**
  43715. * Animation to perform
  43716. */
  43717. animation: Animation;
  43718. /**
  43719. * Target to animate
  43720. */
  43721. target: any;
  43722. /**
  43723. * Returns the string "TargetedAnimation"
  43724. * @returns "TargetedAnimation"
  43725. */
  43726. getClassName(): string;
  43727. /**
  43728. * Serialize the object
  43729. * @returns the JSON object representing the current entity
  43730. */
  43731. serialize(): any;
  43732. }
  43733. /**
  43734. * Use this class to create coordinated animations on multiple targets
  43735. */
  43736. export class AnimationGroup implements IDisposable {
  43737. /** The name of the animation group */
  43738. name: string;
  43739. private _scene;
  43740. private _targetedAnimations;
  43741. private _animatables;
  43742. private _from;
  43743. private _to;
  43744. private _isStarted;
  43745. private _isPaused;
  43746. private _speedRatio;
  43747. private _loopAnimation;
  43748. private _isAdditive;
  43749. /**
  43750. * Gets or sets the unique id of the node
  43751. */
  43752. uniqueId: number;
  43753. /**
  43754. * This observable will notify when one animation have ended
  43755. */
  43756. onAnimationEndObservable: Observable<TargetedAnimation>;
  43757. /**
  43758. * Observer raised when one animation loops
  43759. */
  43760. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43761. /**
  43762. * Observer raised when all animations have looped
  43763. */
  43764. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43765. /**
  43766. * This observable will notify when all animations have ended.
  43767. */
  43768. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43769. /**
  43770. * This observable will notify when all animations have paused.
  43771. */
  43772. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43773. /**
  43774. * This observable will notify when all animations are playing.
  43775. */
  43776. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43777. /**
  43778. * Gets the first frame
  43779. */
  43780. get from(): number;
  43781. /**
  43782. * Gets the last frame
  43783. */
  43784. get to(): number;
  43785. /**
  43786. * Define if the animations are started
  43787. */
  43788. get isStarted(): boolean;
  43789. /**
  43790. * Gets a value indicating that the current group is playing
  43791. */
  43792. get isPlaying(): boolean;
  43793. /**
  43794. * Gets or sets the speed ratio to use for all animations
  43795. */
  43796. get speedRatio(): number;
  43797. /**
  43798. * Gets or sets the speed ratio to use for all animations
  43799. */
  43800. set speedRatio(value: number);
  43801. /**
  43802. * Gets or sets if all animations should loop or not
  43803. */
  43804. get loopAnimation(): boolean;
  43805. set loopAnimation(value: boolean);
  43806. /**
  43807. * Gets or sets if all animations should be evaluated additively
  43808. */
  43809. get isAdditive(): boolean;
  43810. set isAdditive(value: boolean);
  43811. /**
  43812. * Gets the targeted animations for this animation group
  43813. */
  43814. get targetedAnimations(): Array<TargetedAnimation>;
  43815. /**
  43816. * returning the list of animatables controlled by this animation group.
  43817. */
  43818. get animatables(): Array<Animatable>;
  43819. /**
  43820. * Gets the list of target animations
  43821. */
  43822. get children(): TargetedAnimation[];
  43823. /**
  43824. * Instantiates a new Animation Group.
  43825. * This helps managing several animations at once.
  43826. * @see https://doc.babylonjs.com/how_to/group
  43827. * @param name Defines the name of the group
  43828. * @param scene Defines the scene the group belongs to
  43829. */
  43830. constructor(
  43831. /** The name of the animation group */
  43832. name: string, scene?: Nullable<Scene>);
  43833. /**
  43834. * Add an animation (with its target) in the group
  43835. * @param animation defines the animation we want to add
  43836. * @param target defines the target of the animation
  43837. * @returns the TargetedAnimation object
  43838. */
  43839. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43840. /**
  43841. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43842. * It can add constant keys at begin or end
  43843. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43844. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43845. * @returns the animation group
  43846. */
  43847. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43848. private _animationLoopCount;
  43849. private _animationLoopFlags;
  43850. private _processLoop;
  43851. /**
  43852. * Start all animations on given targets
  43853. * @param loop defines if animations must loop
  43854. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43855. * @param from defines the from key (optional)
  43856. * @param to defines the to key (optional)
  43857. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43858. * @returns the current animation group
  43859. */
  43860. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43861. /**
  43862. * Pause all animations
  43863. * @returns the animation group
  43864. */
  43865. pause(): AnimationGroup;
  43866. /**
  43867. * Play all animations to initial state
  43868. * This function will start() the animations if they were not started or will restart() them if they were paused
  43869. * @param loop defines if animations must loop
  43870. * @returns the animation group
  43871. */
  43872. play(loop?: boolean): AnimationGroup;
  43873. /**
  43874. * Reset all animations to initial state
  43875. * @returns the animation group
  43876. */
  43877. reset(): AnimationGroup;
  43878. /**
  43879. * Restart animations from key 0
  43880. * @returns the animation group
  43881. */
  43882. restart(): AnimationGroup;
  43883. /**
  43884. * Stop all animations
  43885. * @returns the animation group
  43886. */
  43887. stop(): AnimationGroup;
  43888. /**
  43889. * Set animation weight for all animatables
  43890. * @param weight defines the weight to use
  43891. * @return the animationGroup
  43892. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43893. */
  43894. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43895. /**
  43896. * Synchronize and normalize all animatables with a source animatable
  43897. * @param root defines the root animatable to synchronize with
  43898. * @return the animationGroup
  43899. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43900. */
  43901. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43902. /**
  43903. * Goes to a specific frame in this animation group
  43904. * @param frame the frame number to go to
  43905. * @return the animationGroup
  43906. */
  43907. goToFrame(frame: number): AnimationGroup;
  43908. /**
  43909. * Dispose all associated resources
  43910. */
  43911. dispose(): void;
  43912. private _checkAnimationGroupEnded;
  43913. /**
  43914. * Clone the current animation group and returns a copy
  43915. * @param newName defines the name of the new group
  43916. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43917. * @returns the new aniamtion group
  43918. */
  43919. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43920. /**
  43921. * Serializes the animationGroup to an object
  43922. * @returns Serialized object
  43923. */
  43924. serialize(): any;
  43925. /**
  43926. * Returns a new AnimationGroup object parsed from the source provided.
  43927. * @param parsedAnimationGroup defines the source
  43928. * @param scene defines the scene that will receive the animationGroup
  43929. * @returns a new AnimationGroup
  43930. */
  43931. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43932. /**
  43933. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43934. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43935. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43936. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43937. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43938. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43939. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43940. */
  43941. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43942. /**
  43943. * Returns the string "AnimationGroup"
  43944. * @returns "AnimationGroup"
  43945. */
  43946. getClassName(): string;
  43947. /**
  43948. * Creates a detailled string about the object
  43949. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43950. * @returns a string representing the object
  43951. */
  43952. toString(fullDetails?: boolean): string;
  43953. }
  43954. }
  43955. declare module BABYLON {
  43956. /**
  43957. * @hidden
  43958. **/
  43959. export class _TimeToken {
  43960. _startTimeQuery: Nullable<WebGLQuery>;
  43961. _endTimeQuery: Nullable<WebGLQuery>;
  43962. _timeElapsedQuery: Nullable<WebGLQuery>;
  43963. _timeElapsedQueryEnded: boolean;
  43964. }
  43965. }
  43966. declare module BABYLON {
  43967. /** @hidden */
  43968. export enum ExtensionName {
  43969. DepthClamping = "depth-clamping",
  43970. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43971. Depth32FloatStencil8 = "depth32float-stencil8",
  43972. PipelineStatisticsQuery = "pipeline-statistics-query",
  43973. TextureCompressionBC = "texture-compression-bc",
  43974. TimestampQuery = "timestamp-query"
  43975. }
  43976. /** @hidden */
  43977. export enum AddressMode {
  43978. ClampToEdge = "clamp-to-edge",
  43979. Repeat = "repeat",
  43980. MirrorRepeat = "mirror-repeat"
  43981. }
  43982. /** @hidden */
  43983. export enum BindingType {
  43984. UniformBuffer = "uniform-buffer",
  43985. StorageBuffer = "storage-buffer",
  43986. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43987. Sampler = "sampler",
  43988. ComparisonSampler = "comparison-sampler",
  43989. SampledTexture = "sampled-texture",
  43990. ReadonlyStorageTexture = "readonly-storage-texture",
  43991. WriteonlyStorageTexture = "writeonly-storage-texture"
  43992. }
  43993. /** @hidden */
  43994. export enum BlendFactor {
  43995. Zero = "zero",
  43996. One = "one",
  43997. SrcColor = "src-color",
  43998. OneMinusSrcColor = "one-minus-src-color",
  43999. SrcAlpha = "src-alpha",
  44000. OneMinusSrcAlpha = "one-minus-src-alpha",
  44001. DstColor = "dst-color",
  44002. OneMinusDstColor = "one-minus-dst-color",
  44003. DstAlpha = "dst-alpha",
  44004. OneMinusDstAlpha = "one-minus-dst-alpha",
  44005. SrcAlphaSaturated = "src-alpha-saturated",
  44006. BlendColor = "blend-color",
  44007. OneMinusBlendColor = "one-minus-blend-color"
  44008. }
  44009. /** @hidden */
  44010. export enum BlendOperation {
  44011. Add = "add",
  44012. Subtract = "subtract",
  44013. ReverseSubtract = "reverse-subtract",
  44014. Min = "min",
  44015. Max = "max"
  44016. }
  44017. /** @hidden */
  44018. export enum CompareFunction {
  44019. Never = "never",
  44020. Less = "less",
  44021. Equal = "equal",
  44022. LessEqual = "less-equal",
  44023. Greater = "greater",
  44024. NotEqual = "not-equal",
  44025. GreaterEqual = "greater-equal",
  44026. Always = "always"
  44027. }
  44028. /** @hidden */
  44029. export enum CullMode {
  44030. None = "none",
  44031. Front = "front",
  44032. Back = "back"
  44033. }
  44034. /** @hidden */
  44035. export enum FilterMode {
  44036. Nearest = "nearest",
  44037. Linear = "linear"
  44038. }
  44039. /** @hidden */
  44040. export enum FrontFace {
  44041. CCW = "ccw",
  44042. CW = "cw"
  44043. }
  44044. /** @hidden */
  44045. export enum IndexFormat {
  44046. Uint16 = "uint16",
  44047. Uint32 = "uint32"
  44048. }
  44049. /** @hidden */
  44050. export enum InputStepMode {
  44051. Vertex = "vertex",
  44052. Instance = "instance"
  44053. }
  44054. /** @hidden */
  44055. export enum LoadOp {
  44056. Load = "load"
  44057. }
  44058. /** @hidden */
  44059. export enum PrimitiveTopology {
  44060. PointList = "point-list",
  44061. LineList = "line-list",
  44062. LineStrip = "line-strip",
  44063. TriangleList = "triangle-list",
  44064. TriangleStrip = "triangle-strip"
  44065. }
  44066. /** @hidden */
  44067. export enum StencilOperation {
  44068. Keep = "keep",
  44069. Zero = "zero",
  44070. Replace = "replace",
  44071. Invert = "invert",
  44072. IncrementClamp = "increment-clamp",
  44073. DecrementClamp = "decrement-clamp",
  44074. IncrementWrap = "increment-wrap",
  44075. DecrementWrap = "decrement-wrap"
  44076. }
  44077. /** @hidden */
  44078. export enum StoreOp {
  44079. Store = "store",
  44080. Clear = "clear"
  44081. }
  44082. /** @hidden */
  44083. export enum TextureDimension {
  44084. E1d = "1d",
  44085. E2d = "2d",
  44086. E3d = "3d"
  44087. }
  44088. /** @hidden */
  44089. export enum TextureFormat {
  44090. R8Unorm = "r8unorm",
  44091. R8Snorm = "r8snorm",
  44092. R8Uint = "r8uint",
  44093. R8Sint = "r8sint",
  44094. R16Uint = "r16uint",
  44095. R16Sint = "r16sint",
  44096. R16Float = "r16float",
  44097. RG8Unorm = "rg8unorm",
  44098. RG8Snorm = "rg8snorm",
  44099. RG8Uint = "rg8uint",
  44100. RG8Sint = "rg8sint",
  44101. R32Uint = "r32uint",
  44102. R32Sint = "r32sint",
  44103. R32Float = "r32float",
  44104. RG16Uint = "rg16uint",
  44105. RG16Sint = "rg16sint",
  44106. RG16Float = "rg16float",
  44107. RGBA8Unorm = "rgba8unorm",
  44108. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44109. RGBA8Snorm = "rgba8snorm",
  44110. RGBA8Uint = "rgba8uint",
  44111. RGBA8Sint = "rgba8sint",
  44112. BGRA8Unorm = "bgra8unorm",
  44113. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44114. RGB9E5UFloat = "rgb9e5ufloat",
  44115. RGB10A2Unorm = "rgb10a2unorm",
  44116. RG11B10UFloat = "rg11b10ufloat",
  44117. RG32Uint = "rg32uint",
  44118. RG32Sint = "rg32sint",
  44119. RG32Float = "rg32float",
  44120. RGBA16Uint = "rgba16uint",
  44121. RGBA16Sint = "rgba16sint",
  44122. RGBA16Float = "rgba16float",
  44123. RGBA32Uint = "rgba32uint",
  44124. RGBA32Sint = "rgba32sint",
  44125. RGBA32Float = "rgba32float",
  44126. Stencil8 = "stencil8",
  44127. Depth16Unorm = "depth16unorm",
  44128. Depth24Plus = "depth24plus",
  44129. Depth24PlusStencil8 = "depth24plus-stencil8",
  44130. Depth32Float = "depth32float",
  44131. BC1RGBAUNorm = "bc1-rgba-unorm",
  44132. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44133. BC2RGBAUnorm = "bc2-rgba-unorm",
  44134. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44135. BC3RGBAUnorm = "bc3-rgba-unorm",
  44136. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44137. BC4RUnorm = "bc4-r-unorm",
  44138. BC4RSnorm = "bc4-r-snorm",
  44139. BC5RGUnorm = "bc5-rg-unorm",
  44140. BC5RGSnorm = "bc5-rg-snorm",
  44141. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44142. BC6HRGBFloat = "bc6h-rgb-float",
  44143. BC7RGBAUnorm = "bc7-rgba-unorm",
  44144. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44145. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44146. Depth32FloatStencil8 = "depth32float-stencil8"
  44147. }
  44148. /** @hidden */
  44149. export enum TextureComponentType {
  44150. Float = "float",
  44151. Sint = "sint",
  44152. Uint = "uint",
  44153. DepthComparison = "depth-comparison"
  44154. }
  44155. /** @hidden */
  44156. export enum TextureViewDimension {
  44157. E1d = "1d",
  44158. E2d = "2d",
  44159. E2dArray = "2d-array",
  44160. Cube = "cube",
  44161. CubeArray = "cube-array",
  44162. E3d = "3d"
  44163. }
  44164. /** @hidden */
  44165. export enum VertexFormat {
  44166. Uchar2 = "uchar2",
  44167. Uchar4 = "uchar4",
  44168. Char2 = "char2",
  44169. Char4 = "char4",
  44170. Uchar2Norm = "uchar2norm",
  44171. Uchar4Norm = "uchar4norm",
  44172. Char2Norm = "char2norm",
  44173. Char4Norm = "char4norm",
  44174. Ushort2 = "ushort2",
  44175. Ushort4 = "ushort4",
  44176. Short2 = "short2",
  44177. Short4 = "short4",
  44178. Ushort2Norm = "ushort2norm",
  44179. Ushort4Norm = "ushort4norm",
  44180. Short2Norm = "short2norm",
  44181. Short4Norm = "short4norm",
  44182. Half2 = "half2",
  44183. Half4 = "half4",
  44184. Float = "float",
  44185. Float2 = "float2",
  44186. Float3 = "float3",
  44187. Float4 = "float4",
  44188. Uint = "uint",
  44189. Uint2 = "uint2",
  44190. Uint3 = "uint3",
  44191. Uint4 = "uint4",
  44192. Int = "int",
  44193. Int2 = "int2",
  44194. Int3 = "int3",
  44195. Int4 = "int4"
  44196. }
  44197. /** @hidden */
  44198. export enum TextureAspect {
  44199. All = "all",
  44200. StencilOnly = "stencil-only",
  44201. DepthOnly = "depth-only"
  44202. }
  44203. /** @hidden */
  44204. export enum CompilationMessageType {
  44205. Error = "error",
  44206. Warning = "warning",
  44207. Info = "info"
  44208. }
  44209. /** @hidden */
  44210. export enum QueryType {
  44211. Occlusion = "occlusion"
  44212. }
  44213. /** @hidden */
  44214. export enum BufferUsage {
  44215. MapRead = 1,
  44216. MapWrite = 2,
  44217. CopySrc = 4,
  44218. CopyDst = 8,
  44219. Index = 16,
  44220. Vertex = 32,
  44221. Uniform = 64,
  44222. Storage = 128,
  44223. Indirect = 256,
  44224. QueryResolve = 512
  44225. }
  44226. /** @hidden */
  44227. export enum ColorWrite {
  44228. Red = 1,
  44229. Green = 2,
  44230. Blue = 4,
  44231. Alpha = 8,
  44232. All = 15
  44233. }
  44234. /** @hidden */
  44235. export enum ShaderStage {
  44236. Vertex = 1,
  44237. Fragment = 2,
  44238. Compute = 4
  44239. }
  44240. /** @hidden */
  44241. export enum TextureUsage {
  44242. CopySrc = 1,
  44243. CopyDst = 2,
  44244. Sampled = 4,
  44245. Storage = 8,
  44246. OutputAttachment = 16
  44247. }
  44248. /** @hidden */
  44249. export enum MapMode {
  44250. Read = 1,
  44251. Write = 2
  44252. }
  44253. }
  44254. declare module BABYLON {
  44255. /** @hidden */
  44256. export interface WebGPUBindingInfo {
  44257. setIndex: number;
  44258. bindingIndex: number;
  44259. }
  44260. /** @hidden */
  44261. export interface WebGPUTextureSamplerBindingDescription {
  44262. sampler: WebGPUBindingInfo;
  44263. isTextureArray: boolean;
  44264. textures: Array<WebGPUBindingInfo>;
  44265. }
  44266. /** @hidden
  44267. * If the binding is a UBO, isSampler=isTexture=false
  44268. */
  44269. export interface WebGPUBindingDescription {
  44270. name: string;
  44271. usedInVertex: boolean;
  44272. usedInFragment: boolean;
  44273. isSampler: boolean;
  44274. isComparisonSampler?: boolean;
  44275. isTexture: boolean;
  44276. componentType?: GPUTextureComponentType;
  44277. textureDimension?: GPUTextureViewDimension;
  44278. }
  44279. /**
  44280. * @hidden
  44281. */
  44282. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44283. uboNextBindingIndex: number;
  44284. freeSetIndex: number;
  44285. freeBindingIndex: number;
  44286. availableVaryings: {
  44287. [key: string]: number;
  44288. };
  44289. availableAttributes: {
  44290. [key: string]: number;
  44291. };
  44292. availableUBOs: {
  44293. [key: string]: {
  44294. setIndex: number;
  44295. bindingIndex: number;
  44296. };
  44297. };
  44298. availableSamplers: {
  44299. [key: string]: WebGPUTextureSamplerBindingDescription;
  44300. };
  44301. leftOverUniforms: {
  44302. name: string;
  44303. type: string;
  44304. length: number;
  44305. }[];
  44306. orderedAttributes: string[];
  44307. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44308. uniformBufferNames: string[];
  44309. private _attributeNextLocation;
  44310. private _varyingNextLocation;
  44311. constructor();
  44312. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44313. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44314. getNextFreeUBOBinding(): {
  44315. setIndex: number;
  44316. bindingIndex: number;
  44317. };
  44318. private _getNextFreeBinding;
  44319. }
  44320. }
  44321. declare module BABYLON {
  44322. /** @hidden */
  44323. export interface IWebGPUPipelineContextSamplerCache {
  44324. samplerBinding: number;
  44325. firstTextureName: string;
  44326. }
  44327. /** @hidden */
  44328. export interface IWebGPUPipelineContextTextureCache {
  44329. textureBinding: number;
  44330. texture: InternalTexture;
  44331. }
  44332. /** @hidden */
  44333. export interface IWebGPUPipelineContextVertexInputsCache {
  44334. indexBuffer: Nullable<GPUBuffer>;
  44335. indexOffset: number;
  44336. vertexStartSlot: number;
  44337. vertexBuffers: GPUBuffer[];
  44338. vertexOffsets: number[];
  44339. }
  44340. /** @hidden */
  44341. export interface IWebGPURenderPipelineStageDescriptor {
  44342. vertexStage: GPUProgrammableStageDescriptor;
  44343. fragmentStage?: GPUProgrammableStageDescriptor;
  44344. }
  44345. /** @hidden */
  44346. export class WebGPUPipelineContext implements IPipelineContext {
  44347. engine: WebGPUEngine;
  44348. shaderProcessingContext: WebGPUShaderProcessingContext;
  44349. leftOverUniformsByName: {
  44350. [name: string]: string;
  44351. };
  44352. sources: {
  44353. vertex: string;
  44354. fragment: string;
  44355. rawVertex: string;
  44356. rawFragment: string;
  44357. };
  44358. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44359. samplers: {
  44360. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44361. };
  44362. textures: {
  44363. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44364. };
  44365. bindGroupLayouts: GPUBindGroupLayout[];
  44366. bindGroupsCache: {
  44367. [key: string]: GPUBindGroup[];
  44368. };
  44369. /**
  44370. * Stores the uniform buffer
  44371. */
  44372. uniformBuffer: Nullable<UniformBuffer>;
  44373. onCompiled?: () => void;
  44374. get isAsync(): boolean;
  44375. get isReady(): boolean;
  44376. /** @hidden */
  44377. _name: string;
  44378. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44379. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44380. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44381. [key: string]: number;
  44382. }, uniformsNames: string[], uniforms: {
  44383. [key: string]: Nullable<WebGLUniformLocation>;
  44384. }, samplerList: string[], samplers: {
  44385. [key: string]: number;
  44386. }, attributesNames: string[], attributes: number[]): void;
  44387. /** @hidden */
  44388. /**
  44389. * Build the uniform buffer used in the material.
  44390. */
  44391. buildUniformLayout(): void;
  44392. /**
  44393. * Release all associated resources.
  44394. **/
  44395. dispose(): void;
  44396. /**
  44397. * Sets an integer value on a uniform variable.
  44398. * @param uniformName Name of the variable.
  44399. * @param value Value to be set.
  44400. */
  44401. setInt(uniformName: string, value: number): void;
  44402. /**
  44403. * Sets an int2 value on a uniform variable.
  44404. * @param uniformName Name of the variable.
  44405. * @param x First int in int2.
  44406. * @param y Second int in int2.
  44407. */
  44408. setInt2(uniformName: string, x: number, y: number): void;
  44409. /**
  44410. * Sets an int3 value on a uniform variable.
  44411. * @param uniformName Name of the variable.
  44412. * @param x First int in int3.
  44413. * @param y Second int in int3.
  44414. * @param z Third int in int3.
  44415. */
  44416. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44417. /**
  44418. * Sets an int4 value on a uniform variable.
  44419. * @param uniformName Name of the variable.
  44420. * @param x First int in int4.
  44421. * @param y Second int in int4.
  44422. * @param z Third int in int4.
  44423. * @param w Fourth int in int4.
  44424. */
  44425. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44426. /**
  44427. * Sets an int array on a uniform variable.
  44428. * @param uniformName Name of the variable.
  44429. * @param array array to be set.
  44430. */
  44431. setIntArray(uniformName: string, array: Int32Array): void;
  44432. /**
  44433. * 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)
  44434. * @param uniformName Name of the variable.
  44435. * @param array array to be set.
  44436. */
  44437. setIntArray2(uniformName: string, array: Int32Array): void;
  44438. /**
  44439. * 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)
  44440. * @param uniformName Name of the variable.
  44441. * @param array array to be set.
  44442. */
  44443. setIntArray3(uniformName: string, array: Int32Array): void;
  44444. /**
  44445. * 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)
  44446. * @param uniformName Name of the variable.
  44447. * @param array array to be set.
  44448. */
  44449. setIntArray4(uniformName: string, array: Int32Array): void;
  44450. /**
  44451. * Sets an array on a uniform variable.
  44452. * @param uniformName Name of the variable.
  44453. * @param array array to be set.
  44454. */
  44455. setArray(uniformName: string, array: number[]): void;
  44456. /**
  44457. * 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)
  44458. * @param uniformName Name of the variable.
  44459. * @param array array to be set.
  44460. */
  44461. setArray2(uniformName: string, array: number[]): void;
  44462. /**
  44463. * 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)
  44464. * @param uniformName Name of the variable.
  44465. * @param array array to be set.
  44466. * @returns this effect.
  44467. */
  44468. setArray3(uniformName: string, array: number[]): void;
  44469. /**
  44470. * 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)
  44471. * @param uniformName Name of the variable.
  44472. * @param array array to be set.
  44473. */
  44474. setArray4(uniformName: string, array: number[]): void;
  44475. /**
  44476. * Sets matrices on a uniform variable.
  44477. * @param uniformName Name of the variable.
  44478. * @param matrices matrices to be set.
  44479. */
  44480. setMatrices(uniformName: string, matrices: Float32Array): void;
  44481. /**
  44482. * Sets matrix on a uniform variable.
  44483. * @param uniformName Name of the variable.
  44484. * @param matrix matrix to be set.
  44485. */
  44486. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44487. /**
  44488. * 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)
  44489. * @param uniformName Name of the variable.
  44490. * @param matrix matrix to be set.
  44491. */
  44492. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44493. /**
  44494. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44495. * @param uniformName Name of the variable.
  44496. * @param matrix matrix to be set.
  44497. */
  44498. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44499. /**
  44500. * Sets a float on a uniform variable.
  44501. * @param uniformName Name of the variable.
  44502. * @param value value to be set.
  44503. * @returns this effect.
  44504. */
  44505. setFloat(uniformName: string, value: number): void;
  44506. /**
  44507. * Sets a Vector2 on a uniform variable.
  44508. * @param uniformName Name of the variable.
  44509. * @param vector2 vector2 to be set.
  44510. */
  44511. setVector2(uniformName: string, vector2: IVector2Like): void;
  44512. /**
  44513. * Sets a float2 on a uniform variable.
  44514. * @param uniformName Name of the variable.
  44515. * @param x First float in float2.
  44516. * @param y Second float in float2.
  44517. */
  44518. setFloat2(uniformName: string, x: number, y: number): void;
  44519. /**
  44520. * Sets a Vector3 on a uniform variable.
  44521. * @param uniformName Name of the variable.
  44522. * @param vector3 Value to be set.
  44523. */
  44524. setVector3(uniformName: string, vector3: IVector3Like): void;
  44525. /**
  44526. * Sets a float3 on a uniform variable.
  44527. * @param uniformName Name of the variable.
  44528. * @param x First float in float3.
  44529. * @param y Second float in float3.
  44530. * @param z Third float in float3.
  44531. */
  44532. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44533. /**
  44534. * Sets a Vector4 on a uniform variable.
  44535. * @param uniformName Name of the variable.
  44536. * @param vector4 Value to be set.
  44537. */
  44538. setVector4(uniformName: string, vector4: IVector4Like): void;
  44539. /**
  44540. * Sets a float4 on a uniform variable.
  44541. * @param uniformName Name of the variable.
  44542. * @param x First float in float4.
  44543. * @param y Second float in float4.
  44544. * @param z Third float in float4.
  44545. * @param w Fourth float in float4.
  44546. * @returns this effect.
  44547. */
  44548. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44549. /**
  44550. * Sets a Color3 on a uniform variable.
  44551. * @param uniformName Name of the variable.
  44552. * @param color3 Value to be set.
  44553. */
  44554. setColor3(uniformName: string, color3: IColor3Like): void;
  44555. /**
  44556. * Sets a Color4 on a uniform variable.
  44557. * @param uniformName Name of the variable.
  44558. * @param color3 Value to be set.
  44559. * @param alpha Alpha value to be set.
  44560. */
  44561. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44562. /**
  44563. * Sets a Color4 on a uniform variable
  44564. * @param uniformName defines the name of the variable
  44565. * @param color4 defines the value to be set
  44566. */
  44567. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44568. _getVertexShaderCode(): string | null;
  44569. _getFragmentShaderCode(): string | null;
  44570. }
  44571. }
  44572. declare module BABYLON {
  44573. /** @hidden */
  44574. export class WebGPUDataBuffer extends DataBuffer {
  44575. private _buffer;
  44576. constructor(resource: GPUBuffer);
  44577. get underlyingResource(): any;
  44578. }
  44579. }
  44580. declare module BABYLON {
  44581. /**
  44582. * Class used to inline functions in shader code
  44583. */
  44584. export class ShaderCodeInliner {
  44585. private static readonly _RegexpFindFunctionNameAndType;
  44586. private _sourceCode;
  44587. private _functionDescr;
  44588. private _numMaxIterations;
  44589. /** Gets or sets the token used to mark the functions to inline */
  44590. inlineToken: string;
  44591. /** Gets or sets the debug mode */
  44592. debug: boolean;
  44593. /** Gets the code after the inlining process */
  44594. get code(): string;
  44595. /**
  44596. * Initializes the inliner
  44597. * @param sourceCode shader code source to inline
  44598. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44599. */
  44600. constructor(sourceCode: string, numMaxIterations?: number);
  44601. /**
  44602. * Start the processing of the shader code
  44603. */
  44604. processCode(): void;
  44605. private _collectFunctions;
  44606. private _processInlining;
  44607. private _extractBetweenMarkers;
  44608. private _skipWhitespaces;
  44609. private _isIdentifierChar;
  44610. private _removeComments;
  44611. private _replaceFunctionCallsByCode;
  44612. private _findBackward;
  44613. private _escapeRegExp;
  44614. private _replaceNames;
  44615. }
  44616. }
  44617. declare module BABYLON {
  44618. /** @hidden */
  44619. export class WebGPUShaderProcessor implements IShaderProcessor {
  44620. protected _missingVaryings: Array<string>;
  44621. protected _textureArrayProcessing: Array<string>;
  44622. protected _preProcessors: {
  44623. [key: string]: string;
  44624. };
  44625. private _getArraySize;
  44626. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44627. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44628. [key: string]: string;
  44629. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44630. attributeProcessor(attribute: string, preProcessors: {
  44631. [key: string]: string;
  44632. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44633. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44634. [key: string]: string;
  44635. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44636. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44637. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44638. private _applyTextureArrayProcessing;
  44639. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44640. vertexCode: string;
  44641. fragmentCode: string;
  44642. };
  44643. }
  44644. }
  44645. declare module BABYLON {
  44646. /** @hidden */
  44647. export class WebGPUBufferManager {
  44648. private _device;
  44649. private _deferredReleaseBuffers;
  44650. private static _IsGPUBuffer;
  44651. constructor(device: GPUDevice);
  44652. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44653. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44654. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44655. private _FromHalfFloat;
  44656. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44657. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44658. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44659. destroyDeferredBuffers(): void;
  44660. }
  44661. }
  44662. declare module BABYLON {
  44663. /** @hidden */
  44664. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44665. private _webgpuTexture;
  44666. private _webgpuMSAATexture;
  44667. get underlyingResource(): Nullable<GPUTexture>;
  44668. get msaaTexture(): Nullable<GPUTexture>;
  44669. set msaaTexture(texture: Nullable<GPUTexture>);
  44670. view: Nullable<GPUTextureView>;
  44671. format: GPUTextureFormat;
  44672. textureUsages: number;
  44673. constructor(existingTexture?: Nullable<GPUTexture>);
  44674. set(hardwareTexture: GPUTexture): void;
  44675. setMSAATexture(hardwareTexture: GPUTexture): void;
  44676. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44677. createView(descriptor?: GPUTextureViewDescriptor): void;
  44678. reset(): void;
  44679. release(): void;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. /** @hidden */
  44684. export class WebGPUTextureHelper {
  44685. private _device;
  44686. private _glslang;
  44687. private _bufferManager;
  44688. private _mipmapSampler;
  44689. private _invertYPreMultiplyAlphaSampler;
  44690. private _pipelines;
  44691. private _compiledShaders;
  44692. private _deferredReleaseTextures;
  44693. private _commandEncoderForCreation;
  44694. static ComputeNumMipmapLevels(width: number, height: number): number;
  44695. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44696. private _getPipeline;
  44697. private static _GetTextureTypeFromFormat;
  44698. private static _GetBlockInformationFromFormat;
  44699. private static _IsHardwareTexture;
  44700. private static _IsInternalTexture;
  44701. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44702. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44703. width: number;
  44704. height: number;
  44705. }): imageBitmap is ImageBitmap;
  44706. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44707. width: number;
  44708. height: number;
  44709. }): imageBitmap is ImageBitmap[];
  44710. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44711. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44712. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44713. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44714. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44715. createTexture(imageBitmap: ImageBitmap | {
  44716. width: number;
  44717. height: number;
  44718. layers: number;
  44719. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44720. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44721. width: number;
  44722. height: number;
  44723. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44724. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44725. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44726. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44727. createMSAATexture(texture: InternalTexture, samples: number): void;
  44728. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44729. 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;
  44730. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44731. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44732. destroyDeferredTextures(): void;
  44733. }
  44734. }
  44735. declare module BABYLON {
  44736. /** @hidden */
  44737. export class WebGPURenderPassWrapper {
  44738. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44739. renderPass: Nullable<GPURenderPassEncoder>;
  44740. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44741. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44742. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44743. depthTextureFormat: GPUTextureFormat | undefined;
  44744. constructor();
  44745. reset(fullReset?: boolean): void;
  44746. }
  44747. }
  44748. declare module BABYLON {
  44749. /** @hidden */
  44750. export class WebGPUCacheSampler {
  44751. private _samplers;
  44752. private _device;
  44753. disabled: boolean;
  44754. constructor(device: GPUDevice);
  44755. private static _GetSamplerHashCode;
  44756. private static _GetSamplerFilterDescriptor;
  44757. private static _GetWrappingMode;
  44758. private static _GetSamplerWrappingDescriptor;
  44759. private static _GetSamplerDescriptor;
  44760. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44761. }
  44762. }
  44763. declare module BABYLON {
  44764. /** @hidden */
  44765. export class WebGPUShaderManager {
  44766. private _shaders;
  44767. private _device;
  44768. constructor(device: GPUDevice);
  44769. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44770. }
  44771. }
  44772. declare module BABYLON {
  44773. /** @hidden */
  44774. export class WebGPUCacheRenderPipeline {
  44775. static NumCacheHitWithoutHash: number;
  44776. static NumCacheHitWithHash: number;
  44777. static NumCacheMiss: number;
  44778. static NumPipelineCreationLastFrame: number;
  44779. disabled: boolean;
  44780. private static _Cache;
  44781. private static _NumPipelineCreationCurrentFrame;
  44782. private _device;
  44783. private _states;
  44784. private _isDirty;
  44785. private _currentRenderPipeline;
  44786. private _emptyVertexBuffer;
  44787. private _shaderId;
  44788. private _alphaToCoverageEnabled;
  44789. private _frontFace;
  44790. private _cullEnabled;
  44791. private _cullFace;
  44792. private _clampDepth;
  44793. private _rasterizationState;
  44794. private _depthBias;
  44795. private _depthBiasClamp;
  44796. private _depthBiasSlopeScale;
  44797. private _colorFormat;
  44798. private _webgpuColorFormat;
  44799. private _mrtAttachments1;
  44800. private _mrtAttachments2;
  44801. private _mrtFormats;
  44802. private _alphaBlendEnabled;
  44803. private _alphaBlendFuncParams;
  44804. private _alphaBlendEqParams;
  44805. private _writeMask;
  44806. private _colorStates;
  44807. private _depthStencilFormat;
  44808. private _webgpuDepthStencilFormat;
  44809. private _depthTestEnabled;
  44810. private _depthWriteEnabled;
  44811. private _depthCompare;
  44812. private _stencilEnabled;
  44813. private _stencilFrontCompare;
  44814. private _stencilFrontDepthFailOp;
  44815. private _stencilFrontPassOp;
  44816. private _stencilFrontFailOp;
  44817. private _stencilReadMask;
  44818. private _stencilWriteMask;
  44819. private _depthStencilState;
  44820. private _vertexBuffers;
  44821. private _indexBuffer;
  44822. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  44823. reset(): void;
  44824. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  44825. endFrame(): void;
  44826. setAlphaToCoverage(enabled: boolean): void;
  44827. setFrontFace(frontFace: number): void;
  44828. setCullEnabled(enabled: boolean): void;
  44829. setCullFace(cullFace: number): void;
  44830. setClampDepth(clampDepth: boolean): void;
  44831. resetDepthCullingState(): void;
  44832. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  44833. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  44834. setColorFormat(format: GPUTextureFormat): void;
  44835. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  44836. setAlphaBlendEnabled(enabled: boolean): void;
  44837. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  44838. setWriteMask(mask: number): void;
  44839. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  44840. setDepthTestEnabled(enabled: boolean): void;
  44841. setDepthWriteEnabled(enabled: boolean): void;
  44842. setDepthCompare(func: Nullable<number>): void;
  44843. setStencilEnabled(enabled: boolean): void;
  44844. setStencilCompare(func: Nullable<number>): void;
  44845. setStencilDepthFailOp(op: Nullable<number>): void;
  44846. setStencilPassOp(op: Nullable<number>): void;
  44847. setStencilFailOp(op: Nullable<number>): void;
  44848. setStencilReadMask(mask: number): void;
  44849. setStencilWriteMask(mask: number): void;
  44850. resetStencilState(): void;
  44851. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  44852. setBuffers(vertexBuffers: Nullable<{
  44853. [key: string]: Nullable<VertexBuffer>;
  44854. }>, indexBuffer: Nullable<DataBuffer>): void;
  44855. private static _GetTopology;
  44856. private static _GetAphaBlendOperation;
  44857. private static _GetAphaBlendFactor;
  44858. private static _GetCompareFunction;
  44859. private static _GetStencilOpFunction;
  44860. private static _GetVertexInputDescriptorFormat;
  44861. private _getAphaBlendState;
  44862. private _getColorBlendState;
  44863. private _setShaderStage;
  44864. private _setRasterizationState;
  44865. private _setColorStates;
  44866. private _setDepthStencilState;
  44867. private _setVertexState;
  44868. private _createPipelineLayout;
  44869. private _getVertexInputDescriptor;
  44870. private _createRenderPipeline;
  44871. }
  44872. }
  44873. declare module BABYLON {
  44874. /** @hidden */
  44875. export var clearQuadVertexShader: {
  44876. name: string;
  44877. shader: string;
  44878. };
  44879. }
  44880. declare module BABYLON {
  44881. /** @hidden */
  44882. export var clearQuadPixelShader: {
  44883. name: string;
  44884. shader: string;
  44885. };
  44886. }
  44887. declare module BABYLON {
  44888. /**
  44889. * Options to load the associated Glslang library
  44890. */
  44891. export interface GlslangOptions {
  44892. /**
  44893. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44894. */
  44895. glslang?: any;
  44896. /**
  44897. * Defines the URL of the glslang JS File.
  44898. */
  44899. jsPath?: string;
  44900. /**
  44901. * Defines the URL of the glslang WASM File.
  44902. */
  44903. wasmPath?: string;
  44904. }
  44905. /**
  44906. * Options to create the WebGPU engine
  44907. */
  44908. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44909. /**
  44910. * If delta time between frames should be constant
  44911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44912. */
  44913. deterministicLockstep?: boolean;
  44914. /**
  44915. * Maximum about of steps between frames (Default: 4)
  44916. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44917. */
  44918. lockstepMaxSteps?: number;
  44919. /**
  44920. * Defines the seconds between each deterministic lock step
  44921. */
  44922. timeStep?: number;
  44923. /**
  44924. * Defines that engine should ignore modifying touch action attribute and style
  44925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44926. */
  44927. doNotHandleTouchAction?: boolean;
  44928. /**
  44929. * Defines if webaudio should be initialized as well
  44930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44931. */
  44932. audioEngine?: boolean;
  44933. /**
  44934. * Defines the category of adapter to use.
  44935. * Is it the discrete or integrated device.
  44936. */
  44937. powerPreference?: GPUPowerPreference;
  44938. /**
  44939. * Defines the device descriptor used to create a device.
  44940. */
  44941. deviceDescriptor?: GPUDeviceDescriptor;
  44942. /**
  44943. * Defines the requested Swap Chain Format.
  44944. */
  44945. swapChainFormat?: GPUTextureFormat;
  44946. /**
  44947. * Defines wether MSAA is enabled on the canvas.
  44948. */
  44949. antialiasing?: boolean;
  44950. /**
  44951. * Defines wether the stencil buffer should be enabled.
  44952. */
  44953. stencil?: boolean;
  44954. /**
  44955. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44956. */
  44957. enableGPUDebugMarkers?: boolean;
  44958. /**
  44959. * Options to load the associated Glslang library
  44960. */
  44961. glslangOptions?: GlslangOptions;
  44962. }
  44963. /**
  44964. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44965. */
  44966. export class WebGPUEngine extends Engine {
  44967. private static readonly _glslangDefaultOptions;
  44968. private readonly _uploadEncoderDescriptor;
  44969. private readonly _renderEncoderDescriptor;
  44970. private readonly _renderTargetEncoderDescriptor;
  44971. private readonly _clearDepthValue;
  44972. private readonly _clearReverseDepthValue;
  44973. private readonly _clearStencilValue;
  44974. private readonly _defaultSampleCount;
  44975. private _canvas;
  44976. private _options;
  44977. private _glslang;
  44978. private _adapter;
  44979. private _adapterSupportedExtensions;
  44980. private _device;
  44981. private _deviceEnabledExtensions;
  44982. private _context;
  44983. private _swapChain;
  44984. private _swapChainTexture;
  44985. private _mainPassSampleCount;
  44986. private _textureHelper;
  44987. private _bufferManager;
  44988. private _shaderManager;
  44989. private _cacheSampler;
  44990. private _cacheRenderPipeline;
  44991. private _emptyVertexBuffer;
  44992. private _lastCachedWrapU;
  44993. private _lastCachedWrapV;
  44994. private _lastCachedWrapR;
  44995. private _mrtAttachments;
  44996. private _counters;
  44997. private _mainTexture;
  44998. private _depthTexture;
  44999. private _mainTextureExtends;
  45000. private _depthTextureFormat;
  45001. private _colorFormat;
  45002. private _uploadEncoder;
  45003. private _renderEncoder;
  45004. private _renderTargetEncoder;
  45005. private _commandBuffers;
  45006. private _currentRenderPass;
  45007. private _mainRenderPassWrapper;
  45008. private _rttRenderPassWrapper;
  45009. private _pendingDebugCommands;
  45010. private _currentVertexBuffers;
  45011. private _currentIndexBuffer;
  45012. private __colorWrite;
  45013. private _uniformsBuffers;
  45014. private _forceEnableEffect;
  45015. /** @hidden */
  45016. dbgShowShaderCode: boolean;
  45017. /** @hidden */
  45018. dbgSanityChecks: boolean;
  45019. /** @hidden */
  45020. dbgGenerateLogs: boolean;
  45021. /** @hidden */
  45022. dbgVerboseLogsForFirstFrames: boolean;
  45023. /** @hidden */
  45024. dbgVerboseLogsNumFrames: number;
  45025. /** @hidden */
  45026. dbgShowWarningsNotImplemented: boolean;
  45027. /**
  45028. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45029. */
  45030. get disableCacheSamplers(): boolean;
  45031. set disableCacheSamplers(disable: boolean);
  45032. /**
  45033. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45034. */
  45035. get disableCacheRenderPipelines(): boolean;
  45036. set disableCacheRenderPipelines(disable: boolean);
  45037. /**
  45038. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  45039. * @returns true if the engine can be created
  45040. */
  45041. static get IsSupported(): boolean;
  45042. /**
  45043. * Gets a boolean indicating that the engine supports uniform buffers
  45044. */
  45045. get supportsUniformBuffers(): boolean;
  45046. /** Gets the supported extensions by the WebGPU adapter */
  45047. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45048. /** Gets the currently enabled extensions on the WebGPU device */
  45049. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45050. /**
  45051. * Returns the name of the engine
  45052. */
  45053. get name(): string;
  45054. /**
  45055. * Returns a string describing the current engine
  45056. */
  45057. get description(): string;
  45058. /**
  45059. * Returns the version of the engine
  45060. */
  45061. get version(): number;
  45062. /**
  45063. * Create a new instance of the gpu engine asynchronously
  45064. * @param canvas Defines the canvas to use to display the result
  45065. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45066. * @returns a promise that resolves with the created engine
  45067. */
  45068. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45069. /**
  45070. * Create a new instance of the gpu engine.
  45071. * @param canvas Defines the canvas to use to display the result
  45072. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45073. */
  45074. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45075. /**
  45076. * Initializes the WebGPU context and dependencies.
  45077. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45078. * @returns a promise notifying the readiness of the engine.
  45079. */
  45080. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45081. private _initGlslang;
  45082. private _initializeLimits;
  45083. private _initializeContextAndSwapChain;
  45084. private _initializeMainAttachments;
  45085. /**
  45086. * Force a specific size of the canvas
  45087. * @param width defines the new canvas' width
  45088. * @param height defines the new canvas' height
  45089. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45090. * @returns true if the size was changed
  45091. */
  45092. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45093. /**
  45094. * Gets a shader processor implementation fitting with the current engine type.
  45095. * @returns The shader processor implementation.
  45096. */
  45097. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45098. /** @hidden */
  45099. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45100. /**
  45101. * Force the entire cache to be cleared
  45102. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45103. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45104. */
  45105. wipeCaches(bruteForce?: boolean): void;
  45106. /**
  45107. * Enable or disable color writing
  45108. * @param enable defines the state to set
  45109. */
  45110. setColorWrite(enable: boolean): void;
  45111. /**
  45112. * Gets a boolean indicating if color writing is enabled
  45113. * @returns the current color writing state
  45114. */
  45115. getColorWrite(): boolean;
  45116. private _viewportsCurrent;
  45117. private _resetCurrentViewport;
  45118. private _applyViewport;
  45119. /** @hidden */
  45120. _viewport(x: number, y: number, width: number, height: number): void;
  45121. private _scissorsCurrent;
  45122. protected _scissorCached: {
  45123. x: number;
  45124. y: number;
  45125. z: number;
  45126. w: number;
  45127. };
  45128. private _resetCurrentScissor;
  45129. private _applyScissor;
  45130. private _scissorIsActive;
  45131. enableScissor(x: number, y: number, width: number, height: number): void;
  45132. disableScissor(): void;
  45133. /**
  45134. * Clear the current render buffer or the current render target (if any is set up)
  45135. * @param color defines the color to use
  45136. * @param backBuffer defines if the back buffer must be cleared
  45137. * @param depth defines if the depth buffer must be cleared
  45138. * @param stencil defines if the stencil buffer must be cleared
  45139. */
  45140. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45141. /**
  45142. * Clears a list of attachments
  45143. * @param attachments list of the attachments
  45144. * @param colorMain clear color for the main attachment (the first one)
  45145. * @param colorOthers clear color for the other attachments
  45146. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45147. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45148. */
  45149. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45150. /**
  45151. * Creates a vertex buffer
  45152. * @param data the data for the vertex buffer
  45153. * @returns the new buffer
  45154. */
  45155. createVertexBuffer(data: DataArray): DataBuffer;
  45156. /**
  45157. * Creates a vertex buffer
  45158. * @param data the data for the dynamic vertex buffer
  45159. * @returns the new buffer
  45160. */
  45161. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45162. /**
  45163. * Updates a vertex buffer.
  45164. * @param vertexBuffer the vertex buffer to update
  45165. * @param data the data used to update the vertex buffer
  45166. * @param byteOffset the byte offset of the data
  45167. * @param byteLength the byte length of the data
  45168. */
  45169. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45170. /**
  45171. * Creates a new index buffer
  45172. * @param indices defines the content of the index buffer
  45173. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45174. * @returns a new buffer
  45175. */
  45176. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45177. /**
  45178. * Update an index buffer
  45179. * @param indexBuffer defines the target index buffer
  45180. * @param indices defines the data to update
  45181. * @param offset defines the offset in the target index buffer where update should start
  45182. */
  45183. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45184. /** @hidden */
  45185. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45186. /** @hidden */
  45187. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45188. /**
  45189. * Bind a list of vertex buffers with the engine
  45190. * @param vertexBuffers defines the list of vertex buffers to bind
  45191. * @param indexBuffer defines the index buffer to bind
  45192. * @param effect defines the effect associated with the vertex buffers
  45193. */
  45194. bindBuffers(vertexBuffers: {
  45195. [key: string]: Nullable<VertexBuffer>;
  45196. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  45197. /** @hidden */
  45198. _releaseBuffer(buffer: DataBuffer): boolean;
  45199. createUniformBuffer(elements: FloatArray): DataBuffer;
  45200. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45201. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45202. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45203. /**
  45204. * Create a new effect (used to store vertex/fragment shaders)
  45205. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45206. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45207. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45208. * @param samplers defines an array of string used to represent textures
  45209. * @param defines defines the string containing the defines to use to compile the shaders
  45210. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45211. * @param onCompiled defines a function to call when the effect creation is successful
  45212. * @param onError defines a function to call when the effect creation has failed
  45213. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45214. * @returns the new Effect
  45215. */
  45216. 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;
  45217. private _compileRawShaderToSpirV;
  45218. private _compileShaderToSpirV;
  45219. private _createPipelineStageDescriptor;
  45220. private _compileRawPipelineStageDescriptor;
  45221. private _compilePipelineStageDescriptor;
  45222. /** @hidden */
  45223. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45224. /** @hidden */
  45225. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45226. /**
  45227. * Creates a new pipeline context
  45228. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45229. * @returns the new pipeline
  45230. */
  45231. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45232. /** @hidden */
  45233. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45234. /**
  45235. * Gets the list of active attributes for a given WebGPU program
  45236. * @param pipelineContext defines the pipeline context to use
  45237. * @param attributesNames defines the list of attribute names to get
  45238. * @returns an array of indices indicating the offset of each attribute
  45239. */
  45240. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45241. /**
  45242. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45243. * @param effect defines the effect to activate
  45244. */
  45245. enableEffect(effect: Nullable<Effect>): void;
  45246. /** @hidden */
  45247. _releaseEffect(effect: Effect): void;
  45248. /**
  45249. * 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
  45250. */
  45251. releaseEffects(): void;
  45252. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45253. /**
  45254. * Gets a boolean indicating that only power of 2 textures are supported
  45255. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45256. */
  45257. get needPOTTextures(): boolean;
  45258. /** @hidden */
  45259. _createHardwareTexture(): HardwareTextureWrapper;
  45260. /** @hidden */
  45261. _releaseTexture(texture: InternalTexture): void;
  45262. /** @hidden */
  45263. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45264. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45265. /**
  45266. * Usually called from Texture.ts.
  45267. * Passed information to create a hardware texture
  45268. * @param url defines a value which contains one of the following:
  45269. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45270. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45271. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45273. * @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)
  45274. * @param scene needed for loading to the correct scene
  45275. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45276. * @param onLoad optional callback to be called upon successful completion
  45277. * @param onError optional callback to be called upon failure
  45278. * @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
  45279. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45280. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45281. * @param forcedExtension defines the extension to use to pick the right loader
  45282. * @param mimeType defines an optional mime type
  45283. * @param loaderOptions options to be passed to the loader
  45284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45285. */
  45286. 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;
  45287. /** @hidden */
  45288. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45289. /**
  45290. * Creates a cube texture
  45291. * @param rootUrl defines the url where the files to load is located
  45292. * @param scene defines the current scene
  45293. * @param files defines the list of files to load (1 per face)
  45294. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45295. * @param onLoad defines an optional callback raised when the texture is loaded
  45296. * @param onError defines an optional callback raised if there is an issue to load the texture
  45297. * @param format defines the format of the data
  45298. * @param forcedExtension defines the extension to use to pick the right loader
  45299. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45300. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45301. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45302. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45303. * @param loaderOptions options to be passed to the loader
  45304. * @returns the cube texture as an InternalTexture
  45305. */
  45306. 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;
  45307. /**
  45308. * Creates a raw texture
  45309. * @param data defines the data to store in the texture
  45310. * @param width defines the width of the texture
  45311. * @param height defines the height of the texture
  45312. * @param format defines the format of the data
  45313. * @param generateMipMaps defines if the engine should generate the mip levels
  45314. * @param invertY defines if data must be stored with Y axis inverted
  45315. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45316. * @param compression defines the compression used (null by default)
  45317. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45318. * @returns the raw texture inside an InternalTexture
  45319. */
  45320. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45321. /**
  45322. * Creates a new raw cube texture
  45323. * @param data defines the array of data to use to create each face
  45324. * @param size defines the size of the textures
  45325. * @param format defines the format of the data
  45326. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45327. * @param generateMipMaps defines if the engine should generate the mip levels
  45328. * @param invertY defines if data must be stored with Y axis inverted
  45329. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45330. * @param compression defines the compression used (null by default)
  45331. * @returns the cube texture as an InternalTexture
  45332. */
  45333. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45334. /**
  45335. * Creates a new raw cube texture from a specified url
  45336. * @param url defines the url where the data is located
  45337. * @param scene defines the current scene
  45338. * @param size defines the size of the textures
  45339. * @param format defines the format of the data
  45340. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45341. * @param noMipmap defines if the engine should avoid generating the mip levels
  45342. * @param callback defines a callback used to extract texture data from loaded data
  45343. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45344. * @param onLoad defines a callback called when texture is loaded
  45345. * @param onError defines a callback called if there is an error
  45346. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45347. * @param invertY defines if data must be stored with Y axis inverted
  45348. * @returns the cube texture as an InternalTexture
  45349. */
  45350. 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;
  45351. /**
  45352. * Creates a new raw 2D array texture
  45353. * @param data defines the data used to create the texture
  45354. * @param width defines the width of the texture
  45355. * @param height defines the height of the texture
  45356. * @param depth defines the number of layers of the texture
  45357. * @param format defines the format of the texture
  45358. * @param generateMipMaps defines if the engine must generate mip levels
  45359. * @param invertY defines if data must be stored with Y axis inverted
  45360. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45361. * @param compression defines the compressed used (can be null)
  45362. * @param textureType defines the compressed used (can be null)
  45363. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45364. */
  45365. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45366. /**
  45367. * Creates a new raw 3D texture
  45368. * @param data defines the data used to create the texture
  45369. * @param width defines the width of the texture
  45370. * @param height defines the height of the texture
  45371. * @param depth defines the depth of the texture
  45372. * @param format defines the format of the texture
  45373. * @param generateMipMaps defines if the engine must generate mip levels
  45374. * @param invertY defines if data must be stored with Y axis inverted
  45375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45376. * @param compression defines the compressed used (can be null)
  45377. * @param textureType defines the compressed used (can be null)
  45378. * @returns a new raw 3D texture (stored in an InternalTexture)
  45379. */
  45380. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45381. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45382. /**
  45383. * Update the sampling mode of a given texture
  45384. * @param samplingMode defines the required sampling mode
  45385. * @param texture defines the texture to update
  45386. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45387. */
  45388. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45389. /**
  45390. * Update the sampling mode of a given texture
  45391. * @param texture defines the texture to update
  45392. * @param wrapU defines the texture wrap mode of the u coordinates
  45393. * @param wrapV defines the texture wrap mode of the v coordinates
  45394. * @param wrapR defines the texture wrap mode of the r coordinates
  45395. */
  45396. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45397. /**
  45398. * Update the dimensions of a texture
  45399. * @param texture texture to update
  45400. * @param width new width of the texture
  45401. * @param height new height of the texture
  45402. * @param depth new depth of the texture
  45403. */
  45404. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45405. private _setInternalTexture;
  45406. /**
  45407. * Sets a texture to the according uniform.
  45408. * @param channel The texture channel
  45409. * @param unused unused parameter
  45410. * @param texture The texture to apply
  45411. * @param name The name of the uniform in the effect
  45412. */
  45413. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45414. /**
  45415. * Sets an array of texture to the WebGPU context
  45416. * @param channel defines the channel where the texture array must be set
  45417. * @param unused unused parameter
  45418. * @param textures defines the array of textures to bind
  45419. * @param name name of the channel
  45420. */
  45421. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45422. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45423. /** @hidden */
  45424. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45425. /** @hidden */
  45426. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45427. private _generateMipmaps;
  45428. /**
  45429. * Update the content of a texture
  45430. * @param texture defines the texture to update
  45431. * @param canvas defines the source containing the data
  45432. * @param invertY defines if data must be stored with Y axis inverted
  45433. * @param premulAlpha defines if alpha is stored as premultiplied
  45434. * @param format defines the format of the data
  45435. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45436. */
  45437. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45438. /**
  45439. * Update a portion of an internal texture
  45440. * @param texture defines the texture to update
  45441. * @param imageData defines the data to store into the texture
  45442. * @param xOffset defines the x coordinates of the update rectangle
  45443. * @param yOffset defines the y coordinates of the update rectangle
  45444. * @param width defines the width of the update rectangle
  45445. * @param height defines the height of the update rectangle
  45446. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45447. * @param lod defines the lod level to update (0 by default)
  45448. */
  45449. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45450. /**
  45451. * Update a video texture
  45452. * @param texture defines the texture to update
  45453. * @param video defines the video element to use
  45454. * @param invertY defines if data must be stored with Y axis inverted
  45455. */
  45456. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45457. /** @hidden */
  45458. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45459. /** @hidden */
  45460. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45461. /** @hidden */
  45462. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45463. /** @hidden */
  45464. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45465. /**
  45466. * Update a raw texture
  45467. * @param texture defines the texture to update
  45468. * @param bufferView defines the data to store in the texture
  45469. * @param format defines the format of the data
  45470. * @param invertY defines if data must be stored with Y axis inverted
  45471. * @param compression defines the compression used (null by default)
  45472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45473. */
  45474. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45475. /**
  45476. * Update a raw cube texture
  45477. * @param texture defines the texture to udpdate
  45478. * @param bufferView defines the data to store
  45479. * @param format defines the data format
  45480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45481. * @param invertY defines if data must be stored with Y axis inverted
  45482. * @param compression defines the compression used (null by default)
  45483. * @param level defines which level of the texture to update
  45484. */
  45485. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45486. /**
  45487. * Update a raw 2D array texture
  45488. * @param texture defines the texture to update
  45489. * @param bufferView defines the data to store
  45490. * @param format defines the data format
  45491. * @param invertY defines if data must be stored with Y axis inverted
  45492. * @param compression defines the used compression (can be null)
  45493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45494. */
  45495. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45496. /**
  45497. * Update a raw 3D texture
  45498. * @param texture defines the texture to update
  45499. * @param bufferView defines the data to store
  45500. * @param format defines the data format
  45501. * @param invertY defines if data must be stored with Y axis inverted
  45502. * @param compression defines the used compression (can be null)
  45503. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45504. */
  45505. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45506. /**
  45507. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45508. * @param x defines the x coordinate of the rectangle where pixels must be read
  45509. * @param y defines the y coordinate of the rectangle where pixels must be read
  45510. * @param width defines the width of the rectangle where pixels must be read
  45511. * @param height defines the height of the rectangle where pixels must be read
  45512. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45513. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45514. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45515. */
  45516. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45517. /** @hidden */
  45518. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45519. /** @hidden */
  45520. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45521. /**
  45522. * Creates a new render target texture
  45523. * @param size defines the size of the texture
  45524. * @param options defines the options used to create the texture
  45525. * @returns a new render target texture stored in an InternalTexture
  45526. */
  45527. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45528. /**
  45529. * Create a multi render target texture
  45530. * @param size defines the size of the texture
  45531. * @param options defines the creation options
  45532. * @returns the cube texture as an InternalTexture
  45533. */
  45534. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45535. /**
  45536. * Creates a new render target cube texture
  45537. * @param size defines the size of the texture
  45538. * @param options defines the options used to create the texture
  45539. * @returns a new render target cube texture stored in an InternalTexture
  45540. */
  45541. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45542. /** @hidden */
  45543. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45544. width: number;
  45545. height: number;
  45546. layers?: number;
  45547. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45548. /** @hidden */
  45549. _createDepthStencilTexture(size: number | {
  45550. width: number;
  45551. height: number;
  45552. layers?: number;
  45553. }, options: DepthTextureCreationOptions): InternalTexture;
  45554. /** @hidden */
  45555. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45556. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45557. /**
  45558. * Update the sample count for a given multiple render target texture
  45559. * @param textures defines the textures to update
  45560. * @param samples defines the sample count to set
  45561. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45562. */
  45563. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45564. /**
  45565. * Begin a new frame
  45566. */
  45567. beginFrame(): void;
  45568. /**
  45569. * End the current frame
  45570. */
  45571. endFrame(): void;
  45572. /**
  45573. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45574. */
  45575. flushFramebuffer(): void;
  45576. private _startRenderTargetRenderPass;
  45577. private _endRenderTargetRenderPass;
  45578. private _getCurrentRenderPass;
  45579. private _startMainRenderPass;
  45580. private _endMainRenderPass;
  45581. /**
  45582. * Restores the WebGPU state to only draw on the main color attachment
  45583. */
  45584. restoreSingleAttachment(): void;
  45585. /**
  45586. * Creates a layout object to draw/clear on specific textures in a MRT
  45587. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45588. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45589. */
  45590. buildTextureLayout(textureStatus: boolean[]): number[];
  45591. /**
  45592. * Select a subsets of attachments to draw to.
  45593. * @param attachments index of attachments
  45594. */
  45595. bindAttachments(attachments: number[]): void;
  45596. /**
  45597. * Binds the frame buffer to the specified texture.
  45598. * @param texture The texture to render to or null for the default canvas
  45599. * @param faceIndex The face of the texture to render to in case of cube texture
  45600. * @param requiredWidth The width of the target to render to
  45601. * @param requiredHeight The height of the target to render to
  45602. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45603. * @param lodLevel defines the lod level to bind to the frame buffer
  45604. * @param layer defines the 2d array index to bind to frame buffer to
  45605. */
  45606. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45607. /**
  45608. * Unbind the current render target texture from the WebGPU context
  45609. * @param texture defines the render target texture to unbind
  45610. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45611. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45612. */
  45613. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45614. /**
  45615. * Unbind a list of render target textures from the WebGPU context
  45616. * @param textures defines the render target textures to unbind
  45617. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45618. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45619. */
  45620. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45621. /**
  45622. * Unbind the current render target and bind the default framebuffer
  45623. */
  45624. restoreDefaultFramebuffer(): void;
  45625. setZOffset(value: number): void;
  45626. private _setColorFormat;
  45627. private _setDepthTextureFormat;
  45628. setDepthBuffer(enable: boolean): void;
  45629. setDepthWrite(enable: boolean): void;
  45630. setStencilBuffer(enable: boolean): void;
  45631. setStencilMask(mask: number): void;
  45632. setStencilFunction(stencilFunc: number): void;
  45633. setStencilFunctionReference(reference: number): void;
  45634. setStencilFunctionMask(mask: number): void;
  45635. setStencilOperationFail(operation: number): void;
  45636. setStencilOperationDepthFail(operation: number): void;
  45637. setStencilOperationPass(operation: number): void;
  45638. setDitheringState(value: boolean): void;
  45639. setRasterizerState(value: boolean): void;
  45640. setDepthFunction(depthFunc: number): void;
  45641. setDepthFunctionToGreater(): void;
  45642. setDepthFunctionToGreaterOrEqual(): void;
  45643. setDepthFunctionToLess(): void;
  45644. setDepthFunctionToLessOrEqual(): void;
  45645. /**
  45646. * Set various states to the context
  45647. * @param culling defines backface culling state
  45648. * @param zOffset defines the value to apply to zOffset (0 by default)
  45649. * @param force defines if states must be applied even if cache is up to date
  45650. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45651. */
  45652. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45653. /**
  45654. * Sets the current alpha mode
  45655. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45656. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45657. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45658. */
  45659. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45660. /**
  45661. * Sets the current alpha equation
  45662. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45663. */
  45664. setAlphaEquation(equation: number): void;
  45665. private _getBindGroupsToRender;
  45666. private _bindVertexInputs;
  45667. private _setRenderBindGroups;
  45668. private _setRenderPipeline;
  45669. /**
  45670. * Draw a list of indexed primitives
  45671. * @param fillMode defines the primitive to use
  45672. * @param indexStart defines the starting index
  45673. * @param indexCount defines the number of index to draw
  45674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45675. */
  45676. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45677. /**
  45678. * Draw a list of unindexed primitives
  45679. * @param fillMode defines the primitive to use
  45680. * @param verticesStart defines the index of first vertex to draw
  45681. * @param verticesCount defines the count of vertices to draw
  45682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45683. */
  45684. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45685. private _bundleEncoder;
  45686. /**
  45687. * Start recording all the gpu calls into a bundle.
  45688. */
  45689. startRecordBundle(): void;
  45690. /**
  45691. * Stops recording the bundle.
  45692. * @returns the recorded bundle
  45693. */
  45694. stopRecordBundle(): GPURenderBundle;
  45695. /**
  45696. * Execute the previously recorded bundle.
  45697. * @param bundles defines the bundle to replay
  45698. */
  45699. executeBundles(bundles: GPURenderBundle[]): void;
  45700. /**
  45701. * Dispose and release all associated resources
  45702. */
  45703. dispose(): void;
  45704. /**
  45705. * Gets the current render width
  45706. * @param useScreen defines if screen size must be used (or the current render target if any)
  45707. * @returns a number defining the current render width
  45708. */
  45709. getRenderWidth(useScreen?: boolean): number;
  45710. /**
  45711. * Gets the current render height
  45712. * @param useScreen defines if screen size must be used (or the current render target if any)
  45713. * @returns a number defining the current render height
  45714. */
  45715. getRenderHeight(useScreen?: boolean): number;
  45716. /**
  45717. * Gets the HTML canvas attached with the current WebGPU context
  45718. * @returns a HTML canvas
  45719. */
  45720. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45721. /** @hidden */
  45722. _debugPushGroup(groupName: string, targetObject?: number): void;
  45723. /** @hidden */
  45724. _debugPopGroup(targetObject?: number): void;
  45725. /** @hidden */
  45726. _debugInsertMarker(text: string, targetObject?: number): void;
  45727. private _debugFlushPendingCommands;
  45728. /**
  45729. * Get the current error code of the WebGPU context
  45730. * @returns the error code
  45731. */
  45732. getError(): number;
  45733. /** @hidden */
  45734. bindSamplers(effect: Effect): void;
  45735. /** @hidden */
  45736. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45737. /** @hidden */
  45738. _releaseFramebufferObjects(texture: InternalTexture): void;
  45739. /** @hidden */
  45740. applyStates(): void;
  45741. /**
  45742. * Gets a boolean indicating if all created effects are ready
  45743. * @returns always true - No parallel shader compilation
  45744. */
  45745. areAllEffectsReady(): boolean;
  45746. /** @hidden */
  45747. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45748. /** @hidden */
  45749. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45750. /** @hidden */
  45751. _getUnpackAlignement(): number;
  45752. /** @hidden */
  45753. _unpackFlipY(value: boolean): void;
  45754. /** @hidden */
  45755. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45756. min: number;
  45757. mag: number;
  45758. };
  45759. /** @hidden */
  45760. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45761. /** @hidden */
  45762. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45763. /** @hidden */
  45764. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45765. /** @hidden */
  45766. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45767. /** @hidden */
  45768. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45769. /** @hidden */
  45770. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45771. /** @hidden */
  45772. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45773. /** @hidden */
  45774. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45775. /** @hidden */
  45776. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45777. /** @hidden */
  45778. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45779. /** @hidden */
  45780. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45781. /** @hidden */
  45782. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45783. /** @hidden */
  45784. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45785. /** @hidden */
  45786. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45787. /** @hidden */
  45788. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45789. /** @hidden */
  45790. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45791. /** @hidden */
  45792. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45793. }
  45794. }
  45795. declare module BABYLON {
  45796. /**
  45797. * Define an interface for all classes that will hold resources
  45798. */
  45799. export interface IDisposable {
  45800. /**
  45801. * Releases all held resources
  45802. */
  45803. dispose(): void;
  45804. }
  45805. /** Interface defining initialization parameters for Scene class */
  45806. export interface SceneOptions {
  45807. /**
  45808. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45809. * It will improve performance when the number of geometries becomes important.
  45810. */
  45811. useGeometryUniqueIdsMap?: boolean;
  45812. /**
  45813. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45814. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45815. */
  45816. useMaterialMeshMap?: boolean;
  45817. /**
  45818. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45819. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45820. */
  45821. useClonedMeshMap?: boolean;
  45822. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45823. virtual?: boolean;
  45824. }
  45825. /**
  45826. * Represents a scene to be rendered by the engine.
  45827. * @see https://doc.babylonjs.com/features/scene
  45828. */
  45829. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45830. /** The fog is deactivated */
  45831. static readonly FOGMODE_NONE: number;
  45832. /** The fog density is following an exponential function */
  45833. static readonly FOGMODE_EXP: number;
  45834. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45835. static readonly FOGMODE_EXP2: number;
  45836. /** The fog density is following a linear function. */
  45837. static readonly FOGMODE_LINEAR: number;
  45838. /**
  45839. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45840. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45841. */
  45842. static MinDeltaTime: number;
  45843. /**
  45844. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45845. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45846. */
  45847. static MaxDeltaTime: number;
  45848. /**
  45849. * Factory used to create the default material.
  45850. * @param name The name of the material to create
  45851. * @param scene The scene to create the material for
  45852. * @returns The default material
  45853. */
  45854. static DefaultMaterialFactory(scene: Scene): Material;
  45855. /**
  45856. * Factory used to create the a collision coordinator.
  45857. * @returns The collision coordinator
  45858. */
  45859. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45860. /** @hidden */
  45861. _inputManager: InputManager;
  45862. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45863. cameraToUseForPointers: Nullable<Camera>;
  45864. /** @hidden */
  45865. readonly _isScene: boolean;
  45866. /** @hidden */
  45867. _blockEntityCollection: boolean;
  45868. /**
  45869. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45870. */
  45871. autoClear: boolean;
  45872. /**
  45873. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45874. */
  45875. autoClearDepthAndStencil: boolean;
  45876. /**
  45877. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45878. */
  45879. clearColor: Color4;
  45880. /**
  45881. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45882. */
  45883. ambientColor: Color3;
  45884. /**
  45885. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45886. * It should only be one of the following (if not the default embedded one):
  45887. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45888. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45889. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45890. * The material properties need to be setup according to the type of texture in use.
  45891. */
  45892. environmentBRDFTexture: BaseTexture;
  45893. /**
  45894. * Texture used in all pbr material as the reflection texture.
  45895. * As in the majority of the scene they are the same (exception for multi room and so on),
  45896. * this is easier to reference from here than from all the materials.
  45897. */
  45898. get environmentTexture(): Nullable<BaseTexture>;
  45899. /**
  45900. * Texture used in all pbr material as the reflection texture.
  45901. * As in the majority of the scene they are the same (exception for multi room and so on),
  45902. * this is easier to set here than in all the materials.
  45903. */
  45904. set environmentTexture(value: Nullable<BaseTexture>);
  45905. /** @hidden */
  45906. protected _environmentIntensity: number;
  45907. /**
  45908. * Intensity of the environment in all pbr material.
  45909. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45910. * As in the majority of the scene they are the same (exception for multi room and so on),
  45911. * this is easier to reference from here than from all the materials.
  45912. */
  45913. get environmentIntensity(): number;
  45914. /**
  45915. * Intensity of the environment in all pbr material.
  45916. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45917. * As in the majority of the scene they are the same (exception for multi room and so on),
  45918. * this is easier to set here than in all the materials.
  45919. */
  45920. set environmentIntensity(value: number);
  45921. /** @hidden */
  45922. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45923. /**
  45924. * Default image processing configuration used either in the rendering
  45925. * Forward main pass or through the imageProcessingPostProcess if present.
  45926. * As in the majority of the scene they are the same (exception for multi camera),
  45927. * this is easier to reference from here than from all the materials and post process.
  45928. *
  45929. * No setter as we it is a shared configuration, you can set the values instead.
  45930. */
  45931. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45932. private _forceWireframe;
  45933. /**
  45934. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45935. */
  45936. set forceWireframe(value: boolean);
  45937. get forceWireframe(): boolean;
  45938. private _skipFrustumClipping;
  45939. /**
  45940. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45941. */
  45942. set skipFrustumClipping(value: boolean);
  45943. get skipFrustumClipping(): boolean;
  45944. private _forcePointsCloud;
  45945. /**
  45946. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45947. */
  45948. set forcePointsCloud(value: boolean);
  45949. get forcePointsCloud(): boolean;
  45950. /**
  45951. * Gets or sets the active clipplane 1
  45952. */
  45953. clipPlane: Nullable<Plane>;
  45954. /**
  45955. * Gets or sets the active clipplane 2
  45956. */
  45957. clipPlane2: Nullable<Plane>;
  45958. /**
  45959. * Gets or sets the active clipplane 3
  45960. */
  45961. clipPlane3: Nullable<Plane>;
  45962. /**
  45963. * Gets or sets the active clipplane 4
  45964. */
  45965. clipPlane4: Nullable<Plane>;
  45966. /**
  45967. * Gets or sets the active clipplane 5
  45968. */
  45969. clipPlane5: Nullable<Plane>;
  45970. /**
  45971. * Gets or sets the active clipplane 6
  45972. */
  45973. clipPlane6: Nullable<Plane>;
  45974. /**
  45975. * Gets or sets a boolean indicating if animations are enabled
  45976. */
  45977. animationsEnabled: boolean;
  45978. private _animationPropertiesOverride;
  45979. /**
  45980. * Gets or sets the animation properties override
  45981. */
  45982. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45983. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45984. /**
  45985. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45986. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45987. */
  45988. useConstantAnimationDeltaTime: boolean;
  45989. /**
  45990. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45991. * Please note that it requires to run a ray cast through the scene on every frame
  45992. */
  45993. constantlyUpdateMeshUnderPointer: boolean;
  45994. /**
  45995. * Defines the HTML cursor to use when hovering over interactive elements
  45996. */
  45997. hoverCursor: string;
  45998. /**
  45999. * Defines the HTML default cursor to use (empty by default)
  46000. */
  46001. defaultCursor: string;
  46002. /**
  46003. * Defines whether cursors are handled by the scene.
  46004. */
  46005. doNotHandleCursors: boolean;
  46006. /**
  46007. * This is used to call preventDefault() on pointer down
  46008. * in order to block unwanted artifacts like system double clicks
  46009. */
  46010. preventDefaultOnPointerDown: boolean;
  46011. /**
  46012. * This is used to call preventDefault() on pointer up
  46013. * in order to block unwanted artifacts like system double clicks
  46014. */
  46015. preventDefaultOnPointerUp: boolean;
  46016. /**
  46017. * Gets or sets user defined metadata
  46018. */
  46019. metadata: any;
  46020. /**
  46021. * For internal use only. Please do not use.
  46022. */
  46023. reservedDataStore: any;
  46024. /**
  46025. * Gets the name of the plugin used to load this scene (null by default)
  46026. */
  46027. loadingPluginName: string;
  46028. /**
  46029. * Use this array to add regular expressions used to disable offline support for specific urls
  46030. */
  46031. disableOfflineSupportExceptionRules: RegExp[];
  46032. /**
  46033. * An event triggered when the scene is disposed.
  46034. */
  46035. onDisposeObservable: Observable<Scene>;
  46036. private _onDisposeObserver;
  46037. /** Sets a function to be executed when this scene is disposed. */
  46038. set onDispose(callback: () => void);
  46039. /**
  46040. * An event triggered before rendering the scene (right after animations and physics)
  46041. */
  46042. onBeforeRenderObservable: Observable<Scene>;
  46043. private _onBeforeRenderObserver;
  46044. /** Sets a function to be executed before rendering this scene */
  46045. set beforeRender(callback: Nullable<() => void>);
  46046. /**
  46047. * An event triggered after rendering the scene
  46048. */
  46049. onAfterRenderObservable: Observable<Scene>;
  46050. /**
  46051. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46052. */
  46053. onAfterRenderCameraObservable: Observable<Camera>;
  46054. private _onAfterRenderObserver;
  46055. /** Sets a function to be executed after rendering this scene */
  46056. set afterRender(callback: Nullable<() => void>);
  46057. /**
  46058. * An event triggered before animating the scene
  46059. */
  46060. onBeforeAnimationsObservable: Observable<Scene>;
  46061. /**
  46062. * An event triggered after animations processing
  46063. */
  46064. onAfterAnimationsObservable: Observable<Scene>;
  46065. /**
  46066. * An event triggered before draw calls are ready to be sent
  46067. */
  46068. onBeforeDrawPhaseObservable: Observable<Scene>;
  46069. /**
  46070. * An event triggered after draw calls have been sent
  46071. */
  46072. onAfterDrawPhaseObservable: Observable<Scene>;
  46073. /**
  46074. * An event triggered when the scene is ready
  46075. */
  46076. onReadyObservable: Observable<Scene>;
  46077. /**
  46078. * An event triggered before rendering a camera
  46079. */
  46080. onBeforeCameraRenderObservable: Observable<Camera>;
  46081. private _onBeforeCameraRenderObserver;
  46082. /** Sets a function to be executed before rendering a camera*/
  46083. set beforeCameraRender(callback: () => void);
  46084. /**
  46085. * An event triggered after rendering a camera
  46086. */
  46087. onAfterCameraRenderObservable: Observable<Camera>;
  46088. private _onAfterCameraRenderObserver;
  46089. /** Sets a function to be executed after rendering a camera*/
  46090. set afterCameraRender(callback: () => void);
  46091. /**
  46092. * An event triggered when active meshes evaluation is about to start
  46093. */
  46094. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46095. /**
  46096. * An event triggered when active meshes evaluation is done
  46097. */
  46098. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46099. /**
  46100. * An event triggered when particles rendering is about to start
  46101. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46102. */
  46103. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46104. /**
  46105. * An event triggered when particles rendering is done
  46106. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46107. */
  46108. onAfterParticlesRenderingObservable: Observable<Scene>;
  46109. /**
  46110. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46111. */
  46112. onDataLoadedObservable: Observable<Scene>;
  46113. /**
  46114. * An event triggered when a camera is created
  46115. */
  46116. onNewCameraAddedObservable: Observable<Camera>;
  46117. /**
  46118. * An event triggered when a camera is removed
  46119. */
  46120. onCameraRemovedObservable: Observable<Camera>;
  46121. /**
  46122. * An event triggered when a light is created
  46123. */
  46124. onNewLightAddedObservable: Observable<Light>;
  46125. /**
  46126. * An event triggered when a light is removed
  46127. */
  46128. onLightRemovedObservable: Observable<Light>;
  46129. /**
  46130. * An event triggered when a geometry is created
  46131. */
  46132. onNewGeometryAddedObservable: Observable<Geometry>;
  46133. /**
  46134. * An event triggered when a geometry is removed
  46135. */
  46136. onGeometryRemovedObservable: Observable<Geometry>;
  46137. /**
  46138. * An event triggered when a transform node is created
  46139. */
  46140. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46141. /**
  46142. * An event triggered when a transform node is removed
  46143. */
  46144. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46145. /**
  46146. * An event triggered when a mesh is created
  46147. */
  46148. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46149. /**
  46150. * An event triggered when a mesh is removed
  46151. */
  46152. onMeshRemovedObservable: Observable<AbstractMesh>;
  46153. /**
  46154. * An event triggered when a skeleton is created
  46155. */
  46156. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46157. /**
  46158. * An event triggered when a skeleton is removed
  46159. */
  46160. onSkeletonRemovedObservable: Observable<Skeleton>;
  46161. /**
  46162. * An event triggered when a material is created
  46163. */
  46164. onNewMaterialAddedObservable: Observable<Material>;
  46165. /**
  46166. * An event triggered when a multi material is created
  46167. */
  46168. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46169. /**
  46170. * An event triggered when a material is removed
  46171. */
  46172. onMaterialRemovedObservable: Observable<Material>;
  46173. /**
  46174. * An event triggered when a multi material is removed
  46175. */
  46176. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46177. /**
  46178. * An event triggered when a texture is created
  46179. */
  46180. onNewTextureAddedObservable: Observable<BaseTexture>;
  46181. /**
  46182. * An event triggered when a texture is removed
  46183. */
  46184. onTextureRemovedObservable: Observable<BaseTexture>;
  46185. /**
  46186. * An event triggered when render targets are about to be rendered
  46187. * Can happen multiple times per frame.
  46188. */
  46189. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46190. /**
  46191. * An event triggered when render targets were rendered.
  46192. * Can happen multiple times per frame.
  46193. */
  46194. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46195. /**
  46196. * An event triggered before calculating deterministic simulation step
  46197. */
  46198. onBeforeStepObservable: Observable<Scene>;
  46199. /**
  46200. * An event triggered after calculating deterministic simulation step
  46201. */
  46202. onAfterStepObservable: Observable<Scene>;
  46203. /**
  46204. * An event triggered when the activeCamera property is updated
  46205. */
  46206. onActiveCameraChanged: Observable<Scene>;
  46207. /**
  46208. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46209. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46210. * 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)
  46211. */
  46212. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46213. /**
  46214. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46215. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46216. * 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)
  46217. */
  46218. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46219. /**
  46220. * This Observable will when a mesh has been imported into the scene.
  46221. */
  46222. onMeshImportedObservable: Observable<AbstractMesh>;
  46223. /**
  46224. * This Observable will when an animation file has been imported into the scene.
  46225. */
  46226. onAnimationFileImportedObservable: Observable<Scene>;
  46227. /**
  46228. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46229. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46230. */
  46231. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46232. /** @hidden */
  46233. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46234. /**
  46235. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46236. */
  46237. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46238. /**
  46239. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46240. */
  46241. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46242. /**
  46243. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46244. */
  46245. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46246. /** Callback called when a pointer move is detected */
  46247. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46248. /** Callback called when a pointer down is detected */
  46249. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46250. /** Callback called when a pointer up is detected */
  46251. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46252. /** Callback called when a pointer pick is detected */
  46253. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46254. /**
  46255. * 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).
  46256. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46257. */
  46258. onPrePointerObservable: Observable<PointerInfoPre>;
  46259. /**
  46260. * Observable event triggered each time an input event is received from the rendering canvas
  46261. */
  46262. onPointerObservable: Observable<PointerInfo>;
  46263. /**
  46264. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46265. */
  46266. get unTranslatedPointer(): Vector2;
  46267. /**
  46268. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46269. */
  46270. static get DragMovementThreshold(): number;
  46271. static set DragMovementThreshold(value: number);
  46272. /**
  46273. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46274. */
  46275. static get LongPressDelay(): number;
  46276. static set LongPressDelay(value: number);
  46277. /**
  46278. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46279. */
  46280. static get DoubleClickDelay(): number;
  46281. static set DoubleClickDelay(value: number);
  46282. /** If you need to check double click without raising a single click at first click, enable this flag */
  46283. static get ExclusiveDoubleClickMode(): boolean;
  46284. static set ExclusiveDoubleClickMode(value: boolean);
  46285. /** @hidden */
  46286. _mirroredCameraPosition: Nullable<Vector3>;
  46287. /**
  46288. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46289. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46290. */
  46291. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46292. /**
  46293. * Observable event triggered each time an keyboard event is received from the hosting window
  46294. */
  46295. onKeyboardObservable: Observable<KeyboardInfo>;
  46296. private _useRightHandedSystem;
  46297. /**
  46298. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46299. */
  46300. set useRightHandedSystem(value: boolean);
  46301. get useRightHandedSystem(): boolean;
  46302. private _timeAccumulator;
  46303. private _currentStepId;
  46304. private _currentInternalStep;
  46305. /**
  46306. * Sets the step Id used by deterministic lock step
  46307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46308. * @param newStepId defines the step Id
  46309. */
  46310. setStepId(newStepId: number): void;
  46311. /**
  46312. * Gets the step Id used by deterministic lock step
  46313. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46314. * @returns the step Id
  46315. */
  46316. getStepId(): number;
  46317. /**
  46318. * Gets the internal step used by deterministic lock step
  46319. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46320. * @returns the internal step
  46321. */
  46322. getInternalStep(): number;
  46323. private _fogEnabled;
  46324. /**
  46325. * Gets or sets a boolean indicating if fog is enabled on this scene
  46326. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46327. * (Default is true)
  46328. */
  46329. set fogEnabled(value: boolean);
  46330. get fogEnabled(): boolean;
  46331. private _fogMode;
  46332. /**
  46333. * Gets or sets the fog mode to use
  46334. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46335. * | mode | value |
  46336. * | --- | --- |
  46337. * | FOGMODE_NONE | 0 |
  46338. * | FOGMODE_EXP | 1 |
  46339. * | FOGMODE_EXP2 | 2 |
  46340. * | FOGMODE_LINEAR | 3 |
  46341. */
  46342. set fogMode(value: number);
  46343. get fogMode(): number;
  46344. /**
  46345. * Gets or sets the fog color to use
  46346. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46347. * (Default is Color3(0.2, 0.2, 0.3))
  46348. */
  46349. fogColor: Color3;
  46350. /**
  46351. * Gets or sets the fog density to use
  46352. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46353. * (Default is 0.1)
  46354. */
  46355. fogDensity: number;
  46356. /**
  46357. * Gets or sets the fog start distance to use
  46358. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46359. * (Default is 0)
  46360. */
  46361. fogStart: number;
  46362. /**
  46363. * Gets or sets the fog end distance to use
  46364. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46365. * (Default is 1000)
  46366. */
  46367. fogEnd: number;
  46368. /**
  46369. * Flag indicating that the frame buffer binding is handled by another component
  46370. */
  46371. prePass: boolean;
  46372. private _shadowsEnabled;
  46373. /**
  46374. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46375. */
  46376. set shadowsEnabled(value: boolean);
  46377. get shadowsEnabled(): boolean;
  46378. private _lightsEnabled;
  46379. /**
  46380. * Gets or sets a boolean indicating if lights are enabled on this scene
  46381. */
  46382. set lightsEnabled(value: boolean);
  46383. get lightsEnabled(): boolean;
  46384. /** All of the active cameras added to this scene. */
  46385. activeCameras: Nullable<Camera[]>;
  46386. /** @hidden */
  46387. _activeCamera: Nullable<Camera>;
  46388. /** Gets or sets the current active camera */
  46389. get activeCamera(): Nullable<Camera>;
  46390. set activeCamera(value: Nullable<Camera>);
  46391. private _defaultMaterial;
  46392. /** The default material used on meshes when no material is affected */
  46393. get defaultMaterial(): Material;
  46394. /** The default material used on meshes when no material is affected */
  46395. set defaultMaterial(value: Material);
  46396. private _texturesEnabled;
  46397. /**
  46398. * Gets or sets a boolean indicating if textures are enabled on this scene
  46399. */
  46400. set texturesEnabled(value: boolean);
  46401. get texturesEnabled(): boolean;
  46402. /**
  46403. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46404. */
  46405. physicsEnabled: boolean;
  46406. /**
  46407. * Gets or sets a boolean indicating if particles are enabled on this scene
  46408. */
  46409. particlesEnabled: boolean;
  46410. /**
  46411. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46412. */
  46413. spritesEnabled: boolean;
  46414. private _skeletonsEnabled;
  46415. /**
  46416. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46417. */
  46418. set skeletonsEnabled(value: boolean);
  46419. get skeletonsEnabled(): boolean;
  46420. /**
  46421. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46422. */
  46423. lensFlaresEnabled: boolean;
  46424. /**
  46425. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46426. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46427. */
  46428. collisionsEnabled: boolean;
  46429. private _collisionCoordinator;
  46430. /** @hidden */
  46431. get collisionCoordinator(): ICollisionCoordinator;
  46432. /**
  46433. * Defines the gravity applied to this scene (used only for collisions)
  46434. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46435. */
  46436. gravity: Vector3;
  46437. /**
  46438. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46439. */
  46440. postProcessesEnabled: boolean;
  46441. /**
  46442. * Gets the current postprocess manager
  46443. */
  46444. postProcessManager: PostProcessManager;
  46445. /**
  46446. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46447. */
  46448. renderTargetsEnabled: boolean;
  46449. /**
  46450. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46451. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46452. */
  46453. dumpNextRenderTargets: boolean;
  46454. /**
  46455. * The list of user defined render targets added to the scene
  46456. */
  46457. customRenderTargets: RenderTargetTexture[];
  46458. /**
  46459. * Defines if texture loading must be delayed
  46460. * If true, textures will only be loaded when they need to be rendered
  46461. */
  46462. useDelayedTextureLoading: boolean;
  46463. /**
  46464. * Gets the list of meshes imported to the scene through SceneLoader
  46465. */
  46466. importedMeshesFiles: String[];
  46467. /**
  46468. * Gets or sets a boolean indicating if probes are enabled on this scene
  46469. */
  46470. probesEnabled: boolean;
  46471. /**
  46472. * Gets or sets the current offline provider to use to store scene data
  46473. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46474. */
  46475. offlineProvider: IOfflineProvider;
  46476. /**
  46477. * Gets or sets the action manager associated with the scene
  46478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46479. */
  46480. actionManager: AbstractActionManager;
  46481. private _meshesForIntersections;
  46482. /**
  46483. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46484. */
  46485. proceduralTexturesEnabled: boolean;
  46486. private _engine;
  46487. private _totalVertices;
  46488. /** @hidden */
  46489. _activeIndices: PerfCounter;
  46490. /** @hidden */
  46491. _activeParticles: PerfCounter;
  46492. /** @hidden */
  46493. _activeBones: PerfCounter;
  46494. private _animationRatio;
  46495. /** @hidden */
  46496. _animationTimeLast: number;
  46497. /** @hidden */
  46498. _animationTime: number;
  46499. /**
  46500. * Gets or sets a general scale for animation speed
  46501. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46502. */
  46503. animationTimeScale: number;
  46504. /** @hidden */
  46505. _cachedMaterial: Nullable<Material>;
  46506. /** @hidden */
  46507. _cachedEffect: Nullable<Effect>;
  46508. /** @hidden */
  46509. _cachedVisibility: Nullable<number>;
  46510. private _renderId;
  46511. private _frameId;
  46512. private _executeWhenReadyTimeoutId;
  46513. private _intermediateRendering;
  46514. private _viewUpdateFlag;
  46515. private _projectionUpdateFlag;
  46516. /** @hidden */
  46517. _toBeDisposed: Nullable<IDisposable>[];
  46518. private _activeRequests;
  46519. /** @hidden */
  46520. _pendingData: any[];
  46521. private _isDisposed;
  46522. /**
  46523. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46524. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46525. */
  46526. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46527. private _activeMeshes;
  46528. private _processedMaterials;
  46529. private _renderTargets;
  46530. /** @hidden */
  46531. _activeParticleSystems: SmartArray<IParticleSystem>;
  46532. private _activeSkeletons;
  46533. private _softwareSkinnedMeshes;
  46534. private _renderingManager;
  46535. /** @hidden */
  46536. _activeAnimatables: Animatable[];
  46537. private _transformMatrix;
  46538. private _sceneUbo;
  46539. /** @hidden */
  46540. _viewMatrix: Matrix;
  46541. /** @hidden */
  46542. _projectionMatrix: Matrix;
  46543. /** @hidden */
  46544. _forcedViewPosition: Nullable<Vector3>;
  46545. /** @hidden */
  46546. _frustumPlanes: Plane[];
  46547. /**
  46548. * Gets the list of frustum planes (built from the active camera)
  46549. */
  46550. get frustumPlanes(): Plane[];
  46551. /**
  46552. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46553. * This is useful if there are more lights that the maximum simulteanous authorized
  46554. */
  46555. requireLightSorting: boolean;
  46556. /** @hidden */
  46557. readonly useMaterialMeshMap: boolean;
  46558. /** @hidden */
  46559. readonly useClonedMeshMap: boolean;
  46560. private _externalData;
  46561. private _uid;
  46562. /**
  46563. * @hidden
  46564. * Backing store of defined scene components.
  46565. */
  46566. _components: ISceneComponent[];
  46567. /**
  46568. * @hidden
  46569. * Backing store of defined scene components.
  46570. */
  46571. _serializableComponents: ISceneSerializableComponent[];
  46572. /**
  46573. * List of components to register on the next registration step.
  46574. */
  46575. private _transientComponents;
  46576. /**
  46577. * Registers the transient components if needed.
  46578. */
  46579. private _registerTransientComponents;
  46580. /**
  46581. * @hidden
  46582. * Add a component to the scene.
  46583. * Note that the ccomponent could be registered on th next frame if this is called after
  46584. * the register component stage.
  46585. * @param component Defines the component to add to the scene
  46586. */
  46587. _addComponent(component: ISceneComponent): void;
  46588. /**
  46589. * @hidden
  46590. * Gets a component from the scene.
  46591. * @param name defines the name of the component to retrieve
  46592. * @returns the component or null if not present
  46593. */
  46594. _getComponent(name: string): Nullable<ISceneComponent>;
  46595. /**
  46596. * @hidden
  46597. * Defines the actions happening before camera updates.
  46598. */
  46599. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46600. /**
  46601. * @hidden
  46602. * Defines the actions happening before clear the canvas.
  46603. */
  46604. _beforeClearStage: Stage<SimpleStageAction>;
  46605. /**
  46606. * @hidden
  46607. * Defines the actions when collecting render targets for the frame.
  46608. */
  46609. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46610. /**
  46611. * @hidden
  46612. * Defines the actions happening for one camera in the frame.
  46613. */
  46614. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46615. /**
  46616. * @hidden
  46617. * Defines the actions happening during the per mesh ready checks.
  46618. */
  46619. _isReadyForMeshStage: Stage<MeshStageAction>;
  46620. /**
  46621. * @hidden
  46622. * Defines the actions happening before evaluate active mesh checks.
  46623. */
  46624. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46625. /**
  46626. * @hidden
  46627. * Defines the actions happening during the evaluate sub mesh checks.
  46628. */
  46629. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46630. /**
  46631. * @hidden
  46632. * Defines the actions happening during the active mesh stage.
  46633. */
  46634. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46635. /**
  46636. * @hidden
  46637. * Defines the actions happening during the per camera render target step.
  46638. */
  46639. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46640. /**
  46641. * @hidden
  46642. * Defines the actions happening just before the active camera is drawing.
  46643. */
  46644. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46645. /**
  46646. * @hidden
  46647. * Defines the actions happening just before a render target is drawing.
  46648. */
  46649. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46650. /**
  46651. * @hidden
  46652. * Defines the actions happening just before a rendering group is drawing.
  46653. */
  46654. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46655. /**
  46656. * @hidden
  46657. * Defines the actions happening just before a mesh is drawing.
  46658. */
  46659. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46660. /**
  46661. * @hidden
  46662. * Defines the actions happening just after a mesh has been drawn.
  46663. */
  46664. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46665. /**
  46666. * @hidden
  46667. * Defines the actions happening just after a rendering group has been drawn.
  46668. */
  46669. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46670. /**
  46671. * @hidden
  46672. * Defines the actions happening just after the active camera has been drawn.
  46673. */
  46674. _afterCameraDrawStage: Stage<CameraStageAction>;
  46675. /**
  46676. * @hidden
  46677. * Defines the actions happening just after a render target has been drawn.
  46678. */
  46679. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46680. /**
  46681. * @hidden
  46682. * Defines the actions happening just after rendering all cameras and computing intersections.
  46683. */
  46684. _afterRenderStage: Stage<SimpleStageAction>;
  46685. /**
  46686. * @hidden
  46687. * Defines the actions happening when a pointer move event happens.
  46688. */
  46689. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46690. /**
  46691. * @hidden
  46692. * Defines the actions happening when a pointer down event happens.
  46693. */
  46694. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46695. /**
  46696. * @hidden
  46697. * Defines the actions happening when a pointer up event happens.
  46698. */
  46699. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46700. /**
  46701. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46702. */
  46703. private geometriesByUniqueId;
  46704. private _renderBundles;
  46705. /**
  46706. * Creates a new Scene
  46707. * @param engine defines the engine to use to render this scene
  46708. * @param options defines the scene options
  46709. */
  46710. constructor(engine: Engine, options?: SceneOptions);
  46711. /**
  46712. * Gets a string identifying the name of the class
  46713. * @returns "Scene" string
  46714. */
  46715. getClassName(): string;
  46716. private _defaultMeshCandidates;
  46717. /**
  46718. * @hidden
  46719. */
  46720. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46721. private _defaultSubMeshCandidates;
  46722. /**
  46723. * @hidden
  46724. */
  46725. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46726. /**
  46727. * Sets the default candidate providers for the scene.
  46728. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46729. * and getCollidingSubMeshCandidates to their default function
  46730. */
  46731. setDefaultCandidateProviders(): void;
  46732. /**
  46733. * Gets the mesh that is currently under the pointer
  46734. */
  46735. get meshUnderPointer(): Nullable<AbstractMesh>;
  46736. /**
  46737. * Gets or sets the current on-screen X position of the pointer
  46738. */
  46739. get pointerX(): number;
  46740. set pointerX(value: number);
  46741. /**
  46742. * Gets or sets the current on-screen Y position of the pointer
  46743. */
  46744. get pointerY(): number;
  46745. set pointerY(value: number);
  46746. /**
  46747. * Gets the cached material (ie. the latest rendered one)
  46748. * @returns the cached material
  46749. */
  46750. getCachedMaterial(): Nullable<Material>;
  46751. /**
  46752. * Gets the cached effect (ie. the latest rendered one)
  46753. * @returns the cached effect
  46754. */
  46755. getCachedEffect(): Nullable<Effect>;
  46756. /**
  46757. * Gets the cached visibility state (ie. the latest rendered one)
  46758. * @returns the cached visibility state
  46759. */
  46760. getCachedVisibility(): Nullable<number>;
  46761. /**
  46762. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46763. * @param material defines the current material
  46764. * @param effect defines the current effect
  46765. * @param visibility defines the current visibility state
  46766. * @returns true if one parameter is not cached
  46767. */
  46768. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46769. /**
  46770. * Gets the engine associated with the scene
  46771. * @returns an Engine
  46772. */
  46773. getEngine(): Engine;
  46774. /**
  46775. * Gets the total number of vertices rendered per frame
  46776. * @returns the total number of vertices rendered per frame
  46777. */
  46778. getTotalVertices(): number;
  46779. /**
  46780. * Gets the performance counter for total vertices
  46781. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46782. */
  46783. get totalVerticesPerfCounter(): PerfCounter;
  46784. /**
  46785. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46786. * @returns the total number of active indices rendered per frame
  46787. */
  46788. getActiveIndices(): number;
  46789. /**
  46790. * Gets the performance counter for active indices
  46791. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46792. */
  46793. get totalActiveIndicesPerfCounter(): PerfCounter;
  46794. /**
  46795. * Gets the total number of active particles rendered per frame
  46796. * @returns the total number of active particles rendered per frame
  46797. */
  46798. getActiveParticles(): number;
  46799. /**
  46800. * Gets the performance counter for active particles
  46801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46802. */
  46803. get activeParticlesPerfCounter(): PerfCounter;
  46804. /**
  46805. * Gets the total number of active bones rendered per frame
  46806. * @returns the total number of active bones rendered per frame
  46807. */
  46808. getActiveBones(): number;
  46809. /**
  46810. * Gets the performance counter for active bones
  46811. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46812. */
  46813. get activeBonesPerfCounter(): PerfCounter;
  46814. /**
  46815. * Gets the array of active meshes
  46816. * @returns an array of AbstractMesh
  46817. */
  46818. getActiveMeshes(): SmartArray<AbstractMesh>;
  46819. /**
  46820. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46821. * @returns a number
  46822. */
  46823. getAnimationRatio(): number;
  46824. /**
  46825. * Gets an unique Id for the current render phase
  46826. * @returns a number
  46827. */
  46828. getRenderId(): number;
  46829. /**
  46830. * Gets an unique Id for the current frame
  46831. * @returns a number
  46832. */
  46833. getFrameId(): number;
  46834. /** Call this function if you want to manually increment the render Id*/
  46835. incrementRenderId(): void;
  46836. private _createUbo;
  46837. /**
  46838. * Use this method to simulate a pointer move on a mesh
  46839. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46840. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46841. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46842. * @returns the current scene
  46843. */
  46844. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46845. /**
  46846. * Use this method to simulate a pointer down on a mesh
  46847. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46848. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46849. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46850. * @returns the current scene
  46851. */
  46852. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46853. /**
  46854. * Use this method to simulate a pointer up on a mesh
  46855. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46856. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46857. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46858. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46859. * @returns the current scene
  46860. */
  46861. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46862. /**
  46863. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46864. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46865. * @returns true if the pointer was captured
  46866. */
  46867. isPointerCaptured(pointerId?: number): boolean;
  46868. /**
  46869. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46870. * @param attachUp defines if you want to attach events to pointerup
  46871. * @param attachDown defines if you want to attach events to pointerdown
  46872. * @param attachMove defines if you want to attach events to pointermove
  46873. */
  46874. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46875. /** Detaches all event handlers*/
  46876. detachControl(): void;
  46877. /**
  46878. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46879. * Delay loaded resources are not taking in account
  46880. * @return true if all required resources are ready
  46881. */
  46882. isReady(): boolean;
  46883. /** Resets all cached information relative to material (including effect and visibility) */
  46884. resetCachedMaterial(): void;
  46885. /**
  46886. * Registers a function to be called before every frame render
  46887. * @param func defines the function to register
  46888. */
  46889. registerBeforeRender(func: () => void): void;
  46890. /**
  46891. * Unregisters a function called before every frame render
  46892. * @param func defines the function to unregister
  46893. */
  46894. unregisterBeforeRender(func: () => void): void;
  46895. /**
  46896. * Registers a function to be called after every frame render
  46897. * @param func defines the function to register
  46898. */
  46899. registerAfterRender(func: () => void): void;
  46900. /**
  46901. * Unregisters a function called after every frame render
  46902. * @param func defines the function to unregister
  46903. */
  46904. unregisterAfterRender(func: () => void): void;
  46905. private _executeOnceBeforeRender;
  46906. /**
  46907. * The provided function will run before render once and will be disposed afterwards.
  46908. * A timeout delay can be provided so that the function will be executed in N ms.
  46909. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46910. * @param func The function to be executed.
  46911. * @param timeout optional delay in ms
  46912. */
  46913. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46914. /** @hidden */
  46915. _addPendingData(data: any): void;
  46916. /** @hidden */
  46917. _removePendingData(data: any): void;
  46918. /**
  46919. * Returns the number of items waiting to be loaded
  46920. * @returns the number of items waiting to be loaded
  46921. */
  46922. getWaitingItemsCount(): number;
  46923. /**
  46924. * Returns a boolean indicating if the scene is still loading data
  46925. */
  46926. get isLoading(): boolean;
  46927. /**
  46928. * Registers a function to be executed when the scene is ready
  46929. * @param {Function} func - the function to be executed
  46930. */
  46931. executeWhenReady(func: () => void): void;
  46932. /**
  46933. * Returns a promise that resolves when the scene is ready
  46934. * @returns A promise that resolves when the scene is ready
  46935. */
  46936. whenReadyAsync(): Promise<void>;
  46937. /** @hidden */
  46938. _checkIsReady(): void;
  46939. /**
  46940. * Gets all animatable attached to the scene
  46941. */
  46942. get animatables(): Animatable[];
  46943. /**
  46944. * Resets the last animation time frame.
  46945. * Useful to override when animations start running when loading a scene for the first time.
  46946. */
  46947. resetLastAnimationTimeFrame(): void;
  46948. /**
  46949. * Gets the current view matrix
  46950. * @returns a Matrix
  46951. */
  46952. getViewMatrix(): Matrix;
  46953. /**
  46954. * Gets the current projection matrix
  46955. * @returns a Matrix
  46956. */
  46957. getProjectionMatrix(): Matrix;
  46958. /**
  46959. * Gets the current transform matrix
  46960. * @returns a Matrix made of View * Projection
  46961. */
  46962. getTransformMatrix(): Matrix;
  46963. /**
  46964. * Sets the current transform matrix
  46965. * @param viewL defines the View matrix to use
  46966. * @param projectionL defines the Projection matrix to use
  46967. * @param viewR defines the right View matrix to use (if provided)
  46968. * @param projectionR defines the right Projection matrix to use (if provided)
  46969. */
  46970. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46971. /**
  46972. * Gets the uniform buffer used to store scene data
  46973. * @returns a UniformBuffer
  46974. */
  46975. getSceneUniformBuffer(): UniformBuffer;
  46976. /**
  46977. * Gets an unique (relatively to the current scene) Id
  46978. * @returns an unique number for the scene
  46979. */
  46980. getUniqueId(): number;
  46981. /**
  46982. * Add a mesh to the list of scene's meshes
  46983. * @param newMesh defines the mesh to add
  46984. * @param recursive if all child meshes should also be added to the scene
  46985. */
  46986. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46987. /**
  46988. * Remove a mesh for the list of scene's meshes
  46989. * @param toRemove defines the mesh to remove
  46990. * @param recursive if all child meshes should also be removed from the scene
  46991. * @returns the index where the mesh was in the mesh list
  46992. */
  46993. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46994. /**
  46995. * Add a transform node to the list of scene's transform nodes
  46996. * @param newTransformNode defines the transform node to add
  46997. */
  46998. addTransformNode(newTransformNode: TransformNode): void;
  46999. /**
  47000. * Remove a transform node for the list of scene's transform nodes
  47001. * @param toRemove defines the transform node to remove
  47002. * @returns the index where the transform node was in the transform node list
  47003. */
  47004. removeTransformNode(toRemove: TransformNode): number;
  47005. /**
  47006. * Remove a skeleton for the list of scene's skeletons
  47007. * @param toRemove defines the skeleton to remove
  47008. * @returns the index where the skeleton was in the skeleton list
  47009. */
  47010. removeSkeleton(toRemove: Skeleton): number;
  47011. /**
  47012. * Remove a morph target for the list of scene's morph targets
  47013. * @param toRemove defines the morph target to remove
  47014. * @returns the index where the morph target was in the morph target list
  47015. */
  47016. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47017. /**
  47018. * Remove a light for the list of scene's lights
  47019. * @param toRemove defines the light to remove
  47020. * @returns the index where the light was in the light list
  47021. */
  47022. removeLight(toRemove: Light): number;
  47023. /**
  47024. * Remove a camera for the list of scene's cameras
  47025. * @param toRemove defines the camera to remove
  47026. * @returns the index where the camera was in the camera list
  47027. */
  47028. removeCamera(toRemove: Camera): number;
  47029. /**
  47030. * Remove a particle system for the list of scene's particle systems
  47031. * @param toRemove defines the particle system to remove
  47032. * @returns the index where the particle system was in the particle system list
  47033. */
  47034. removeParticleSystem(toRemove: IParticleSystem): number;
  47035. /**
  47036. * Remove a animation for the list of scene's animations
  47037. * @param toRemove defines the animation to remove
  47038. * @returns the index where the animation was in the animation list
  47039. */
  47040. removeAnimation(toRemove: Animation): number;
  47041. /**
  47042. * Will stop the animation of the given target
  47043. * @param target - the target
  47044. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47045. * @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)
  47046. */
  47047. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47048. /**
  47049. * Removes the given animation group from this scene.
  47050. * @param toRemove The animation group to remove
  47051. * @returns The index of the removed animation group
  47052. */
  47053. removeAnimationGroup(toRemove: AnimationGroup): number;
  47054. /**
  47055. * Removes the given multi-material from this scene.
  47056. * @param toRemove The multi-material to remove
  47057. * @returns The index of the removed multi-material
  47058. */
  47059. removeMultiMaterial(toRemove: MultiMaterial): number;
  47060. /**
  47061. * Removes the given material from this scene.
  47062. * @param toRemove The material to remove
  47063. * @returns The index of the removed material
  47064. */
  47065. removeMaterial(toRemove: Material): number;
  47066. /**
  47067. * Removes the given action manager from this scene.
  47068. * @param toRemove The action manager to remove
  47069. * @returns The index of the removed action manager
  47070. */
  47071. removeActionManager(toRemove: AbstractActionManager): number;
  47072. /**
  47073. * Removes the given texture from this scene.
  47074. * @param toRemove The texture to remove
  47075. * @returns The index of the removed texture
  47076. */
  47077. removeTexture(toRemove: BaseTexture): number;
  47078. /**
  47079. * Adds the given light to this scene
  47080. * @param newLight The light to add
  47081. */
  47082. addLight(newLight: Light): void;
  47083. /**
  47084. * Sorts the list list based on light priorities
  47085. */
  47086. sortLightsByPriority(): void;
  47087. /**
  47088. * Adds the given camera to this scene
  47089. * @param newCamera The camera to add
  47090. */
  47091. addCamera(newCamera: Camera): void;
  47092. /**
  47093. * Adds the given skeleton to this scene
  47094. * @param newSkeleton The skeleton to add
  47095. */
  47096. addSkeleton(newSkeleton: Skeleton): void;
  47097. /**
  47098. * Adds the given particle system to this scene
  47099. * @param newParticleSystem The particle system to add
  47100. */
  47101. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47102. /**
  47103. * Adds the given animation to this scene
  47104. * @param newAnimation The animation to add
  47105. */
  47106. addAnimation(newAnimation: Animation): void;
  47107. /**
  47108. * Adds the given animation group to this scene.
  47109. * @param newAnimationGroup The animation group to add
  47110. */
  47111. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47112. /**
  47113. * Adds the given multi-material to this scene
  47114. * @param newMultiMaterial The multi-material to add
  47115. */
  47116. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47117. /**
  47118. * Adds the given material to this scene
  47119. * @param newMaterial The material to add
  47120. */
  47121. addMaterial(newMaterial: Material): void;
  47122. /**
  47123. * Adds the given morph target to this scene
  47124. * @param newMorphTargetManager The morph target to add
  47125. */
  47126. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47127. /**
  47128. * Adds the given geometry to this scene
  47129. * @param newGeometry The geometry to add
  47130. */
  47131. addGeometry(newGeometry: Geometry): void;
  47132. /**
  47133. * Adds the given action manager to this scene
  47134. * @param newActionManager The action manager to add
  47135. */
  47136. addActionManager(newActionManager: AbstractActionManager): void;
  47137. /**
  47138. * Adds the given texture to this scene.
  47139. * @param newTexture The texture to add
  47140. */
  47141. addTexture(newTexture: BaseTexture): void;
  47142. /**
  47143. * Switch active camera
  47144. * @param newCamera defines the new active camera
  47145. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47146. */
  47147. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47148. /**
  47149. * sets the active camera of the scene using its ID
  47150. * @param id defines the camera's ID
  47151. * @return the new active camera or null if none found.
  47152. */
  47153. setActiveCameraByID(id: string): Nullable<Camera>;
  47154. /**
  47155. * sets the active camera of the scene using its name
  47156. * @param name defines the camera's name
  47157. * @returns the new active camera or null if none found.
  47158. */
  47159. setActiveCameraByName(name: string): Nullable<Camera>;
  47160. /**
  47161. * get an animation group using its name
  47162. * @param name defines the material's name
  47163. * @return the animation group or null if none found.
  47164. */
  47165. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47166. /**
  47167. * Get a material using its unique id
  47168. * @param uniqueId defines the material's unique id
  47169. * @return the material or null if none found.
  47170. */
  47171. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47172. /**
  47173. * get a material using its id
  47174. * @param id defines the material's ID
  47175. * @return the material or null if none found.
  47176. */
  47177. getMaterialByID(id: string): Nullable<Material>;
  47178. /**
  47179. * Gets a the last added material using a given id
  47180. * @param id defines the material's ID
  47181. * @return the last material with the given id or null if none found.
  47182. */
  47183. getLastMaterialByID(id: string): Nullable<Material>;
  47184. /**
  47185. * Gets a material using its name
  47186. * @param name defines the material's name
  47187. * @return the material or null if none found.
  47188. */
  47189. getMaterialByName(name: string): Nullable<Material>;
  47190. /**
  47191. * Get a texture using its unique id
  47192. * @param uniqueId defines the texture's unique id
  47193. * @return the texture or null if none found.
  47194. */
  47195. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47196. /**
  47197. * Gets a camera using its id
  47198. * @param id defines the id to look for
  47199. * @returns the camera or null if not found
  47200. */
  47201. getCameraByID(id: string): Nullable<Camera>;
  47202. /**
  47203. * Gets a camera using its unique id
  47204. * @param uniqueId defines the unique id to look for
  47205. * @returns the camera or null if not found
  47206. */
  47207. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47208. /**
  47209. * Gets a camera using its name
  47210. * @param name defines the camera's name
  47211. * @return the camera or null if none found.
  47212. */
  47213. getCameraByName(name: string): Nullable<Camera>;
  47214. /**
  47215. * Gets a bone using its id
  47216. * @param id defines the bone's id
  47217. * @return the bone or null if not found
  47218. */
  47219. getBoneByID(id: string): Nullable<Bone>;
  47220. /**
  47221. * Gets a bone using its id
  47222. * @param name defines the bone's name
  47223. * @return the bone or null if not found
  47224. */
  47225. getBoneByName(name: string): Nullable<Bone>;
  47226. /**
  47227. * Gets a light node using its name
  47228. * @param name defines the the light's name
  47229. * @return the light or null if none found.
  47230. */
  47231. getLightByName(name: string): Nullable<Light>;
  47232. /**
  47233. * Gets a light node using its id
  47234. * @param id defines the light's id
  47235. * @return the light or null if none found.
  47236. */
  47237. getLightByID(id: string): Nullable<Light>;
  47238. /**
  47239. * Gets a light node using its scene-generated unique ID
  47240. * @param uniqueId defines the light's unique id
  47241. * @return the light or null if none found.
  47242. */
  47243. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47244. /**
  47245. * Gets a particle system by id
  47246. * @param id defines the particle system id
  47247. * @return the corresponding system or null if none found
  47248. */
  47249. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47250. /**
  47251. * Gets a geometry using its ID
  47252. * @param id defines the geometry's id
  47253. * @return the geometry or null if none found.
  47254. */
  47255. getGeometryByID(id: string): Nullable<Geometry>;
  47256. private _getGeometryByUniqueID;
  47257. /**
  47258. * Add a new geometry to this scene
  47259. * @param geometry defines the geometry to be added to the scene.
  47260. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47261. * @return a boolean defining if the geometry was added or not
  47262. */
  47263. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47264. /**
  47265. * Removes an existing geometry
  47266. * @param geometry defines the geometry to be removed from the scene
  47267. * @return a boolean defining if the geometry was removed or not
  47268. */
  47269. removeGeometry(geometry: Geometry): boolean;
  47270. /**
  47271. * Gets the list of geometries attached to the scene
  47272. * @returns an array of Geometry
  47273. */
  47274. getGeometries(): Geometry[];
  47275. /**
  47276. * Gets the first added mesh found of a given ID
  47277. * @param id defines the id to search for
  47278. * @return the mesh found or null if not found at all
  47279. */
  47280. getMeshByID(id: string): Nullable<AbstractMesh>;
  47281. /**
  47282. * Gets a list of meshes using their id
  47283. * @param id defines the id to search for
  47284. * @returns a list of meshes
  47285. */
  47286. getMeshesByID(id: string): Array<AbstractMesh>;
  47287. /**
  47288. * Gets the first added transform node found of a given ID
  47289. * @param id defines the id to search for
  47290. * @return the found transform node or null if not found at all.
  47291. */
  47292. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47293. /**
  47294. * Gets a transform node with its auto-generated unique id
  47295. * @param uniqueId efines the unique id to search for
  47296. * @return the found transform node or null if not found at all.
  47297. */
  47298. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47299. /**
  47300. * Gets a list of transform nodes using their id
  47301. * @param id defines the id to search for
  47302. * @returns a list of transform nodes
  47303. */
  47304. getTransformNodesByID(id: string): Array<TransformNode>;
  47305. /**
  47306. * Gets a mesh with its auto-generated unique id
  47307. * @param uniqueId defines the unique id to search for
  47308. * @return the found mesh or null if not found at all.
  47309. */
  47310. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47311. /**
  47312. * Gets a the last added mesh using a given id
  47313. * @param id defines the id to search for
  47314. * @return the found mesh or null if not found at all.
  47315. */
  47316. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47317. /**
  47318. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47319. * @param id defines the id to search for
  47320. * @return the found node or null if not found at all
  47321. */
  47322. getLastEntryByID(id: string): Nullable<Node>;
  47323. /**
  47324. * Gets a node (Mesh, Camera, Light) using a given id
  47325. * @param id defines the id to search for
  47326. * @return the found node or null if not found at all
  47327. */
  47328. getNodeByID(id: string): Nullable<Node>;
  47329. /**
  47330. * Gets a node (Mesh, Camera, Light) using a given name
  47331. * @param name defines the name to search for
  47332. * @return the found node or null if not found at all.
  47333. */
  47334. getNodeByName(name: string): Nullable<Node>;
  47335. /**
  47336. * Gets a mesh using a given name
  47337. * @param name defines the name to search for
  47338. * @return the found mesh or null if not found at all.
  47339. */
  47340. getMeshByName(name: string): Nullable<AbstractMesh>;
  47341. /**
  47342. * Gets a transform node using a given name
  47343. * @param name defines the name to search for
  47344. * @return the found transform node or null if not found at all.
  47345. */
  47346. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47347. /**
  47348. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47349. * @param id defines the id to search for
  47350. * @return the found skeleton or null if not found at all.
  47351. */
  47352. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47353. /**
  47354. * Gets a skeleton using a given auto generated unique id
  47355. * @param uniqueId defines the unique id to search for
  47356. * @return the found skeleton or null if not found at all.
  47357. */
  47358. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47359. /**
  47360. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47361. * @param id defines the id to search for
  47362. * @return the found skeleton or null if not found at all.
  47363. */
  47364. getSkeletonById(id: string): Nullable<Skeleton>;
  47365. /**
  47366. * Gets a skeleton using a given name
  47367. * @param name defines the name to search for
  47368. * @return the found skeleton or null if not found at all.
  47369. */
  47370. getSkeletonByName(name: string): Nullable<Skeleton>;
  47371. /**
  47372. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47373. * @param id defines the id to search for
  47374. * @return the found morph target manager or null if not found at all.
  47375. */
  47376. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47377. /**
  47378. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47379. * @param id defines the id to search for
  47380. * @return the found morph target or null if not found at all.
  47381. */
  47382. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47383. /**
  47384. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47385. * @param name defines the name to search for
  47386. * @return the found morph target or null if not found at all.
  47387. */
  47388. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47389. /**
  47390. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47391. * @param name defines the name to search for
  47392. * @return the found post process or null if not found at all.
  47393. */
  47394. getPostProcessByName(name: string): Nullable<PostProcess>;
  47395. /**
  47396. * Gets a boolean indicating if the given mesh is active
  47397. * @param mesh defines the mesh to look for
  47398. * @returns true if the mesh is in the active list
  47399. */
  47400. isActiveMesh(mesh: AbstractMesh): boolean;
  47401. /**
  47402. * Return a unique id as a string which can serve as an identifier for the scene
  47403. */
  47404. get uid(): string;
  47405. /**
  47406. * Add an externaly attached data from its key.
  47407. * This method call will fail and return false, if such key already exists.
  47408. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47409. * @param key the unique key that identifies the data
  47410. * @param data the data object to associate to the key for this Engine instance
  47411. * @return true if no such key were already present and the data was added successfully, false otherwise
  47412. */
  47413. addExternalData<T>(key: string, data: T): boolean;
  47414. /**
  47415. * Get an externaly attached data from its key
  47416. * @param key the unique key that identifies the data
  47417. * @return the associated data, if present (can be null), or undefined if not present
  47418. */
  47419. getExternalData<T>(key: string): Nullable<T>;
  47420. /**
  47421. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47422. * @param key the unique key that identifies the data
  47423. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47424. * @return the associated data, can be null if the factory returned null.
  47425. */
  47426. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47427. /**
  47428. * Remove an externaly attached data from the Engine instance
  47429. * @param key the unique key that identifies the data
  47430. * @return true if the data was successfully removed, false if it doesn't exist
  47431. */
  47432. removeExternalData(key: string): boolean;
  47433. private _evaluateSubMesh;
  47434. /**
  47435. * Clear the processed materials smart array preventing retention point in material dispose.
  47436. */
  47437. freeProcessedMaterials(): void;
  47438. private _preventFreeActiveMeshesAndRenderingGroups;
  47439. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47440. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47441. * when disposing several meshes in a row or a hierarchy of meshes.
  47442. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47443. */
  47444. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47445. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47446. /**
  47447. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47448. */
  47449. freeActiveMeshes(): void;
  47450. /**
  47451. * Clear the info related to rendering groups preventing retention points during dispose.
  47452. */
  47453. freeRenderingGroups(): void;
  47454. /** @hidden */
  47455. _isInIntermediateRendering(): boolean;
  47456. /**
  47457. * Lambda returning the list of potentially active meshes.
  47458. */
  47459. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47460. /**
  47461. * Lambda returning the list of potentially active sub meshes.
  47462. */
  47463. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47464. /**
  47465. * Lambda returning the list of potentially intersecting sub meshes.
  47466. */
  47467. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47468. /**
  47469. * Lambda returning the list of potentially colliding sub meshes.
  47470. */
  47471. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47472. /** @hidden */
  47473. _activeMeshesFrozen: boolean;
  47474. private _skipEvaluateActiveMeshesCompletely;
  47475. /**
  47476. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47477. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47478. * @param onSuccess optional success callback
  47479. * @param onError optional error callback
  47480. * @returns the current scene
  47481. */
  47482. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47483. /**
  47484. * Use this function to restart evaluating active meshes on every frame
  47485. * @returns the current scene
  47486. */
  47487. unfreezeActiveMeshes(): Scene;
  47488. private _evaluateActiveMeshes;
  47489. private _activeMesh;
  47490. /**
  47491. * Update the transform matrix to update from the current active camera
  47492. * @param force defines a boolean used to force the update even if cache is up to date
  47493. */
  47494. updateTransformMatrix(force?: boolean): void;
  47495. private _bindFrameBuffer;
  47496. /** @hidden */
  47497. _allowPostProcessClearColor: boolean;
  47498. /** @hidden */
  47499. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47500. private _processSubCameras;
  47501. private _checkIntersections;
  47502. /** @hidden */
  47503. _advancePhysicsEngineStep(step: number): void;
  47504. /**
  47505. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47506. */
  47507. getDeterministicFrameTime: () => number;
  47508. /** @hidden */
  47509. _animate(): void;
  47510. /** Execute all animations (for a frame) */
  47511. animate(): void;
  47512. /**
  47513. * Render the scene
  47514. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47515. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47516. */
  47517. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47518. /**
  47519. * Freeze all materials
  47520. * A frozen material will not be updatable but should be faster to render
  47521. */
  47522. freezeMaterials(): void;
  47523. /**
  47524. * Unfreeze all materials
  47525. * A frozen material will not be updatable but should be faster to render
  47526. */
  47527. unfreezeMaterials(): void;
  47528. /**
  47529. * Releases all held ressources
  47530. */
  47531. dispose(): void;
  47532. /**
  47533. * Gets if the scene is already disposed
  47534. */
  47535. get isDisposed(): boolean;
  47536. /**
  47537. * Call this function to reduce memory footprint of the scene.
  47538. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47539. */
  47540. clearCachedVertexData(): void;
  47541. /**
  47542. * This function will remove the local cached buffer data from texture.
  47543. * It will save memory but will prevent the texture from being rebuilt
  47544. */
  47545. cleanCachedTextureBuffer(): void;
  47546. /**
  47547. * Get the world extend vectors with an optional filter
  47548. *
  47549. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47550. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47551. */
  47552. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47553. min: Vector3;
  47554. max: Vector3;
  47555. };
  47556. /**
  47557. * Creates a ray that can be used to pick in the scene
  47558. * @param x defines the x coordinate of the origin (on-screen)
  47559. * @param y defines the y coordinate of the origin (on-screen)
  47560. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47561. * @param camera defines the camera to use for the picking
  47562. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47563. * @returns a Ray
  47564. */
  47565. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47566. /**
  47567. * Creates a ray that can be used to pick in the scene
  47568. * @param x defines the x coordinate of the origin (on-screen)
  47569. * @param y defines the y coordinate of the origin (on-screen)
  47570. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47571. * @param result defines the ray where to store the picking ray
  47572. * @param camera defines the camera to use for the picking
  47573. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47574. * @returns the current scene
  47575. */
  47576. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47577. /**
  47578. * Creates a ray that can be used to pick in the scene
  47579. * @param x defines the x coordinate of the origin (on-screen)
  47580. * @param y defines the y coordinate of the origin (on-screen)
  47581. * @param camera defines the camera to use for the picking
  47582. * @returns a Ray
  47583. */
  47584. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47585. /**
  47586. * Creates a ray that can be used to pick in the scene
  47587. * @param x defines the x coordinate of the origin (on-screen)
  47588. * @param y defines the y coordinate of the origin (on-screen)
  47589. * @param result defines the ray where to store the picking ray
  47590. * @param camera defines the camera to use for the picking
  47591. * @returns the current scene
  47592. */
  47593. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47594. /** Launch a ray to try to pick a mesh in the scene
  47595. * @param x position on screen
  47596. * @param y position on screen
  47597. * @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
  47598. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47599. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47600. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47601. * @returns a PickingInfo
  47602. */
  47603. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47604. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47605. * @param x position on screen
  47606. * @param y position on screen
  47607. * @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
  47608. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47609. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47610. * @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)
  47611. */
  47612. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47613. /** Use the given ray to pick a mesh in the scene
  47614. * @param ray The ray to use to pick meshes
  47615. * @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
  47616. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47618. * @returns a PickingInfo
  47619. */
  47620. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47621. /**
  47622. * Launch a ray to try to pick a mesh in the scene
  47623. * @param x X position on screen
  47624. * @param y Y position on screen
  47625. * @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
  47626. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47627. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47628. * @returns an array of PickingInfo
  47629. */
  47630. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47631. /**
  47632. * Launch a ray to try to pick a mesh in the scene
  47633. * @param ray Ray to use
  47634. * @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
  47635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47636. * @returns an array of PickingInfo
  47637. */
  47638. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47639. /**
  47640. * Force the value of meshUnderPointer
  47641. * @param mesh defines the mesh to use
  47642. * @param pointerId optional pointer id when using more than one pointer
  47643. */
  47644. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47645. /**
  47646. * Gets the mesh under the pointer
  47647. * @returns a Mesh or null if no mesh is under the pointer
  47648. */
  47649. getPointerOverMesh(): Nullable<AbstractMesh>;
  47650. /** @hidden */
  47651. _rebuildGeometries(): void;
  47652. /** @hidden */
  47653. _rebuildTextures(): void;
  47654. private _getByTags;
  47655. /**
  47656. * Get a list of meshes by tags
  47657. * @param tagsQuery defines the tags query to use
  47658. * @param forEach defines a predicate used to filter results
  47659. * @returns an array of Mesh
  47660. */
  47661. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47662. /**
  47663. * Get a list of cameras by tags
  47664. * @param tagsQuery defines the tags query to use
  47665. * @param forEach defines a predicate used to filter results
  47666. * @returns an array of Camera
  47667. */
  47668. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47669. /**
  47670. * Get a list of lights by tags
  47671. * @param tagsQuery defines the tags query to use
  47672. * @param forEach defines a predicate used to filter results
  47673. * @returns an array of Light
  47674. */
  47675. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47676. /**
  47677. * Get a list of materials by tags
  47678. * @param tagsQuery defines the tags query to use
  47679. * @param forEach defines a predicate used to filter results
  47680. * @returns an array of Material
  47681. */
  47682. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47683. /**
  47684. * Get a list of transform nodes by tags
  47685. * @param tagsQuery defines the tags query to use
  47686. * @param forEach defines a predicate used to filter results
  47687. * @returns an array of TransformNode
  47688. */
  47689. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47690. /**
  47691. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47692. * This allowed control for front to back rendering or reversly depending of the special needs.
  47693. *
  47694. * @param renderingGroupId The rendering group id corresponding to its index
  47695. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47696. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47697. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47698. */
  47699. 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;
  47700. /**
  47701. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47702. *
  47703. * @param renderingGroupId The rendering group id corresponding to its index
  47704. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47705. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47706. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47707. */
  47708. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47709. /**
  47710. * Gets the current auto clear configuration for one rendering group of the rendering
  47711. * manager.
  47712. * @param index the rendering group index to get the information for
  47713. * @returns The auto clear setup for the requested rendering group
  47714. */
  47715. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47716. private _blockMaterialDirtyMechanism;
  47717. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47718. get blockMaterialDirtyMechanism(): boolean;
  47719. set blockMaterialDirtyMechanism(value: boolean);
  47720. /**
  47721. * Will flag all materials as dirty to trigger new shader compilation
  47722. * @param flag defines the flag used to specify which material part must be marked as dirty
  47723. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47724. */
  47725. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47726. /** @hidden */
  47727. _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;
  47728. /** @hidden */
  47729. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47730. /** @hidden */
  47731. _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;
  47732. /** @hidden */
  47733. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47734. /** @hidden */
  47735. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47736. /** @hidden */
  47737. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47738. }
  47739. }
  47740. declare module BABYLON {
  47741. /**
  47742. * Set of assets to keep when moving a scene into an asset container.
  47743. */
  47744. export class KeepAssets extends AbstractScene {
  47745. }
  47746. /**
  47747. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47748. */
  47749. export class InstantiatedEntries {
  47750. /**
  47751. * List of new root nodes (eg. nodes with no parent)
  47752. */
  47753. rootNodes: TransformNode[];
  47754. /**
  47755. * List of new skeletons
  47756. */
  47757. skeletons: Skeleton[];
  47758. /**
  47759. * List of new animation groups
  47760. */
  47761. animationGroups: AnimationGroup[];
  47762. }
  47763. /**
  47764. * Container with a set of assets that can be added or removed from a scene.
  47765. */
  47766. export class AssetContainer extends AbstractScene {
  47767. private _wasAddedToScene;
  47768. /**
  47769. * The scene the AssetContainer belongs to.
  47770. */
  47771. scene: Scene;
  47772. /**
  47773. * Instantiates an AssetContainer.
  47774. * @param scene The scene the AssetContainer belongs to.
  47775. */
  47776. constructor(scene: Scene);
  47777. /**
  47778. * Instantiate or clone all meshes and add the new ones to the scene.
  47779. * Skeletons and animation groups will all be cloned
  47780. * @param nameFunction defines an optional function used to get new names for clones
  47781. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47782. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47783. */
  47784. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47785. /**
  47786. * Adds all the assets from the container to the scene.
  47787. */
  47788. addAllToScene(): void;
  47789. /**
  47790. * Removes all the assets in the container from the scene
  47791. */
  47792. removeAllFromScene(): void;
  47793. /**
  47794. * Disposes all the assets in the container
  47795. */
  47796. dispose(): void;
  47797. private _moveAssets;
  47798. /**
  47799. * Removes all the assets contained in the scene and adds them to the container.
  47800. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47801. */
  47802. moveAllFromScene(keepAssets?: KeepAssets): void;
  47803. /**
  47804. * 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.
  47805. * @returns the root mesh
  47806. */
  47807. createRootMesh(): Mesh;
  47808. /**
  47809. * Merge animations (direct and animation groups) from this asset container into a scene
  47810. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47811. * @param animatables set of animatables to retarget to a node from the scene
  47812. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47813. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47814. */
  47815. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47816. }
  47817. }
  47818. declare module BABYLON {
  47819. /**
  47820. * Defines how the parser contract is defined.
  47821. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47822. */
  47823. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47824. /**
  47825. * Defines how the individual parser contract is defined.
  47826. * These parser can parse an individual asset
  47827. */
  47828. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47829. /**
  47830. * Base class of the scene acting as a container for the different elements composing a scene.
  47831. * This class is dynamically extended by the different components of the scene increasing
  47832. * flexibility and reducing coupling
  47833. */
  47834. export abstract class AbstractScene {
  47835. /**
  47836. * Stores the list of available parsers in the application.
  47837. */
  47838. private static _BabylonFileParsers;
  47839. /**
  47840. * Stores the list of available individual parsers in the application.
  47841. */
  47842. private static _IndividualBabylonFileParsers;
  47843. /**
  47844. * Adds a parser in the list of available ones
  47845. * @param name Defines the name of the parser
  47846. * @param parser Defines the parser to add
  47847. */
  47848. static AddParser(name: string, parser: BabylonFileParser): void;
  47849. /**
  47850. * Gets a general parser from the list of avaialble ones
  47851. * @param name Defines the name of the parser
  47852. * @returns the requested parser or null
  47853. */
  47854. static GetParser(name: string): Nullable<BabylonFileParser>;
  47855. /**
  47856. * Adds n individual parser in the list of available ones
  47857. * @param name Defines the name of the parser
  47858. * @param parser Defines the parser to add
  47859. */
  47860. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47861. /**
  47862. * Gets an individual parser from the list of avaialble ones
  47863. * @param name Defines the name of the parser
  47864. * @returns the requested parser or null
  47865. */
  47866. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47867. /**
  47868. * Parser json data and populate both a scene and its associated container object
  47869. * @param jsonData Defines the data to parse
  47870. * @param scene Defines the scene to parse the data for
  47871. * @param container Defines the container attached to the parsing sequence
  47872. * @param rootUrl Defines the root url of the data
  47873. */
  47874. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47875. /**
  47876. * Gets the list of root nodes (ie. nodes with no parent)
  47877. */
  47878. rootNodes: Node[];
  47879. /** All of the cameras added to this scene
  47880. * @see https://doc.babylonjs.com/babylon101/cameras
  47881. */
  47882. cameras: Camera[];
  47883. /**
  47884. * All of the lights added to this scene
  47885. * @see https://doc.babylonjs.com/babylon101/lights
  47886. */
  47887. lights: Light[];
  47888. /**
  47889. * All of the (abstract) meshes added to this scene
  47890. */
  47891. meshes: AbstractMesh[];
  47892. /**
  47893. * The list of skeletons added to the scene
  47894. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47895. */
  47896. skeletons: Skeleton[];
  47897. /**
  47898. * All of the particle systems added to this scene
  47899. * @see https://doc.babylonjs.com/babylon101/particles
  47900. */
  47901. particleSystems: IParticleSystem[];
  47902. /**
  47903. * Gets a list of Animations associated with the scene
  47904. */
  47905. animations: Animation[];
  47906. /**
  47907. * All of the animation groups added to this scene
  47908. * @see https://doc.babylonjs.com/how_to/group
  47909. */
  47910. animationGroups: AnimationGroup[];
  47911. /**
  47912. * All of the multi-materials added to this scene
  47913. * @see https://doc.babylonjs.com/how_to/multi_materials
  47914. */
  47915. multiMaterials: MultiMaterial[];
  47916. /**
  47917. * All of the materials added to this scene
  47918. * In the context of a Scene, it is not supposed to be modified manually.
  47919. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47920. * Note also that the order of the Material within the array is not significant and might change.
  47921. * @see https://doc.babylonjs.com/babylon101/materials
  47922. */
  47923. materials: Material[];
  47924. /**
  47925. * The list of morph target managers added to the scene
  47926. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47927. */
  47928. morphTargetManagers: MorphTargetManager[];
  47929. /**
  47930. * The list of geometries used in the scene.
  47931. */
  47932. geometries: Geometry[];
  47933. /**
  47934. * All of the tranform nodes added to this scene
  47935. * In the context of a Scene, it is not supposed to be modified manually.
  47936. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47937. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47938. * @see https://doc.babylonjs.com/how_to/transformnode
  47939. */
  47940. transformNodes: TransformNode[];
  47941. /**
  47942. * ActionManagers available on the scene.
  47943. */
  47944. actionManagers: AbstractActionManager[];
  47945. /**
  47946. * Textures to keep.
  47947. */
  47948. textures: BaseTexture[];
  47949. /** @hidden */
  47950. protected _environmentTexture: Nullable<BaseTexture>;
  47951. /**
  47952. * Texture used in all pbr material as the reflection texture.
  47953. * As in the majority of the scene they are the same (exception for multi room and so on),
  47954. * this is easier to reference from here than from all the materials.
  47955. */
  47956. get environmentTexture(): Nullable<BaseTexture>;
  47957. set environmentTexture(value: Nullable<BaseTexture>);
  47958. /**
  47959. * The list of postprocesses added to the scene
  47960. */
  47961. postProcesses: PostProcess[];
  47962. /**
  47963. * @returns all meshes, lights, cameras, transformNodes and bones
  47964. */
  47965. getNodes(): Array<Node>;
  47966. }
  47967. }
  47968. declare module BABYLON {
  47969. /**
  47970. * Interface used to define options for Sound class
  47971. */
  47972. export interface ISoundOptions {
  47973. /**
  47974. * Does the sound autoplay once loaded.
  47975. */
  47976. autoplay?: boolean;
  47977. /**
  47978. * Does the sound loop after it finishes playing once.
  47979. */
  47980. loop?: boolean;
  47981. /**
  47982. * Sound's volume
  47983. */
  47984. volume?: number;
  47985. /**
  47986. * Is it a spatial sound?
  47987. */
  47988. spatialSound?: boolean;
  47989. /**
  47990. * Maximum distance to hear that sound
  47991. */
  47992. maxDistance?: number;
  47993. /**
  47994. * Uses user defined attenuation function
  47995. */
  47996. useCustomAttenuation?: boolean;
  47997. /**
  47998. * Define the roll off factor of spatial sounds.
  47999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48000. */
  48001. rolloffFactor?: number;
  48002. /**
  48003. * Define the reference distance the sound should be heard perfectly.
  48004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48005. */
  48006. refDistance?: number;
  48007. /**
  48008. * Define the distance attenuation model the sound will follow.
  48009. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48010. */
  48011. distanceModel?: string;
  48012. /**
  48013. * Defines the playback speed (1 by default)
  48014. */
  48015. playbackRate?: number;
  48016. /**
  48017. * Defines if the sound is from a streaming source
  48018. */
  48019. streaming?: boolean;
  48020. /**
  48021. * Defines an optional length (in seconds) inside the sound file
  48022. */
  48023. length?: number;
  48024. /**
  48025. * Defines an optional offset (in seconds) inside the sound file
  48026. */
  48027. offset?: number;
  48028. /**
  48029. * If true, URLs will not be required to state the audio file codec to use.
  48030. */
  48031. skipCodecCheck?: boolean;
  48032. }
  48033. }
  48034. declare module BABYLON {
  48035. /**
  48036. * Defines a sound that can be played in the application.
  48037. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48039. */
  48040. export class Sound {
  48041. /**
  48042. * The name of the sound in the scene.
  48043. */
  48044. name: string;
  48045. /**
  48046. * Does the sound autoplay once loaded.
  48047. */
  48048. autoplay: boolean;
  48049. private _loop;
  48050. /**
  48051. * Does the sound loop after it finishes playing once.
  48052. */
  48053. get loop(): boolean;
  48054. set loop(value: boolean);
  48055. /**
  48056. * Does the sound use a custom attenuation curve to simulate the falloff
  48057. * happening when the source gets further away from the camera.
  48058. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48059. */
  48060. useCustomAttenuation: boolean;
  48061. /**
  48062. * The sound track id this sound belongs to.
  48063. */
  48064. soundTrackId: number;
  48065. /**
  48066. * Is this sound currently played.
  48067. */
  48068. isPlaying: boolean;
  48069. /**
  48070. * Is this sound currently paused.
  48071. */
  48072. isPaused: boolean;
  48073. /**
  48074. * Does this sound enables spatial sound.
  48075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48076. */
  48077. spatialSound: boolean;
  48078. /**
  48079. * Define the reference distance the sound should be heard perfectly.
  48080. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48081. */
  48082. refDistance: number;
  48083. /**
  48084. * Define the roll off factor of spatial sounds.
  48085. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48086. */
  48087. rolloffFactor: number;
  48088. /**
  48089. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48090. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48091. */
  48092. maxDistance: number;
  48093. /**
  48094. * Define the distance attenuation model the sound will follow.
  48095. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48096. */
  48097. distanceModel: string;
  48098. /**
  48099. * @hidden
  48100. * Back Compat
  48101. **/
  48102. onended: () => any;
  48103. /**
  48104. * Gets or sets an object used to store user defined information for the sound.
  48105. */
  48106. metadata: any;
  48107. /**
  48108. * Observable event when the current playing sound finishes.
  48109. */
  48110. onEndedObservable: Observable<Sound>;
  48111. /**
  48112. * Gets the current time for the sound.
  48113. */
  48114. get currentTime(): number;
  48115. private _panningModel;
  48116. private _playbackRate;
  48117. private _streaming;
  48118. private _startTime;
  48119. private _startOffset;
  48120. private _position;
  48121. /** @hidden */
  48122. _positionInEmitterSpace: boolean;
  48123. private _localDirection;
  48124. private _volume;
  48125. private _isReadyToPlay;
  48126. private _isDirectional;
  48127. private _readyToPlayCallback;
  48128. private _audioBuffer;
  48129. private _soundSource;
  48130. private _streamingSource;
  48131. private _soundPanner;
  48132. private _soundGain;
  48133. private _inputAudioNode;
  48134. private _outputAudioNode;
  48135. private _coneInnerAngle;
  48136. private _coneOuterAngle;
  48137. private _coneOuterGain;
  48138. private _scene;
  48139. private _connectedTransformNode;
  48140. private _customAttenuationFunction;
  48141. private _registerFunc;
  48142. private _isOutputConnected;
  48143. private _htmlAudioElement;
  48144. private _urlType;
  48145. private _length?;
  48146. private _offset?;
  48147. /** @hidden */
  48148. static _SceneComponentInitialization: (scene: Scene) => void;
  48149. /**
  48150. * Create a sound and attach it to a scene
  48151. * @param name Name of your sound
  48152. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48153. * @param scene defines the scene the sound belongs to
  48154. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48155. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48156. */
  48157. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48158. /**
  48159. * Release the sound and its associated resources
  48160. */
  48161. dispose(): void;
  48162. /**
  48163. * Gets if the sounds is ready to be played or not.
  48164. * @returns true if ready, otherwise false
  48165. */
  48166. isReady(): boolean;
  48167. /**
  48168. * Get the current class name.
  48169. * @returns current class name
  48170. */
  48171. getClassName(): string;
  48172. private _soundLoaded;
  48173. /**
  48174. * Sets the data of the sound from an audiobuffer
  48175. * @param audioBuffer The audioBuffer containing the data
  48176. */
  48177. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48178. /**
  48179. * Updates the current sounds options such as maxdistance, loop...
  48180. * @param options A JSON object containing values named as the object properties
  48181. */
  48182. updateOptions(options: ISoundOptions): void;
  48183. private _createSpatialParameters;
  48184. private _updateSpatialParameters;
  48185. /**
  48186. * Switch the panning model to HRTF:
  48187. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48188. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48189. */
  48190. switchPanningModelToHRTF(): void;
  48191. /**
  48192. * Switch the panning model to Equal Power:
  48193. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48194. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48195. */
  48196. switchPanningModelToEqualPower(): void;
  48197. private _switchPanningModel;
  48198. /**
  48199. * Connect this sound to a sound track audio node like gain...
  48200. * @param soundTrackAudioNode the sound track audio node to connect to
  48201. */
  48202. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48203. /**
  48204. * Transform this sound into a directional source
  48205. * @param coneInnerAngle Size of the inner cone in degree
  48206. * @param coneOuterAngle Size of the outer cone in degree
  48207. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48208. */
  48209. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48210. /**
  48211. * Gets or sets the inner angle for the directional cone.
  48212. */
  48213. get directionalConeInnerAngle(): number;
  48214. /**
  48215. * Gets or sets the inner angle for the directional cone.
  48216. */
  48217. set directionalConeInnerAngle(value: number);
  48218. /**
  48219. * Gets or sets the outer angle for the directional cone.
  48220. */
  48221. get directionalConeOuterAngle(): number;
  48222. /**
  48223. * Gets or sets the outer angle for the directional cone.
  48224. */
  48225. set directionalConeOuterAngle(value: number);
  48226. /**
  48227. * Sets the position of the emitter if spatial sound is enabled
  48228. * @param newPosition Defines the new posisiton
  48229. */
  48230. setPosition(newPosition: Vector3): void;
  48231. /**
  48232. * Sets the local direction of the emitter if spatial sound is enabled
  48233. * @param newLocalDirection Defines the new local direction
  48234. */
  48235. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48236. private _updateDirection;
  48237. /** @hidden */
  48238. updateDistanceFromListener(): void;
  48239. /**
  48240. * Sets a new custom attenuation function for the sound.
  48241. * @param callback Defines the function used for the attenuation
  48242. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48243. */
  48244. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48245. /**
  48246. * Play the sound
  48247. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48248. * @param offset (optional) Start the sound at a specific time in seconds
  48249. * @param length (optional) Sound duration (in seconds)
  48250. */
  48251. play(time?: number, offset?: number, length?: number): void;
  48252. private _onended;
  48253. /**
  48254. * Stop the sound
  48255. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48256. */
  48257. stop(time?: number): void;
  48258. /**
  48259. * Put the sound in pause
  48260. */
  48261. pause(): void;
  48262. /**
  48263. * Sets a dedicated volume for this sounds
  48264. * @param newVolume Define the new volume of the sound
  48265. * @param time Define time for gradual change to new volume
  48266. */
  48267. setVolume(newVolume: number, time?: number): void;
  48268. /**
  48269. * Set the sound play back rate
  48270. * @param newPlaybackRate Define the playback rate the sound should be played at
  48271. */
  48272. setPlaybackRate(newPlaybackRate: number): void;
  48273. /**
  48274. * Gets the volume of the sound.
  48275. * @returns the volume of the sound
  48276. */
  48277. getVolume(): number;
  48278. /**
  48279. * Attach the sound to a dedicated mesh
  48280. * @param transformNode The transform node to connect the sound with
  48281. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48282. */
  48283. attachToMesh(transformNode: TransformNode): void;
  48284. /**
  48285. * Detach the sound from the previously attached mesh
  48286. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48287. */
  48288. detachFromMesh(): void;
  48289. private _onRegisterAfterWorldMatrixUpdate;
  48290. /**
  48291. * Clone the current sound in the scene.
  48292. * @returns the new sound clone
  48293. */
  48294. clone(): Nullable<Sound>;
  48295. /**
  48296. * Gets the current underlying audio buffer containing the data
  48297. * @returns the audio buffer
  48298. */
  48299. getAudioBuffer(): Nullable<AudioBuffer>;
  48300. /**
  48301. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48302. * @returns the source node
  48303. */
  48304. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48305. /**
  48306. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48307. * @returns the gain node
  48308. */
  48309. getSoundGain(): Nullable<GainNode>;
  48310. /**
  48311. * Serializes the Sound in a JSON representation
  48312. * @returns the JSON representation of the sound
  48313. */
  48314. serialize(): any;
  48315. /**
  48316. * Parse a JSON representation of a sound to innstantiate in a given scene
  48317. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48318. * @param scene Define the scene the new parsed sound should be created in
  48319. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48320. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48321. * @returns the newly parsed sound
  48322. */
  48323. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48324. }
  48325. }
  48326. declare module BABYLON {
  48327. /**
  48328. * This defines an action helpful to play a defined sound on a triggered action.
  48329. */
  48330. export class PlaySoundAction extends Action {
  48331. private _sound;
  48332. /**
  48333. * Instantiate the action
  48334. * @param triggerOptions defines the trigger options
  48335. * @param sound defines the sound to play
  48336. * @param condition defines the trigger related conditions
  48337. */
  48338. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48339. /** @hidden */
  48340. _prepare(): void;
  48341. /**
  48342. * Execute the action and play the sound.
  48343. */
  48344. execute(): void;
  48345. /**
  48346. * Serializes the actions and its related information.
  48347. * @param parent defines the object to serialize in
  48348. * @returns the serialized object
  48349. */
  48350. serialize(parent: any): any;
  48351. }
  48352. /**
  48353. * This defines an action helpful to stop a defined sound on a triggered action.
  48354. */
  48355. export class StopSoundAction extends Action {
  48356. private _sound;
  48357. /**
  48358. * Instantiate the action
  48359. * @param triggerOptions defines the trigger options
  48360. * @param sound defines the sound to stop
  48361. * @param condition defines the trigger related conditions
  48362. */
  48363. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48364. /** @hidden */
  48365. _prepare(): void;
  48366. /**
  48367. * Execute the action and stop the sound.
  48368. */
  48369. execute(): void;
  48370. /**
  48371. * Serializes the actions and its related information.
  48372. * @param parent defines the object to serialize in
  48373. * @returns the serialized object
  48374. */
  48375. serialize(parent: any): any;
  48376. }
  48377. }
  48378. declare module BABYLON {
  48379. /**
  48380. * This defines an action responsible to change the value of a property
  48381. * by interpolating between its current value and the newly set one once triggered.
  48382. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48383. */
  48384. export class InterpolateValueAction extends Action {
  48385. /**
  48386. * Defines the path of the property where the value should be interpolated
  48387. */
  48388. propertyPath: string;
  48389. /**
  48390. * Defines the target value at the end of the interpolation.
  48391. */
  48392. value: any;
  48393. /**
  48394. * Defines the time it will take for the property to interpolate to the value.
  48395. */
  48396. duration: number;
  48397. /**
  48398. * Defines if the other scene animations should be stopped when the action has been triggered
  48399. */
  48400. stopOtherAnimations?: boolean;
  48401. /**
  48402. * Defines a callback raised once the interpolation animation has been done.
  48403. */
  48404. onInterpolationDone?: () => void;
  48405. /**
  48406. * Observable triggered once the interpolation animation has been done.
  48407. */
  48408. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48409. private _target;
  48410. private _effectiveTarget;
  48411. private _property;
  48412. /**
  48413. * Instantiate the action
  48414. * @param triggerOptions defines the trigger options
  48415. * @param target defines the object containing the value to interpolate
  48416. * @param propertyPath defines the path to the property in the target object
  48417. * @param value defines the target value at the end of the interpolation
  48418. * @param duration deines the time it will take for the property to interpolate to the value.
  48419. * @param condition defines the trigger related conditions
  48420. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48421. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48422. */
  48423. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48424. /** @hidden */
  48425. _prepare(): void;
  48426. /**
  48427. * Execute the action starts the value interpolation.
  48428. */
  48429. execute(): void;
  48430. /**
  48431. * Serializes the actions and its related information.
  48432. * @param parent defines the object to serialize in
  48433. * @returns the serialized object
  48434. */
  48435. serialize(parent: any): any;
  48436. }
  48437. }
  48438. declare module BABYLON {
  48439. /**
  48440. * This represents the default audio engine used in babylon.
  48441. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48442. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48443. */
  48444. export class AudioEngine implements IAudioEngine {
  48445. private _audioContext;
  48446. private _audioContextInitialized;
  48447. private _muteButton;
  48448. private _hostElement;
  48449. /**
  48450. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48451. */
  48452. canUseWebAudio: boolean;
  48453. /**
  48454. * The master gain node defines the global audio volume of your audio engine.
  48455. */
  48456. masterGain: GainNode;
  48457. /**
  48458. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48459. * @ignoreNaming
  48460. */
  48461. WarnedWebAudioUnsupported: boolean;
  48462. /**
  48463. * Gets whether or not mp3 are supported by your browser.
  48464. */
  48465. isMP3supported: boolean;
  48466. /**
  48467. * Gets whether or not ogg are supported by your browser.
  48468. */
  48469. isOGGsupported: boolean;
  48470. /**
  48471. * Gets whether audio has been unlocked on the device.
  48472. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48473. * a user interaction has happened.
  48474. */
  48475. unlocked: boolean;
  48476. /**
  48477. * Defines if the audio engine relies on a custom unlocked button.
  48478. * In this case, the embedded button will not be displayed.
  48479. */
  48480. useCustomUnlockedButton: boolean;
  48481. /**
  48482. * Event raised when audio has been unlocked on the browser.
  48483. */
  48484. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48485. /**
  48486. * Event raised when audio has been locked on the browser.
  48487. */
  48488. onAudioLockedObservable: Observable<IAudioEngine>;
  48489. /**
  48490. * Gets the current AudioContext if available.
  48491. */
  48492. get audioContext(): Nullable<AudioContext>;
  48493. private _connectedAnalyser;
  48494. /**
  48495. * Instantiates a new audio engine.
  48496. *
  48497. * There should be only one per page as some browsers restrict the number
  48498. * of audio contexts you can create.
  48499. * @param hostElement defines the host element where to display the mute icon if necessary
  48500. */
  48501. constructor(hostElement?: Nullable<HTMLElement>);
  48502. /**
  48503. * Flags the audio engine in Locked state.
  48504. * This happens due to new browser policies preventing audio to autoplay.
  48505. */
  48506. lock(): void;
  48507. /**
  48508. * Unlocks the audio engine once a user action has been done on the dom.
  48509. * This is helpful to resume play once browser policies have been satisfied.
  48510. */
  48511. unlock(): void;
  48512. private _resumeAudioContext;
  48513. private _initializeAudioContext;
  48514. private _tryToRun;
  48515. private _triggerRunningState;
  48516. private _triggerSuspendedState;
  48517. private _displayMuteButton;
  48518. private _moveButtonToTopLeft;
  48519. private _onResize;
  48520. private _hideMuteButton;
  48521. /**
  48522. * Destroy and release the resources associated with the audio ccontext.
  48523. */
  48524. dispose(): void;
  48525. /**
  48526. * Gets the global volume sets on the master gain.
  48527. * @returns the global volume if set or -1 otherwise
  48528. */
  48529. getGlobalVolume(): number;
  48530. /**
  48531. * Sets the global volume of your experience (sets on the master gain).
  48532. * @param newVolume Defines the new global volume of the application
  48533. */
  48534. setGlobalVolume(newVolume: number): void;
  48535. /**
  48536. * Connect the audio engine to an audio analyser allowing some amazing
  48537. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48538. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48539. * @param analyser The analyser to connect to the engine
  48540. */
  48541. connectToAnalyser(analyser: Analyser): void;
  48542. }
  48543. }
  48544. declare module BABYLON {
  48545. /**
  48546. * Options allowed during the creation of a sound track.
  48547. */
  48548. export interface ISoundTrackOptions {
  48549. /**
  48550. * The volume the sound track should take during creation
  48551. */
  48552. volume?: number;
  48553. /**
  48554. * Define if the sound track is the main sound track of the scene
  48555. */
  48556. mainTrack?: boolean;
  48557. }
  48558. /**
  48559. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48560. * It will be also used in a future release to apply effects on a specific track.
  48561. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48562. */
  48563. export class SoundTrack {
  48564. /**
  48565. * The unique identifier of the sound track in the scene.
  48566. */
  48567. id: number;
  48568. /**
  48569. * The list of sounds included in the sound track.
  48570. */
  48571. soundCollection: Array<Sound>;
  48572. private _outputAudioNode;
  48573. private _scene;
  48574. private _connectedAnalyser;
  48575. private _options;
  48576. private _isInitialized;
  48577. /**
  48578. * Creates a new sound track.
  48579. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48580. * @param scene Define the scene the sound track belongs to
  48581. * @param options
  48582. */
  48583. constructor(scene: Scene, options?: ISoundTrackOptions);
  48584. private _initializeSoundTrackAudioGraph;
  48585. /**
  48586. * Release the sound track and its associated resources
  48587. */
  48588. dispose(): void;
  48589. /**
  48590. * Adds a sound to this sound track
  48591. * @param sound define the cound to add
  48592. * @ignoreNaming
  48593. */
  48594. addSound(sound: Sound): void;
  48595. /**
  48596. * Removes a sound to this sound track
  48597. * @param sound define the cound to remove
  48598. * @ignoreNaming
  48599. */
  48600. removeSound(sound: Sound): void;
  48601. /**
  48602. * Set a global volume for the full sound track.
  48603. * @param newVolume Define the new volume of the sound track
  48604. */
  48605. setVolume(newVolume: number): void;
  48606. /**
  48607. * Switch the panning model to HRTF:
  48608. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48609. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48610. */
  48611. switchPanningModelToHRTF(): void;
  48612. /**
  48613. * Switch the panning model to Equal Power:
  48614. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48616. */
  48617. switchPanningModelToEqualPower(): void;
  48618. /**
  48619. * Connect the sound track to an audio analyser allowing some amazing
  48620. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48621. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48622. * @param analyser The analyser to connect to the engine
  48623. */
  48624. connectToAnalyser(analyser: Analyser): void;
  48625. }
  48626. }
  48627. declare module BABYLON {
  48628. interface AbstractScene {
  48629. /**
  48630. * The list of sounds used in the scene.
  48631. */
  48632. sounds: Nullable<Array<Sound>>;
  48633. }
  48634. interface Scene {
  48635. /**
  48636. * @hidden
  48637. * Backing field
  48638. */
  48639. _mainSoundTrack: SoundTrack;
  48640. /**
  48641. * The main sound track played by the scene.
  48642. * It cotains your primary collection of sounds.
  48643. */
  48644. mainSoundTrack: SoundTrack;
  48645. /**
  48646. * The list of sound tracks added to the scene
  48647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48648. */
  48649. soundTracks: Nullable<Array<SoundTrack>>;
  48650. /**
  48651. * Gets a sound using a given name
  48652. * @param name defines the name to search for
  48653. * @return the found sound or null if not found at all.
  48654. */
  48655. getSoundByName(name: string): Nullable<Sound>;
  48656. /**
  48657. * Gets or sets if audio support is enabled
  48658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48659. */
  48660. audioEnabled: boolean;
  48661. /**
  48662. * Gets or sets if audio will be output to headphones
  48663. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48664. */
  48665. headphone: boolean;
  48666. /**
  48667. * Gets or sets custom audio listener position provider
  48668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48669. */
  48670. audioListenerPositionProvider: Nullable<() => Vector3>;
  48671. /**
  48672. * Gets or sets a refresh rate when using 3D audio positioning
  48673. */
  48674. audioPositioningRefreshRate: number;
  48675. }
  48676. /**
  48677. * Defines the sound scene component responsible to manage any sounds
  48678. * in a given scene.
  48679. */
  48680. export class AudioSceneComponent implements ISceneSerializableComponent {
  48681. private static _CameraDirectionLH;
  48682. private static _CameraDirectionRH;
  48683. /**
  48684. * The component name helpfull to identify the component in the list of scene components.
  48685. */
  48686. readonly name: string;
  48687. /**
  48688. * The scene the component belongs to.
  48689. */
  48690. scene: Scene;
  48691. private _audioEnabled;
  48692. /**
  48693. * Gets whether audio is enabled or not.
  48694. * Please use related enable/disable method to switch state.
  48695. */
  48696. get audioEnabled(): boolean;
  48697. private _headphone;
  48698. /**
  48699. * Gets whether audio is outputing to headphone or not.
  48700. * Please use the according Switch methods to change output.
  48701. */
  48702. get headphone(): boolean;
  48703. /**
  48704. * Gets or sets a refresh rate when using 3D audio positioning
  48705. */
  48706. audioPositioningRefreshRate: number;
  48707. private _audioListenerPositionProvider;
  48708. /**
  48709. * Gets the current audio listener position provider
  48710. */
  48711. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48712. /**
  48713. * Sets a custom listener position for all sounds in the scene
  48714. * By default, this is the position of the first active camera
  48715. */
  48716. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48717. /**
  48718. * Creates a new instance of the component for the given scene
  48719. * @param scene Defines the scene to register the component in
  48720. */
  48721. constructor(scene: Scene);
  48722. /**
  48723. * Registers the component in a given scene
  48724. */
  48725. register(): void;
  48726. /**
  48727. * Rebuilds the elements related to this component in case of
  48728. * context lost for instance.
  48729. */
  48730. rebuild(): void;
  48731. /**
  48732. * Serializes the component data to the specified json object
  48733. * @param serializationObject The object to serialize to
  48734. */
  48735. serialize(serializationObject: any): void;
  48736. /**
  48737. * Adds all the elements from the container to the scene
  48738. * @param container the container holding the elements
  48739. */
  48740. addFromContainer(container: AbstractScene): void;
  48741. /**
  48742. * Removes all the elements in the container from the scene
  48743. * @param container contains the elements to remove
  48744. * @param dispose if the removed element should be disposed (default: false)
  48745. */
  48746. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48747. /**
  48748. * Disposes the component and the associated ressources.
  48749. */
  48750. dispose(): void;
  48751. /**
  48752. * Disables audio in the associated scene.
  48753. */
  48754. disableAudio(): void;
  48755. /**
  48756. * Enables audio in the associated scene.
  48757. */
  48758. enableAudio(): void;
  48759. /**
  48760. * Switch audio to headphone output.
  48761. */
  48762. switchAudioModeForHeadphones(): void;
  48763. /**
  48764. * Switch audio to normal speakers.
  48765. */
  48766. switchAudioModeForNormalSpeakers(): void;
  48767. private _cachedCameraDirection;
  48768. private _cachedCameraPosition;
  48769. private _lastCheck;
  48770. private _afterRender;
  48771. }
  48772. }
  48773. declare module BABYLON {
  48774. /**
  48775. * Wraps one or more Sound objects and selects one with random weight for playback.
  48776. */
  48777. export class WeightedSound {
  48778. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48779. loop: boolean;
  48780. private _coneInnerAngle;
  48781. private _coneOuterAngle;
  48782. private _volume;
  48783. /** A Sound is currently playing. */
  48784. isPlaying: boolean;
  48785. /** A Sound is currently paused. */
  48786. isPaused: boolean;
  48787. private _sounds;
  48788. private _weights;
  48789. private _currentIndex?;
  48790. /**
  48791. * Creates a new WeightedSound from the list of sounds given.
  48792. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48793. * @param sounds Array of Sounds that will be selected from.
  48794. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48795. */
  48796. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48797. /**
  48798. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48799. */
  48800. get directionalConeInnerAngle(): number;
  48801. /**
  48802. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48803. */
  48804. set directionalConeInnerAngle(value: number);
  48805. /**
  48806. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48807. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48808. */
  48809. get directionalConeOuterAngle(): number;
  48810. /**
  48811. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48812. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48813. */
  48814. set directionalConeOuterAngle(value: number);
  48815. /**
  48816. * Playback volume.
  48817. */
  48818. get volume(): number;
  48819. /**
  48820. * Playback volume.
  48821. */
  48822. set volume(value: number);
  48823. private _onended;
  48824. /**
  48825. * Suspend playback
  48826. */
  48827. pause(): void;
  48828. /**
  48829. * Stop playback
  48830. */
  48831. stop(): void;
  48832. /**
  48833. * Start playback.
  48834. * @param startOffset Position the clip head at a specific time in seconds.
  48835. */
  48836. play(startOffset?: number): void;
  48837. }
  48838. }
  48839. declare module BABYLON {
  48840. /**
  48841. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48842. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48843. */
  48844. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48845. /**
  48846. * Gets the name of the behavior.
  48847. */
  48848. get name(): string;
  48849. /**
  48850. * The easing function used by animations
  48851. */
  48852. static EasingFunction: BackEase;
  48853. /**
  48854. * The easing mode used by animations
  48855. */
  48856. static EasingMode: number;
  48857. /**
  48858. * The duration of the animation, in milliseconds
  48859. */
  48860. transitionDuration: number;
  48861. /**
  48862. * Length of the distance animated by the transition when lower radius is reached
  48863. */
  48864. lowerRadiusTransitionRange: number;
  48865. /**
  48866. * Length of the distance animated by the transition when upper radius is reached
  48867. */
  48868. upperRadiusTransitionRange: number;
  48869. private _autoTransitionRange;
  48870. /**
  48871. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48872. */
  48873. get autoTransitionRange(): boolean;
  48874. /**
  48875. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48876. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48877. */
  48878. set autoTransitionRange(value: boolean);
  48879. private _attachedCamera;
  48880. private _onAfterCheckInputsObserver;
  48881. private _onMeshTargetChangedObserver;
  48882. /**
  48883. * Initializes the behavior.
  48884. */
  48885. init(): void;
  48886. /**
  48887. * Attaches the behavior to its arc rotate camera.
  48888. * @param camera Defines the camera to attach the behavior to
  48889. */
  48890. attach(camera: ArcRotateCamera): void;
  48891. /**
  48892. * Detaches the behavior from its current arc rotate camera.
  48893. */
  48894. detach(): void;
  48895. private _radiusIsAnimating;
  48896. private _radiusBounceTransition;
  48897. private _animatables;
  48898. private _cachedWheelPrecision;
  48899. /**
  48900. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48901. * @param radiusLimit The limit to check against.
  48902. * @return Bool to indicate if at limit.
  48903. */
  48904. private _isRadiusAtLimit;
  48905. /**
  48906. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48907. * @param radiusDelta The delta by which to animate to. Can be negative.
  48908. */
  48909. private _applyBoundRadiusAnimation;
  48910. /**
  48911. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48912. */
  48913. protected _clearAnimationLocks(): void;
  48914. /**
  48915. * Stops and removes all animations that have been applied to the camera
  48916. */
  48917. stopAllAnimations(): void;
  48918. }
  48919. }
  48920. declare module BABYLON {
  48921. /**
  48922. * 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.
  48923. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48924. */
  48925. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48926. /**
  48927. * Gets the name of the behavior.
  48928. */
  48929. get name(): string;
  48930. private _mode;
  48931. private _radiusScale;
  48932. private _positionScale;
  48933. private _defaultElevation;
  48934. private _elevationReturnTime;
  48935. private _elevationReturnWaitTime;
  48936. private _zoomStopsAnimation;
  48937. private _framingTime;
  48938. /**
  48939. * The easing function used by animations
  48940. */
  48941. static EasingFunction: ExponentialEase;
  48942. /**
  48943. * The easing mode used by animations
  48944. */
  48945. static EasingMode: number;
  48946. /**
  48947. * Sets the current mode used by the behavior
  48948. */
  48949. set mode(mode: number);
  48950. /**
  48951. * Gets current mode used by the behavior.
  48952. */
  48953. get mode(): number;
  48954. /**
  48955. * Sets the scale applied to the radius (1 by default)
  48956. */
  48957. set radiusScale(radius: number);
  48958. /**
  48959. * Gets the scale applied to the radius
  48960. */
  48961. get radiusScale(): number;
  48962. /**
  48963. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48964. */
  48965. set positionScale(scale: number);
  48966. /**
  48967. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48968. */
  48969. get positionScale(): number;
  48970. /**
  48971. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48972. * behaviour is triggered, in radians.
  48973. */
  48974. set defaultElevation(elevation: number);
  48975. /**
  48976. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48977. * behaviour is triggered, in radians.
  48978. */
  48979. get defaultElevation(): number;
  48980. /**
  48981. * Sets the time (in milliseconds) taken to return to the default beta position.
  48982. * Negative value indicates camera should not return to default.
  48983. */
  48984. set elevationReturnTime(speed: number);
  48985. /**
  48986. * Gets the time (in milliseconds) taken to return to the default beta position.
  48987. * Negative value indicates camera should not return to default.
  48988. */
  48989. get elevationReturnTime(): number;
  48990. /**
  48991. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48992. */
  48993. set elevationReturnWaitTime(time: number);
  48994. /**
  48995. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48996. */
  48997. get elevationReturnWaitTime(): number;
  48998. /**
  48999. * Sets the flag that indicates if user zooming should stop animation.
  49000. */
  49001. set zoomStopsAnimation(flag: boolean);
  49002. /**
  49003. * Gets the flag that indicates if user zooming should stop animation.
  49004. */
  49005. get zoomStopsAnimation(): boolean;
  49006. /**
  49007. * Sets the transition time when framing the mesh, in milliseconds
  49008. */
  49009. set framingTime(time: number);
  49010. /**
  49011. * Gets the transition time when framing the mesh, in milliseconds
  49012. */
  49013. get framingTime(): number;
  49014. /**
  49015. * Define if the behavior should automatically change the configured
  49016. * camera limits and sensibilities.
  49017. */
  49018. autoCorrectCameraLimitsAndSensibility: boolean;
  49019. private _onPrePointerObservableObserver;
  49020. private _onAfterCheckInputsObserver;
  49021. private _onMeshTargetChangedObserver;
  49022. private _attachedCamera;
  49023. private _isPointerDown;
  49024. private _lastInteractionTime;
  49025. /**
  49026. * Initializes the behavior.
  49027. */
  49028. init(): void;
  49029. /**
  49030. * Attaches the behavior to its arc rotate camera.
  49031. * @param camera Defines the camera to attach the behavior to
  49032. */
  49033. attach(camera: ArcRotateCamera): void;
  49034. /**
  49035. * Detaches the behavior from its current arc rotate camera.
  49036. */
  49037. detach(): void;
  49038. private _animatables;
  49039. private _betaIsAnimating;
  49040. private _betaTransition;
  49041. private _radiusTransition;
  49042. private _vectorTransition;
  49043. /**
  49044. * Targets the given mesh and updates zoom level accordingly.
  49045. * @param mesh The mesh to target.
  49046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49048. */
  49049. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49050. /**
  49051. * Targets the given mesh with its children and updates zoom level accordingly.
  49052. * @param mesh The mesh to target.
  49053. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49054. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49055. */
  49056. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49057. /**
  49058. * Targets the given meshes with their children and updates zoom level accordingly.
  49059. * @param meshes The mesh to target.
  49060. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49061. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49062. */
  49063. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49064. /**
  49065. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49066. * @param minimumWorld Determines the smaller position of the bounding box extend
  49067. * @param maximumWorld Determines the bigger position of the bounding box extend
  49068. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49069. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49070. */
  49071. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49072. /**
  49073. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49074. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49075. * frustum width.
  49076. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49077. * to fully enclose the mesh in the viewing frustum.
  49078. */
  49079. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49080. /**
  49081. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49082. * is automatically returned to its default position (expected to be above ground plane).
  49083. */
  49084. private _maintainCameraAboveGround;
  49085. /**
  49086. * Returns the frustum slope based on the canvas ratio and camera FOV
  49087. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49088. */
  49089. private _getFrustumSlope;
  49090. /**
  49091. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49092. */
  49093. private _clearAnimationLocks;
  49094. /**
  49095. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49096. */
  49097. private _applyUserInteraction;
  49098. /**
  49099. * Stops and removes all animations that have been applied to the camera
  49100. */
  49101. stopAllAnimations(): void;
  49102. /**
  49103. * Gets a value indicating if the user is moving the camera
  49104. */
  49105. get isUserIsMoving(): boolean;
  49106. /**
  49107. * The camera can move all the way towards the mesh.
  49108. */
  49109. static IgnoreBoundsSizeMode: number;
  49110. /**
  49111. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49112. */
  49113. static FitFrustumSidesMode: number;
  49114. }
  49115. }
  49116. declare module BABYLON {
  49117. /**
  49118. * Base class for Camera Pointer Inputs.
  49119. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49120. * for example usage.
  49121. */
  49122. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49123. /**
  49124. * Defines the camera the input is attached to.
  49125. */
  49126. abstract camera: Camera;
  49127. /**
  49128. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49129. */
  49130. protected _altKey: boolean;
  49131. protected _ctrlKey: boolean;
  49132. protected _metaKey: boolean;
  49133. protected _shiftKey: boolean;
  49134. /**
  49135. * Which mouse buttons were pressed at time of last mouse event.
  49136. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49137. */
  49138. protected _buttonsPressed: number;
  49139. /**
  49140. * Defines the buttons associated with the input to handle camera move.
  49141. */
  49142. buttons: number[];
  49143. /**
  49144. * Attach the input controls to a specific dom element to get the input from.
  49145. * @param element Defines the element the controls should be listened from
  49146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49147. */
  49148. attachControl(noPreventDefault?: boolean): void;
  49149. /**
  49150. * Detach the current controls from the specified dom element.
  49151. */
  49152. detachControl(): void;
  49153. /**
  49154. * Gets the class name of the current input.
  49155. * @returns the class name
  49156. */
  49157. getClassName(): string;
  49158. /**
  49159. * Get the friendly name associated with the input class.
  49160. * @returns the input friendly name
  49161. */
  49162. getSimpleName(): string;
  49163. /**
  49164. * Called on pointer POINTERDOUBLETAP event.
  49165. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49166. */
  49167. protected onDoubleTap(type: string): void;
  49168. /**
  49169. * Called on pointer POINTERMOVE event if only a single touch is active.
  49170. * Override this method to provide functionality.
  49171. */
  49172. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49173. /**
  49174. * Called on pointer POINTERMOVE event if multiple touches are active.
  49175. * Override this method to provide functionality.
  49176. */
  49177. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49178. /**
  49179. * Called on JS contextmenu event.
  49180. * Override this method to provide functionality.
  49181. */
  49182. protected onContextMenu(evt: PointerEvent): void;
  49183. /**
  49184. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49185. * press.
  49186. * Override this method to provide functionality.
  49187. */
  49188. protected onButtonDown(evt: PointerEvent): void;
  49189. /**
  49190. * Called each time a new POINTERUP event occurs. Ie, for each button
  49191. * release.
  49192. * Override this method to provide functionality.
  49193. */
  49194. protected onButtonUp(evt: PointerEvent): void;
  49195. /**
  49196. * Called when window becomes inactive.
  49197. * Override this method to provide functionality.
  49198. */
  49199. protected onLostFocus(): void;
  49200. private _pointerInput;
  49201. private _observer;
  49202. private _onLostFocus;
  49203. private pointA;
  49204. private pointB;
  49205. }
  49206. }
  49207. declare module BABYLON {
  49208. /**
  49209. * Manage the pointers inputs to control an arc rotate camera.
  49210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49211. */
  49212. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49213. /**
  49214. * Defines the camera the input is attached to.
  49215. */
  49216. camera: ArcRotateCamera;
  49217. /**
  49218. * Gets the class name of the current input.
  49219. * @returns the class name
  49220. */
  49221. getClassName(): string;
  49222. /**
  49223. * Defines the buttons associated with the input to handle camera move.
  49224. */
  49225. buttons: number[];
  49226. /**
  49227. * Defines the pointer angular sensibility along the X axis or how fast is
  49228. * the camera rotating.
  49229. */
  49230. angularSensibilityX: number;
  49231. /**
  49232. * Defines the pointer angular sensibility along the Y axis or how fast is
  49233. * the camera rotating.
  49234. */
  49235. angularSensibilityY: number;
  49236. /**
  49237. * Defines the pointer pinch precision or how fast is the camera zooming.
  49238. */
  49239. pinchPrecision: number;
  49240. /**
  49241. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49242. * from 0.
  49243. * It defines the percentage of current camera.radius to use as delta when
  49244. * pinch zoom is used.
  49245. */
  49246. pinchDeltaPercentage: number;
  49247. /**
  49248. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49249. * that any object in the plane at the camera's target point will scale
  49250. * perfectly with finger motion.
  49251. * Overrides pinchDeltaPercentage and pinchPrecision.
  49252. */
  49253. useNaturalPinchZoom: boolean;
  49254. /**
  49255. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49256. */
  49257. pinchZoom: boolean;
  49258. /**
  49259. * Defines the pointer panning sensibility or how fast is the camera moving.
  49260. */
  49261. panningSensibility: number;
  49262. /**
  49263. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49264. */
  49265. multiTouchPanning: boolean;
  49266. /**
  49267. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49268. * zoom (pinch) through multitouch.
  49269. */
  49270. multiTouchPanAndZoom: boolean;
  49271. /**
  49272. * Revers pinch action direction.
  49273. */
  49274. pinchInwards: boolean;
  49275. private _isPanClick;
  49276. private _twoFingerActivityCount;
  49277. private _isPinching;
  49278. /**
  49279. * Move camera from multi touch panning positions.
  49280. */
  49281. private _computeMultiTouchPanning;
  49282. /**
  49283. * Move camera from pinch zoom distances.
  49284. */
  49285. private _computePinchZoom;
  49286. /**
  49287. * Called on pointer POINTERMOVE event if only a single touch is active.
  49288. */
  49289. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49290. /**
  49291. * Called on pointer POINTERDOUBLETAP event.
  49292. */
  49293. protected onDoubleTap(type: string): void;
  49294. /**
  49295. * Called on pointer POINTERMOVE event if multiple touches are active.
  49296. */
  49297. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49298. /**
  49299. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49300. * press.
  49301. */
  49302. protected onButtonDown(evt: PointerEvent): void;
  49303. /**
  49304. * Called each time a new POINTERUP event occurs. Ie, for each button
  49305. * release.
  49306. */
  49307. protected onButtonUp(evt: PointerEvent): void;
  49308. /**
  49309. * Called when window becomes inactive.
  49310. */
  49311. protected onLostFocus(): void;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49318. */
  49319. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49320. /**
  49321. * Defines the camera the input is attached to.
  49322. */
  49323. camera: ArcRotateCamera;
  49324. /**
  49325. * Defines the list of key codes associated with the up action (increase alpha)
  49326. */
  49327. keysUp: number[];
  49328. /**
  49329. * Defines the list of key codes associated with the down action (decrease alpha)
  49330. */
  49331. keysDown: number[];
  49332. /**
  49333. * Defines the list of key codes associated with the left action (increase beta)
  49334. */
  49335. keysLeft: number[];
  49336. /**
  49337. * Defines the list of key codes associated with the right action (decrease beta)
  49338. */
  49339. keysRight: number[];
  49340. /**
  49341. * Defines the list of key codes associated with the reset action.
  49342. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49343. */
  49344. keysReset: number[];
  49345. /**
  49346. * Defines the panning sensibility of the inputs.
  49347. * (How fast is the camera panning)
  49348. */
  49349. panningSensibility: number;
  49350. /**
  49351. * Defines the zooming sensibility of the inputs.
  49352. * (How fast is the camera zooming)
  49353. */
  49354. zoomingSensibility: number;
  49355. /**
  49356. * Defines whether maintaining the alt key down switch the movement mode from
  49357. * orientation to zoom.
  49358. */
  49359. useAltToZoom: boolean;
  49360. /**
  49361. * Rotation speed of the camera
  49362. */
  49363. angularSpeed: number;
  49364. private _keys;
  49365. private _ctrlPressed;
  49366. private _altPressed;
  49367. private _onCanvasBlurObserver;
  49368. private _onKeyboardObserver;
  49369. private _engine;
  49370. private _scene;
  49371. /**
  49372. * Attach the input controls to a specific dom element to get the input from.
  49373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49374. */
  49375. attachControl(noPreventDefault?: boolean): void;
  49376. /**
  49377. * Detach the current controls from the specified dom element.
  49378. */
  49379. detachControl(): void;
  49380. /**
  49381. * Update the current camera state depending on the inputs that have been used this frame.
  49382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49383. */
  49384. checkInputs(): void;
  49385. /**
  49386. * Gets the class name of the current intput.
  49387. * @returns the class name
  49388. */
  49389. getClassName(): string;
  49390. /**
  49391. * Get the friendly name associated with the input class.
  49392. * @returns the input friendly name
  49393. */
  49394. getSimpleName(): string;
  49395. }
  49396. }
  49397. declare module BABYLON {
  49398. /**
  49399. * Manage the mouse wheel inputs to control an arc rotate camera.
  49400. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49401. */
  49402. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49403. /**
  49404. * Defines the camera the input is attached to.
  49405. */
  49406. camera: ArcRotateCamera;
  49407. /**
  49408. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49409. */
  49410. wheelPrecision: number;
  49411. /**
  49412. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49413. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49414. */
  49415. wheelDeltaPercentage: number;
  49416. private _wheel;
  49417. private _observer;
  49418. private computeDeltaFromMouseWheelLegacyEvent;
  49419. /**
  49420. * Attach the input controls to a specific dom element to get the input from.
  49421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49422. */
  49423. attachControl(noPreventDefault?: boolean): void;
  49424. /**
  49425. * Detach the current controls from the specified dom element.
  49426. */
  49427. detachControl(): void;
  49428. /**
  49429. * Gets the class name of the current intput.
  49430. * @returns the class name
  49431. */
  49432. getClassName(): string;
  49433. /**
  49434. * Get the friendly name associated with the input class.
  49435. * @returns the input friendly name
  49436. */
  49437. getSimpleName(): string;
  49438. }
  49439. }
  49440. declare module BABYLON {
  49441. /**
  49442. * Default Inputs manager for the ArcRotateCamera.
  49443. * It groups all the default supported inputs for ease of use.
  49444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49445. */
  49446. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49447. /**
  49448. * Instantiates a new ArcRotateCameraInputsManager.
  49449. * @param camera Defines the camera the inputs belong to
  49450. */
  49451. constructor(camera: ArcRotateCamera);
  49452. /**
  49453. * Add mouse wheel input support to the input manager.
  49454. * @returns the current input manager
  49455. */
  49456. addMouseWheel(): ArcRotateCameraInputsManager;
  49457. /**
  49458. * Add pointers input support to the input manager.
  49459. * @returns the current input manager
  49460. */
  49461. addPointers(): ArcRotateCameraInputsManager;
  49462. /**
  49463. * Add keyboard input support to the input manager.
  49464. * @returns the current input manager
  49465. */
  49466. addKeyboard(): ArcRotateCameraInputsManager;
  49467. }
  49468. }
  49469. declare module BABYLON {
  49470. /**
  49471. * This represents an orbital type of camera.
  49472. *
  49473. * 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.
  49474. * 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.
  49475. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49476. */
  49477. export class ArcRotateCamera extends TargetCamera {
  49478. /**
  49479. * Defines the rotation angle of the camera along the longitudinal axis.
  49480. */
  49481. alpha: number;
  49482. /**
  49483. * Defines the rotation angle of the camera along the latitudinal axis.
  49484. */
  49485. beta: number;
  49486. /**
  49487. * Defines the radius of the camera from it s target point.
  49488. */
  49489. radius: number;
  49490. protected _target: Vector3;
  49491. protected _targetHost: Nullable<AbstractMesh>;
  49492. /**
  49493. * Defines the target point of the camera.
  49494. * The camera looks towards it form the radius distance.
  49495. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49496. */
  49497. get target(): Vector3;
  49498. set target(value: Vector3);
  49499. /**
  49500. * Define the current local position of the camera in the scene
  49501. */
  49502. get position(): Vector3;
  49503. set position(newPosition: Vector3);
  49504. protected _upToYMatrix: Matrix;
  49505. protected _YToUpMatrix: Matrix;
  49506. /**
  49507. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49508. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49509. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49510. */
  49511. set upVector(vec: Vector3);
  49512. get upVector(): Vector3;
  49513. /**
  49514. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49515. */
  49516. setMatUp(): void;
  49517. /**
  49518. * Current inertia value on the longitudinal axis.
  49519. * The bigger this number the longer it will take for the camera to stop.
  49520. */
  49521. inertialAlphaOffset: number;
  49522. /**
  49523. * Current inertia value on the latitudinal axis.
  49524. * The bigger this number the longer it will take for the camera to stop.
  49525. */
  49526. inertialBetaOffset: number;
  49527. /**
  49528. * Current inertia value on the radius axis.
  49529. * The bigger this number the longer it will take for the camera to stop.
  49530. */
  49531. inertialRadiusOffset: number;
  49532. /**
  49533. * Minimum allowed angle on the longitudinal axis.
  49534. * This can help limiting how the Camera is able to move in the scene.
  49535. */
  49536. lowerAlphaLimit: Nullable<number>;
  49537. /**
  49538. * Maximum allowed angle on the longitudinal axis.
  49539. * This can help limiting how the Camera is able to move in the scene.
  49540. */
  49541. upperAlphaLimit: Nullable<number>;
  49542. /**
  49543. * Minimum allowed angle on the latitudinal axis.
  49544. * This can help limiting how the Camera is able to move in the scene.
  49545. */
  49546. lowerBetaLimit: number;
  49547. /**
  49548. * Maximum allowed angle on the latitudinal axis.
  49549. * This can help limiting how the Camera is able to move in the scene.
  49550. */
  49551. upperBetaLimit: number;
  49552. /**
  49553. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49554. * This can help limiting how the Camera is able to move in the scene.
  49555. */
  49556. lowerRadiusLimit: Nullable<number>;
  49557. /**
  49558. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49559. * This can help limiting how the Camera is able to move in the scene.
  49560. */
  49561. upperRadiusLimit: Nullable<number>;
  49562. /**
  49563. * Defines the current inertia value used during panning of the camera along the X axis.
  49564. */
  49565. inertialPanningX: number;
  49566. /**
  49567. * Defines the current inertia value used during panning of the camera along the Y axis.
  49568. */
  49569. inertialPanningY: number;
  49570. /**
  49571. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49572. * Basically if your fingers moves away from more than this distance you will be considered
  49573. * in pinch mode.
  49574. */
  49575. pinchToPanMaxDistance: number;
  49576. /**
  49577. * Defines the maximum distance the camera can pan.
  49578. * This could help keeping the cammera always in your scene.
  49579. */
  49580. panningDistanceLimit: Nullable<number>;
  49581. /**
  49582. * Defines the target of the camera before paning.
  49583. */
  49584. panningOriginTarget: Vector3;
  49585. /**
  49586. * Defines the value of the inertia used during panning.
  49587. * 0 would mean stop inertia and one would mean no decelleration at all.
  49588. */
  49589. panningInertia: number;
  49590. /**
  49591. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49592. */
  49593. get angularSensibilityX(): number;
  49594. set angularSensibilityX(value: number);
  49595. /**
  49596. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49597. */
  49598. get angularSensibilityY(): number;
  49599. set angularSensibilityY(value: number);
  49600. /**
  49601. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49602. */
  49603. get pinchPrecision(): number;
  49604. set pinchPrecision(value: number);
  49605. /**
  49606. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49607. * It will be used instead of pinchDeltaPrecision if different from 0.
  49608. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49609. */
  49610. get pinchDeltaPercentage(): number;
  49611. set pinchDeltaPercentage(value: number);
  49612. /**
  49613. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49614. * and pinch delta percentage.
  49615. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49616. * that any object in the plane at the camera's target point will scale
  49617. * perfectly with finger motion.
  49618. */
  49619. get useNaturalPinchZoom(): boolean;
  49620. set useNaturalPinchZoom(value: boolean);
  49621. /**
  49622. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49623. */
  49624. get panningSensibility(): number;
  49625. set panningSensibility(value: number);
  49626. /**
  49627. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49628. */
  49629. get keysUp(): number[];
  49630. set keysUp(value: number[]);
  49631. /**
  49632. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49633. */
  49634. get keysDown(): number[];
  49635. set keysDown(value: number[]);
  49636. /**
  49637. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49638. */
  49639. get keysLeft(): number[];
  49640. set keysLeft(value: number[]);
  49641. /**
  49642. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49643. */
  49644. get keysRight(): number[];
  49645. set keysRight(value: number[]);
  49646. /**
  49647. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49648. */
  49649. get wheelPrecision(): number;
  49650. set wheelPrecision(value: number);
  49651. /**
  49652. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49653. * It will be used instead of pinchDeltaPrecision if different from 0.
  49654. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49655. */
  49656. get wheelDeltaPercentage(): number;
  49657. set wheelDeltaPercentage(value: number);
  49658. /**
  49659. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49660. */
  49661. zoomOnFactor: number;
  49662. /**
  49663. * Defines a screen offset for the camera position.
  49664. */
  49665. targetScreenOffset: Vector2;
  49666. /**
  49667. * Allows the camera to be completely reversed.
  49668. * If false the camera can not arrive upside down.
  49669. */
  49670. allowUpsideDown: boolean;
  49671. /**
  49672. * Define if double tap/click is used to restore the previously saved state of the camera.
  49673. */
  49674. useInputToRestoreState: boolean;
  49675. /** @hidden */
  49676. _viewMatrix: Matrix;
  49677. /** @hidden */
  49678. _useCtrlForPanning: boolean;
  49679. /** @hidden */
  49680. _panningMouseButton: number;
  49681. /**
  49682. * Defines the input associated to the camera.
  49683. */
  49684. inputs: ArcRotateCameraInputsManager;
  49685. /** @hidden */
  49686. _reset: () => void;
  49687. /**
  49688. * Defines the allowed panning axis.
  49689. */
  49690. panningAxis: Vector3;
  49691. protected _transformedDirection: Vector3;
  49692. private _bouncingBehavior;
  49693. /**
  49694. * Gets the bouncing behavior of the camera if it has been enabled.
  49695. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49696. */
  49697. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49698. /**
  49699. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49700. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49701. */
  49702. get useBouncingBehavior(): boolean;
  49703. set useBouncingBehavior(value: boolean);
  49704. private _framingBehavior;
  49705. /**
  49706. * Gets the framing behavior of the camera if it has been enabled.
  49707. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49708. */
  49709. get framingBehavior(): Nullable<FramingBehavior>;
  49710. /**
  49711. * Defines if the framing behavior of the camera is enabled on the camera.
  49712. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49713. */
  49714. get useFramingBehavior(): boolean;
  49715. set useFramingBehavior(value: boolean);
  49716. private _autoRotationBehavior;
  49717. /**
  49718. * Gets the auto rotation behavior of the camera if it has been enabled.
  49719. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49720. */
  49721. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49722. /**
  49723. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49724. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49725. */
  49726. get useAutoRotationBehavior(): boolean;
  49727. set useAutoRotationBehavior(value: boolean);
  49728. /**
  49729. * Observable triggered when the mesh target has been changed on the camera.
  49730. */
  49731. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49732. /**
  49733. * Event raised when the camera is colliding with a mesh.
  49734. */
  49735. onCollide: (collidedMesh: AbstractMesh) => void;
  49736. /**
  49737. * Defines whether the camera should check collision with the objects oh the scene.
  49738. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49739. */
  49740. checkCollisions: boolean;
  49741. /**
  49742. * Defines the collision radius of the camera.
  49743. * This simulates a sphere around the camera.
  49744. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49745. */
  49746. collisionRadius: Vector3;
  49747. protected _collider: Collider;
  49748. protected _previousPosition: Vector3;
  49749. protected _collisionVelocity: Vector3;
  49750. protected _newPosition: Vector3;
  49751. protected _previousAlpha: number;
  49752. protected _previousBeta: number;
  49753. protected _previousRadius: number;
  49754. protected _collisionTriggered: boolean;
  49755. protected _targetBoundingCenter: Nullable<Vector3>;
  49756. private _computationVector;
  49757. /**
  49758. * Instantiates a new ArcRotateCamera in a given scene
  49759. * @param name Defines the name of the camera
  49760. * @param alpha Defines the camera rotation along the logitudinal axis
  49761. * @param beta Defines the camera rotation along the latitudinal axis
  49762. * @param radius Defines the camera distance from its target
  49763. * @param target Defines the camera target
  49764. * @param scene Defines the scene the camera belongs to
  49765. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49766. */
  49767. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49768. /** @hidden */
  49769. _initCache(): void;
  49770. /** @hidden */
  49771. _updateCache(ignoreParentClass?: boolean): void;
  49772. protected _getTargetPosition(): Vector3;
  49773. private _storedAlpha;
  49774. private _storedBeta;
  49775. private _storedRadius;
  49776. private _storedTarget;
  49777. private _storedTargetScreenOffset;
  49778. /**
  49779. * Stores the current state of the camera (alpha, beta, radius and target)
  49780. * @returns the camera itself
  49781. */
  49782. storeState(): Camera;
  49783. /**
  49784. * @hidden
  49785. * Restored camera state. You must call storeState() first
  49786. */
  49787. _restoreStateValues(): boolean;
  49788. /** @hidden */
  49789. _isSynchronizedViewMatrix(): boolean;
  49790. /**
  49791. * Attach the input controls to a specific dom element to get the input from.
  49792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49793. */
  49794. attachControl(noPreventDefault?: boolean): void;
  49795. /**
  49796. * Attach the input controls to a specific dom element to get the input from.
  49797. * @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
  49798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49799. */
  49800. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49801. /**
  49802. * Attached controls to the current camera.
  49803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49804. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49805. */
  49806. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49807. /**
  49808. * Attached controls to the current camera.
  49809. * @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
  49810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49811. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49812. */
  49813. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49814. /**
  49815. * Attached controls to the current camera.
  49816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49817. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49818. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49819. */
  49820. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49821. /**
  49822. * Detach the current controls from the specified dom element.
  49823. */
  49824. detachControl(): void;
  49825. /**
  49826. * Detach the current controls from the specified dom element.
  49827. * @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
  49828. */
  49829. detachControl(ignored: any): void;
  49830. /** @hidden */
  49831. _checkInputs(): void;
  49832. protected _checkLimits(): void;
  49833. /**
  49834. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49835. */
  49836. rebuildAnglesAndRadius(): void;
  49837. /**
  49838. * Use a position to define the current camera related information like alpha, beta and radius
  49839. * @param position Defines the position to set the camera at
  49840. */
  49841. setPosition(position: Vector3): void;
  49842. /**
  49843. * Defines the target the camera should look at.
  49844. * This will automatically adapt alpha beta and radius to fit within the new target.
  49845. * @param target Defines the new target as a Vector or a mesh
  49846. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49847. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49848. */
  49849. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49850. /** @hidden */
  49851. _getViewMatrix(): Matrix;
  49852. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49853. /**
  49854. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49855. * @param meshes Defines the mesh to zoom on
  49856. * @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)
  49857. */
  49858. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49859. /**
  49860. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49861. * The target will be changed but the radius
  49862. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49863. * @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)
  49864. */
  49865. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49866. min: Vector3;
  49867. max: Vector3;
  49868. distance: number;
  49869. }, doNotUpdateMaxZ?: boolean): void;
  49870. /**
  49871. * @override
  49872. * Override Camera.createRigCamera
  49873. */
  49874. createRigCamera(name: string, cameraIndex: number): Camera;
  49875. /**
  49876. * @hidden
  49877. * @override
  49878. * Override Camera._updateRigCameras
  49879. */
  49880. _updateRigCameras(): void;
  49881. /**
  49882. * Destroy the camera and release the current resources hold by it.
  49883. */
  49884. dispose(): void;
  49885. /**
  49886. * Gets the current object class name.
  49887. * @return the class name
  49888. */
  49889. getClassName(): string;
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /**
  49894. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49895. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49896. */
  49897. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49898. /**
  49899. * Gets the name of the behavior.
  49900. */
  49901. get name(): string;
  49902. private _zoomStopsAnimation;
  49903. private _idleRotationSpeed;
  49904. private _idleRotationWaitTime;
  49905. private _idleRotationSpinupTime;
  49906. /**
  49907. * Sets the flag that indicates if user zooming should stop animation.
  49908. */
  49909. set zoomStopsAnimation(flag: boolean);
  49910. /**
  49911. * Gets the flag that indicates if user zooming should stop animation.
  49912. */
  49913. get zoomStopsAnimation(): boolean;
  49914. /**
  49915. * Sets the default speed at which the camera rotates around the model.
  49916. */
  49917. set idleRotationSpeed(speed: number);
  49918. /**
  49919. * Gets the default speed at which the camera rotates around the model.
  49920. */
  49921. get idleRotationSpeed(): number;
  49922. /**
  49923. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49924. */
  49925. set idleRotationWaitTime(time: number);
  49926. /**
  49927. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49928. */
  49929. get idleRotationWaitTime(): number;
  49930. /**
  49931. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49932. */
  49933. set idleRotationSpinupTime(time: number);
  49934. /**
  49935. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49936. */
  49937. get idleRotationSpinupTime(): number;
  49938. /**
  49939. * Gets a value indicating if the camera is currently rotating because of this behavior
  49940. */
  49941. get rotationInProgress(): boolean;
  49942. private _onPrePointerObservableObserver;
  49943. private _onAfterCheckInputsObserver;
  49944. private _attachedCamera;
  49945. private _isPointerDown;
  49946. private _lastFrameTime;
  49947. private _lastInteractionTime;
  49948. private _cameraRotationSpeed;
  49949. /**
  49950. * Initializes the behavior.
  49951. */
  49952. init(): void;
  49953. /**
  49954. * Attaches the behavior to its arc rotate camera.
  49955. * @param camera Defines the camera to attach the behavior to
  49956. */
  49957. attach(camera: ArcRotateCamera): void;
  49958. /**
  49959. * Detaches the behavior from its current arc rotate camera.
  49960. */
  49961. detach(): void;
  49962. /**
  49963. * Returns true if user is scrolling.
  49964. * @return true if user is scrolling.
  49965. */
  49966. private _userIsZooming;
  49967. private _lastFrameRadius;
  49968. private _shouldAnimationStopForInteraction;
  49969. /**
  49970. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49971. */
  49972. private _applyUserInteraction;
  49973. private _userIsMoving;
  49974. }
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49979. */
  49980. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49981. private ui;
  49982. /**
  49983. * The name of the behavior
  49984. */
  49985. name: string;
  49986. /**
  49987. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49988. */
  49989. distanceAwayFromFace: number;
  49990. /**
  49991. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49992. */
  49993. distanceAwayFromBottomOfFace: number;
  49994. private _faceVectors;
  49995. private _target;
  49996. private _scene;
  49997. private _onRenderObserver;
  49998. private _tmpMatrix;
  49999. private _tmpVector;
  50000. /**
  50001. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50002. * @param ui The transform node that should be attched to the mesh
  50003. */
  50004. constructor(ui: TransformNode);
  50005. /**
  50006. * Initializes the behavior
  50007. */
  50008. init(): void;
  50009. private _closestFace;
  50010. private _zeroVector;
  50011. private _lookAtTmpMatrix;
  50012. private _lookAtToRef;
  50013. /**
  50014. * Attaches the AttachToBoxBehavior to the passed in mesh
  50015. * @param target The mesh that the specified node will be attached to
  50016. */
  50017. attach(target: Mesh): void;
  50018. /**
  50019. * Detaches the behavior from the mesh
  50020. */
  50021. detach(): void;
  50022. }
  50023. }
  50024. declare module BABYLON {
  50025. /**
  50026. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50027. */
  50028. export class FadeInOutBehavior implements Behavior<Mesh> {
  50029. /**
  50030. * Time in milliseconds to delay before fading in (Default: 0)
  50031. */
  50032. delay: number;
  50033. /**
  50034. * Time in milliseconds for the mesh to fade in (Default: 300)
  50035. */
  50036. fadeInTime: number;
  50037. private _millisecondsPerFrame;
  50038. private _hovered;
  50039. private _hoverValue;
  50040. private _ownerNode;
  50041. /**
  50042. * Instatiates the FadeInOutBehavior
  50043. */
  50044. constructor();
  50045. /**
  50046. * The name of the behavior
  50047. */
  50048. get name(): string;
  50049. /**
  50050. * Initializes the behavior
  50051. */
  50052. init(): void;
  50053. /**
  50054. * Attaches the fade behavior on the passed in mesh
  50055. * @param ownerNode The mesh that will be faded in/out once attached
  50056. */
  50057. attach(ownerNode: Mesh): void;
  50058. /**
  50059. * Detaches the behavior from the mesh
  50060. */
  50061. detach(): void;
  50062. /**
  50063. * Triggers the mesh to begin fading in or out
  50064. * @param value if the object should fade in or out (true to fade in)
  50065. */
  50066. fadeIn(value: boolean): void;
  50067. private _update;
  50068. private _setAllVisibility;
  50069. }
  50070. }
  50071. declare module BABYLON {
  50072. /**
  50073. * Class containing a set of static utilities functions for managing Pivots
  50074. * @hidden
  50075. */
  50076. export class PivotTools {
  50077. private static _PivotCached;
  50078. private static _OldPivotPoint;
  50079. private static _PivotTranslation;
  50080. private static _PivotTmpVector;
  50081. private static _PivotPostMultiplyPivotMatrix;
  50082. /** @hidden */
  50083. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50084. /** @hidden */
  50085. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50086. }
  50087. }
  50088. declare module BABYLON {
  50089. /**
  50090. * Class containing static functions to help procedurally build meshes
  50091. */
  50092. export class PlaneBuilder {
  50093. /**
  50094. * Creates a plane mesh
  50095. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50096. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50097. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50099. * * 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
  50100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50101. * @param name defines the name of the mesh
  50102. * @param options defines the options used to create the mesh
  50103. * @param scene defines the hosting scene
  50104. * @returns the plane mesh
  50105. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50106. */
  50107. static CreatePlane(name: string, options: {
  50108. size?: number;
  50109. width?: number;
  50110. height?: number;
  50111. sideOrientation?: number;
  50112. frontUVs?: Vector4;
  50113. backUVs?: Vector4;
  50114. updatable?: boolean;
  50115. sourcePlane?: Plane;
  50116. }, scene?: Nullable<Scene>): Mesh;
  50117. }
  50118. }
  50119. declare module BABYLON {
  50120. /**
  50121. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50122. */
  50123. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50124. private static _AnyMouseID;
  50125. /**
  50126. * Abstract mesh the behavior is set on
  50127. */
  50128. attachedNode: AbstractMesh;
  50129. private _dragPlane;
  50130. private _scene;
  50131. private _pointerObserver;
  50132. private _beforeRenderObserver;
  50133. private static _planeScene;
  50134. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50135. /**
  50136. * 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)
  50137. */
  50138. maxDragAngle: number;
  50139. /**
  50140. * @hidden
  50141. */
  50142. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50143. /**
  50144. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50145. */
  50146. currentDraggingPointerID: number;
  50147. /**
  50148. * The last position where the pointer hit the drag plane in world space
  50149. */
  50150. lastDragPosition: Vector3;
  50151. /**
  50152. * If the behavior is currently in a dragging state
  50153. */
  50154. dragging: boolean;
  50155. /**
  50156. * 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)
  50157. */
  50158. dragDeltaRatio: number;
  50159. /**
  50160. * If the drag plane orientation should be updated during the dragging (Default: true)
  50161. */
  50162. updateDragPlane: boolean;
  50163. private _debugMode;
  50164. private _moving;
  50165. /**
  50166. * Fires each time the attached mesh is dragged with the pointer
  50167. * * delta between last drag position and current drag position in world space
  50168. * * dragDistance along the drag axis
  50169. * * dragPlaneNormal normal of the current drag plane used during the drag
  50170. * * dragPlanePoint in world space where the drag intersects the drag plane
  50171. */
  50172. onDragObservable: Observable<{
  50173. delta: Vector3;
  50174. dragPlanePoint: Vector3;
  50175. dragPlaneNormal: Vector3;
  50176. dragDistance: number;
  50177. pointerId: number;
  50178. }>;
  50179. /**
  50180. * Fires each time a drag begins (eg. mouse down on mesh)
  50181. */
  50182. onDragStartObservable: Observable<{
  50183. dragPlanePoint: Vector3;
  50184. pointerId: number;
  50185. }>;
  50186. /**
  50187. * Fires each time a drag ends (eg. mouse release after drag)
  50188. */
  50189. onDragEndObservable: Observable<{
  50190. dragPlanePoint: Vector3;
  50191. pointerId: number;
  50192. }>;
  50193. /**
  50194. * If the attached mesh should be moved when dragged
  50195. */
  50196. moveAttached: boolean;
  50197. /**
  50198. * If the drag behavior will react to drag events (Default: true)
  50199. */
  50200. enabled: boolean;
  50201. /**
  50202. * If pointer events should start and release the drag (Default: true)
  50203. */
  50204. startAndReleaseDragOnPointerEvents: boolean;
  50205. /**
  50206. * If camera controls should be detached during the drag
  50207. */
  50208. detachCameraControls: boolean;
  50209. /**
  50210. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50211. */
  50212. useObjectOrientationForDragging: boolean;
  50213. private _options;
  50214. /**
  50215. * Gets the options used by the behavior
  50216. */
  50217. get options(): {
  50218. dragAxis?: Vector3;
  50219. dragPlaneNormal?: Vector3;
  50220. };
  50221. /**
  50222. * Sets the options used by the behavior
  50223. */
  50224. set options(options: {
  50225. dragAxis?: Vector3;
  50226. dragPlaneNormal?: Vector3;
  50227. });
  50228. /**
  50229. * Creates a pointer drag behavior that can be attached to a mesh
  50230. * @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)
  50231. */
  50232. constructor(options?: {
  50233. dragAxis?: Vector3;
  50234. dragPlaneNormal?: Vector3;
  50235. });
  50236. /**
  50237. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50238. */
  50239. validateDrag: (targetPosition: Vector3) => boolean;
  50240. /**
  50241. * The name of the behavior
  50242. */
  50243. get name(): string;
  50244. /**
  50245. * Initializes the behavior
  50246. */
  50247. init(): void;
  50248. private _tmpVector;
  50249. private _alternatePickedPoint;
  50250. private _worldDragAxis;
  50251. private _targetPosition;
  50252. private _attachedToElement;
  50253. /**
  50254. * Attaches the drag behavior the passed in mesh
  50255. * @param ownerNode The mesh that will be dragged around once attached
  50256. * @param predicate Predicate to use for pick filtering
  50257. */
  50258. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50259. /**
  50260. * Force relase the drag action by code.
  50261. */
  50262. releaseDrag(): void;
  50263. private _startDragRay;
  50264. private _lastPointerRay;
  50265. /**
  50266. * Simulates the start of a pointer drag event on the behavior
  50267. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50268. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50269. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50270. */
  50271. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50272. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50273. private _dragDelta;
  50274. protected _moveDrag(ray: Ray): void;
  50275. private _pickWithRayOnDragPlane;
  50276. private _pointA;
  50277. private _pointC;
  50278. private _localAxis;
  50279. private _lookAt;
  50280. private _updateDragPlanePosition;
  50281. /**
  50282. * Detaches the behavior from the mesh
  50283. */
  50284. detach(): void;
  50285. }
  50286. }
  50287. declare module BABYLON {
  50288. /**
  50289. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50290. */
  50291. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50292. private _dragBehaviorA;
  50293. private _dragBehaviorB;
  50294. private _startDistance;
  50295. private _initialScale;
  50296. private _targetScale;
  50297. private _ownerNode;
  50298. private _sceneRenderObserver;
  50299. /**
  50300. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50301. */
  50302. constructor();
  50303. /**
  50304. * The name of the behavior
  50305. */
  50306. get name(): string;
  50307. /**
  50308. * Initializes the behavior
  50309. */
  50310. init(): void;
  50311. private _getCurrentDistance;
  50312. /**
  50313. * Attaches the scale behavior the passed in mesh
  50314. * @param ownerNode The mesh that will be scaled around once attached
  50315. */
  50316. attach(ownerNode: Mesh): void;
  50317. /**
  50318. * Detaches the behavior from the mesh
  50319. */
  50320. detach(): void;
  50321. }
  50322. }
  50323. declare module BABYLON {
  50324. /**
  50325. * 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
  50326. */
  50327. export class SixDofDragBehavior implements Behavior<Mesh> {
  50328. private static _virtualScene;
  50329. private _ownerNode;
  50330. private _sceneRenderObserver;
  50331. private _scene;
  50332. private _targetPosition;
  50333. private _virtualOriginMesh;
  50334. private _virtualDragMesh;
  50335. private _pointerObserver;
  50336. private _moving;
  50337. private _startingOrientation;
  50338. private _attachedToElement;
  50339. /**
  50340. * 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)
  50341. */
  50342. private zDragFactor;
  50343. /**
  50344. * If the object should rotate to face the drag origin
  50345. */
  50346. rotateDraggedObject: boolean;
  50347. /**
  50348. * If the behavior is currently in a dragging state
  50349. */
  50350. dragging: boolean;
  50351. /**
  50352. * 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)
  50353. */
  50354. dragDeltaRatio: number;
  50355. /**
  50356. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50357. */
  50358. currentDraggingPointerID: number;
  50359. /**
  50360. * If camera controls should be detached during the drag
  50361. */
  50362. detachCameraControls: boolean;
  50363. /**
  50364. * Fires each time a drag starts
  50365. */
  50366. onDragStartObservable: Observable<{}>;
  50367. /**
  50368. * Fires each time a drag happens
  50369. */
  50370. onDragObservable: Observable<void>;
  50371. /**
  50372. * Fires each time a drag ends (eg. mouse release after drag)
  50373. */
  50374. onDragEndObservable: Observable<{}>;
  50375. /**
  50376. * 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
  50377. */
  50378. constructor();
  50379. /**
  50380. * The name of the behavior
  50381. */
  50382. get name(): string;
  50383. /**
  50384. * Initializes the behavior
  50385. */
  50386. init(): void;
  50387. /**
  50388. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50389. */
  50390. private get _pointerCamera();
  50391. /**
  50392. * Attaches the scale behavior the passed in mesh
  50393. * @param ownerNode The mesh that will be scaled around once attached
  50394. */
  50395. attach(ownerNode: Mesh): void;
  50396. /**
  50397. * Detaches the behavior from the mesh
  50398. */
  50399. detach(): void;
  50400. }
  50401. }
  50402. declare module BABYLON {
  50403. /**
  50404. * Class used to apply inverse kinematics to bones
  50405. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50406. */
  50407. export class BoneIKController {
  50408. private static _tmpVecs;
  50409. private static _tmpQuat;
  50410. private static _tmpMats;
  50411. /**
  50412. * Gets or sets the target mesh
  50413. */
  50414. targetMesh: AbstractMesh;
  50415. /** Gets or sets the mesh used as pole */
  50416. poleTargetMesh: AbstractMesh;
  50417. /**
  50418. * Gets or sets the bone used as pole
  50419. */
  50420. poleTargetBone: Nullable<Bone>;
  50421. /**
  50422. * Gets or sets the target position
  50423. */
  50424. targetPosition: Vector3;
  50425. /**
  50426. * Gets or sets the pole target position
  50427. */
  50428. poleTargetPosition: Vector3;
  50429. /**
  50430. * Gets or sets the pole target local offset
  50431. */
  50432. poleTargetLocalOffset: Vector3;
  50433. /**
  50434. * Gets or sets the pole angle
  50435. */
  50436. poleAngle: number;
  50437. /**
  50438. * Gets or sets the mesh associated with the controller
  50439. */
  50440. mesh: AbstractMesh;
  50441. /**
  50442. * 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)
  50443. */
  50444. slerpAmount: number;
  50445. private _bone1Quat;
  50446. private _bone1Mat;
  50447. private _bone2Ang;
  50448. private _bone1;
  50449. private _bone2;
  50450. private _bone1Length;
  50451. private _bone2Length;
  50452. private _maxAngle;
  50453. private _maxReach;
  50454. private _rightHandedSystem;
  50455. private _bendAxis;
  50456. private _slerping;
  50457. private _adjustRoll;
  50458. /**
  50459. * Gets or sets maximum allowed angle
  50460. */
  50461. get maxAngle(): number;
  50462. set maxAngle(value: number);
  50463. /**
  50464. * Creates a new BoneIKController
  50465. * @param mesh defines the mesh to control
  50466. * @param bone defines the bone to control
  50467. * @param options defines options to set up the controller
  50468. */
  50469. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50470. targetMesh?: AbstractMesh;
  50471. poleTargetMesh?: AbstractMesh;
  50472. poleTargetBone?: Bone;
  50473. poleTargetLocalOffset?: Vector3;
  50474. poleAngle?: number;
  50475. bendAxis?: Vector3;
  50476. maxAngle?: number;
  50477. slerpAmount?: number;
  50478. });
  50479. private _setMaxAngle;
  50480. /**
  50481. * Force the controller to update the bones
  50482. */
  50483. update(): void;
  50484. }
  50485. }
  50486. declare module BABYLON {
  50487. /**
  50488. * Class used to make a bone look toward a point in space
  50489. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50490. */
  50491. export class BoneLookController {
  50492. private static _tmpVecs;
  50493. private static _tmpQuat;
  50494. private static _tmpMats;
  50495. /**
  50496. * The target Vector3 that the bone will look at
  50497. */
  50498. target: Vector3;
  50499. /**
  50500. * The mesh that the bone is attached to
  50501. */
  50502. mesh: AbstractMesh;
  50503. /**
  50504. * The bone that will be looking to the target
  50505. */
  50506. bone: Bone;
  50507. /**
  50508. * The up axis of the coordinate system that is used when the bone is rotated
  50509. */
  50510. upAxis: Vector3;
  50511. /**
  50512. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50513. */
  50514. upAxisSpace: Space;
  50515. /**
  50516. * Used to make an adjustment to the yaw of the bone
  50517. */
  50518. adjustYaw: number;
  50519. /**
  50520. * Used to make an adjustment to the pitch of the bone
  50521. */
  50522. adjustPitch: number;
  50523. /**
  50524. * Used to make an adjustment to the roll of the bone
  50525. */
  50526. adjustRoll: number;
  50527. /**
  50528. * 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)
  50529. */
  50530. slerpAmount: number;
  50531. private _minYaw;
  50532. private _maxYaw;
  50533. private _minPitch;
  50534. private _maxPitch;
  50535. private _minYawSin;
  50536. private _minYawCos;
  50537. private _maxYawSin;
  50538. private _maxYawCos;
  50539. private _midYawConstraint;
  50540. private _minPitchTan;
  50541. private _maxPitchTan;
  50542. private _boneQuat;
  50543. private _slerping;
  50544. private _transformYawPitch;
  50545. private _transformYawPitchInv;
  50546. private _firstFrameSkipped;
  50547. private _yawRange;
  50548. private _fowardAxis;
  50549. /**
  50550. * Gets or sets the minimum yaw angle that the bone can look to
  50551. */
  50552. get minYaw(): number;
  50553. set minYaw(value: number);
  50554. /**
  50555. * Gets or sets the maximum yaw angle that the bone can look to
  50556. */
  50557. get maxYaw(): number;
  50558. set maxYaw(value: number);
  50559. /**
  50560. * Gets or sets the minimum pitch angle that the bone can look to
  50561. */
  50562. get minPitch(): number;
  50563. set minPitch(value: number);
  50564. /**
  50565. * Gets or sets the maximum pitch angle that the bone can look to
  50566. */
  50567. get maxPitch(): number;
  50568. set maxPitch(value: number);
  50569. /**
  50570. * Create a BoneLookController
  50571. * @param mesh the mesh that the bone belongs to
  50572. * @param bone the bone that will be looking to the target
  50573. * @param target the target Vector3 to look at
  50574. * @param options optional settings:
  50575. * * maxYaw: the maximum angle the bone will yaw to
  50576. * * minYaw: the minimum angle the bone will yaw to
  50577. * * maxPitch: the maximum angle the bone will pitch to
  50578. * * minPitch: the minimum angle the bone will yaw to
  50579. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50580. * * upAxis: the up axis of the coordinate system
  50581. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50582. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50583. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50584. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50585. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50586. * * adjustRoll: used to make an adjustment to the roll of the bone
  50587. **/
  50588. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50589. maxYaw?: number;
  50590. minYaw?: number;
  50591. maxPitch?: number;
  50592. minPitch?: number;
  50593. slerpAmount?: number;
  50594. upAxis?: Vector3;
  50595. upAxisSpace?: Space;
  50596. yawAxis?: Vector3;
  50597. pitchAxis?: Vector3;
  50598. adjustYaw?: number;
  50599. adjustPitch?: number;
  50600. adjustRoll?: number;
  50601. });
  50602. /**
  50603. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50604. */
  50605. update(): void;
  50606. private _getAngleDiff;
  50607. private _getAngleBetween;
  50608. private _isAngleBetween;
  50609. }
  50610. }
  50611. declare module BABYLON {
  50612. /**
  50613. * Manage the gamepad inputs to control an arc rotate camera.
  50614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50615. */
  50616. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50617. /**
  50618. * Defines the camera the input is attached to.
  50619. */
  50620. camera: ArcRotateCamera;
  50621. /**
  50622. * Defines the gamepad the input is gathering event from.
  50623. */
  50624. gamepad: Nullable<Gamepad>;
  50625. /**
  50626. * Defines the gamepad rotation sensiblity.
  50627. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50628. */
  50629. gamepadRotationSensibility: number;
  50630. /**
  50631. * Defines the gamepad move sensiblity.
  50632. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50633. */
  50634. gamepadMoveSensibility: number;
  50635. private _yAxisScale;
  50636. /**
  50637. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50638. */
  50639. get invertYAxis(): boolean;
  50640. set invertYAxis(value: boolean);
  50641. private _onGamepadConnectedObserver;
  50642. private _onGamepadDisconnectedObserver;
  50643. /**
  50644. * Attach the input controls to a specific dom element to get the input from.
  50645. */
  50646. attachControl(): void;
  50647. /**
  50648. * Detach the current controls from the specified dom element.
  50649. */
  50650. detachControl(): void;
  50651. /**
  50652. * Update the current camera state depending on the inputs that have been used this frame.
  50653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50654. */
  50655. checkInputs(): void;
  50656. /**
  50657. * Gets the class name of the current intput.
  50658. * @returns the class name
  50659. */
  50660. getClassName(): string;
  50661. /**
  50662. * Get the friendly name associated with the input class.
  50663. * @returns the input friendly name
  50664. */
  50665. getSimpleName(): string;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. interface ArcRotateCameraInputsManager {
  50670. /**
  50671. * Add orientation input support to the input manager.
  50672. * @returns the current input manager
  50673. */
  50674. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50675. }
  50676. /**
  50677. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50678. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50679. */
  50680. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50681. /**
  50682. * Defines the camera the input is attached to.
  50683. */
  50684. camera: ArcRotateCamera;
  50685. /**
  50686. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50687. */
  50688. alphaCorrection: number;
  50689. /**
  50690. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50691. */
  50692. gammaCorrection: number;
  50693. private _alpha;
  50694. private _gamma;
  50695. private _dirty;
  50696. private _deviceOrientationHandler;
  50697. /**
  50698. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50699. */
  50700. constructor();
  50701. /**
  50702. * Attach the input controls to a specific dom element to get the input from.
  50703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50704. */
  50705. attachControl(noPreventDefault?: boolean): void;
  50706. /** @hidden */
  50707. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50708. /**
  50709. * Update the current camera state depending on the inputs that have been used this frame.
  50710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50711. */
  50712. checkInputs(): void;
  50713. /**
  50714. * Detach the current controls from the specified dom element.
  50715. */
  50716. detachControl(): void;
  50717. /**
  50718. * Gets the class name of the current intput.
  50719. * @returns the class name
  50720. */
  50721. getClassName(): string;
  50722. /**
  50723. * Get the friendly name associated with the input class.
  50724. * @returns the input friendly name
  50725. */
  50726. getSimpleName(): string;
  50727. }
  50728. }
  50729. declare module BABYLON {
  50730. /**
  50731. * Listen to mouse events to control the camera.
  50732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50733. */
  50734. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50735. /**
  50736. * Defines the camera the input is attached to.
  50737. */
  50738. camera: FlyCamera;
  50739. /**
  50740. * Defines if touch is enabled. (Default is true.)
  50741. */
  50742. touchEnabled: boolean;
  50743. /**
  50744. * Defines the buttons associated with the input to handle camera rotation.
  50745. */
  50746. buttons: number[];
  50747. /**
  50748. * Assign buttons for Yaw control.
  50749. */
  50750. buttonsYaw: number[];
  50751. /**
  50752. * Assign buttons for Pitch control.
  50753. */
  50754. buttonsPitch: number[];
  50755. /**
  50756. * Assign buttons for Roll control.
  50757. */
  50758. buttonsRoll: number[];
  50759. /**
  50760. * Detect if any button is being pressed while mouse is moved.
  50761. * -1 = Mouse locked.
  50762. * 0 = Left button.
  50763. * 1 = Middle Button.
  50764. * 2 = Right Button.
  50765. */
  50766. activeButton: number;
  50767. /**
  50768. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50769. * Higher values reduce its sensitivity.
  50770. */
  50771. angularSensibility: number;
  50772. private _observer;
  50773. private _rollObserver;
  50774. private previousPosition;
  50775. private noPreventDefault;
  50776. private element;
  50777. /**
  50778. * Listen to mouse events to control the camera.
  50779. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50781. */
  50782. constructor(touchEnabled?: boolean);
  50783. /**
  50784. * Attach the mouse control to the HTML DOM element.
  50785. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50786. */
  50787. attachControl(noPreventDefault?: boolean): void;
  50788. /**
  50789. * Detach the current controls from the specified dom element.
  50790. */
  50791. detachControl(): void;
  50792. /**
  50793. * Gets the class name of the current input.
  50794. * @returns the class name.
  50795. */
  50796. getClassName(): string;
  50797. /**
  50798. * Get the friendly name associated with the input class.
  50799. * @returns the input's friendly name.
  50800. */
  50801. getSimpleName(): string;
  50802. private _pointerInput;
  50803. private _onMouseMove;
  50804. /**
  50805. * Rotate camera by mouse offset.
  50806. */
  50807. private rotateCamera;
  50808. }
  50809. }
  50810. declare module BABYLON {
  50811. /**
  50812. * Default Inputs manager for the FlyCamera.
  50813. * It groups all the default supported inputs for ease of use.
  50814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50815. */
  50816. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50817. /**
  50818. * Instantiates a new FlyCameraInputsManager.
  50819. * @param camera Defines the camera the inputs belong to.
  50820. */
  50821. constructor(camera: FlyCamera);
  50822. /**
  50823. * Add keyboard input support to the input manager.
  50824. * @returns the new FlyCameraKeyboardMoveInput().
  50825. */
  50826. addKeyboard(): FlyCameraInputsManager;
  50827. /**
  50828. * Add mouse input support to the input manager.
  50829. * @param touchEnabled Enable touch screen support.
  50830. * @returns the new FlyCameraMouseInput().
  50831. */
  50832. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50833. }
  50834. }
  50835. declare module BABYLON {
  50836. /**
  50837. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50838. * such as in a 3D Space Shooter or a Flight Simulator.
  50839. */
  50840. export class FlyCamera extends TargetCamera {
  50841. /**
  50842. * Define the collision ellipsoid of the camera.
  50843. * This is helpful for simulating a camera body, like a player's body.
  50844. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50845. */
  50846. ellipsoid: Vector3;
  50847. /**
  50848. * Define an offset for the position of the ellipsoid around the camera.
  50849. * This can be helpful if the camera is attached away from the player's body center,
  50850. * such as at its head.
  50851. */
  50852. ellipsoidOffset: Vector3;
  50853. /**
  50854. * Enable or disable collisions of the camera with the rest of the scene objects.
  50855. */
  50856. checkCollisions: boolean;
  50857. /**
  50858. * Enable or disable gravity on the camera.
  50859. */
  50860. applyGravity: boolean;
  50861. /**
  50862. * Define the current direction the camera is moving to.
  50863. */
  50864. cameraDirection: Vector3;
  50865. /**
  50866. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50867. * This overrides and empties cameraRotation.
  50868. */
  50869. rotationQuaternion: Quaternion;
  50870. /**
  50871. * Track Roll to maintain the wanted Rolling when looking around.
  50872. */
  50873. _trackRoll: number;
  50874. /**
  50875. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50876. */
  50877. rollCorrect: number;
  50878. /**
  50879. * Mimic a banked turn, Rolling the camera when Yawing.
  50880. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50881. */
  50882. bankedTurn: boolean;
  50883. /**
  50884. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50885. */
  50886. bankedTurnLimit: number;
  50887. /**
  50888. * Value of 0 disables the banked Roll.
  50889. * Value of 1 is equal to the Yaw angle in radians.
  50890. */
  50891. bankedTurnMultiplier: number;
  50892. /**
  50893. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50894. */
  50895. inputs: FlyCameraInputsManager;
  50896. /**
  50897. * Gets the input sensibility for mouse input.
  50898. * Higher values reduce sensitivity.
  50899. */
  50900. get angularSensibility(): number;
  50901. /**
  50902. * Sets the input sensibility for a mouse input.
  50903. * Higher values reduce sensitivity.
  50904. */
  50905. set angularSensibility(value: number);
  50906. /**
  50907. * Get the keys for camera movement forward.
  50908. */
  50909. get keysForward(): number[];
  50910. /**
  50911. * Set the keys for camera movement forward.
  50912. */
  50913. set keysForward(value: number[]);
  50914. /**
  50915. * Get the keys for camera movement backward.
  50916. */
  50917. get keysBackward(): number[];
  50918. set keysBackward(value: number[]);
  50919. /**
  50920. * Get the keys for camera movement up.
  50921. */
  50922. get keysUp(): number[];
  50923. /**
  50924. * Set the keys for camera movement up.
  50925. */
  50926. set keysUp(value: number[]);
  50927. /**
  50928. * Get the keys for camera movement down.
  50929. */
  50930. get keysDown(): number[];
  50931. /**
  50932. * Set the keys for camera movement down.
  50933. */
  50934. set keysDown(value: number[]);
  50935. /**
  50936. * Get the keys for camera movement left.
  50937. */
  50938. get keysLeft(): number[];
  50939. /**
  50940. * Set the keys for camera movement left.
  50941. */
  50942. set keysLeft(value: number[]);
  50943. /**
  50944. * Set the keys for camera movement right.
  50945. */
  50946. get keysRight(): number[];
  50947. /**
  50948. * Set the keys for camera movement right.
  50949. */
  50950. set keysRight(value: number[]);
  50951. /**
  50952. * Event raised when the camera collides with a mesh in the scene.
  50953. */
  50954. onCollide: (collidedMesh: AbstractMesh) => void;
  50955. private _collider;
  50956. private _needMoveForGravity;
  50957. private _oldPosition;
  50958. private _diffPosition;
  50959. private _newPosition;
  50960. /** @hidden */
  50961. _localDirection: Vector3;
  50962. /** @hidden */
  50963. _transformedDirection: Vector3;
  50964. /**
  50965. * Instantiates a FlyCamera.
  50966. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50967. * such as in a 3D Space Shooter or a Flight Simulator.
  50968. * @param name Define the name of the camera in the scene.
  50969. * @param position Define the starting position of the camera in the scene.
  50970. * @param scene Define the scene the camera belongs to.
  50971. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50972. */
  50973. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50974. /**
  50975. * Attach the input controls to a specific dom element to get the input from.
  50976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50977. */
  50978. attachControl(noPreventDefault?: boolean): void;
  50979. /**
  50980. * Detach a control from the HTML DOM element.
  50981. * The camera will stop reacting to that input.
  50982. */
  50983. detachControl(): void;
  50984. private _collisionMask;
  50985. /**
  50986. * Get the mask that the camera ignores in collision events.
  50987. */
  50988. get collisionMask(): number;
  50989. /**
  50990. * Set the mask that the camera ignores in collision events.
  50991. */
  50992. set collisionMask(mask: number);
  50993. /** @hidden */
  50994. _collideWithWorld(displacement: Vector3): void;
  50995. /** @hidden */
  50996. private _onCollisionPositionChange;
  50997. /** @hidden */
  50998. _checkInputs(): void;
  50999. /** @hidden */
  51000. _decideIfNeedsToMove(): boolean;
  51001. /** @hidden */
  51002. _updatePosition(): void;
  51003. /**
  51004. * Restore the Roll to its target value at the rate specified.
  51005. * @param rate - Higher means slower restoring.
  51006. * @hidden
  51007. */
  51008. restoreRoll(rate: number): void;
  51009. /**
  51010. * Destroy the camera and release the current resources held by it.
  51011. */
  51012. dispose(): void;
  51013. /**
  51014. * Get the current object class name.
  51015. * @returns the class name.
  51016. */
  51017. getClassName(): string;
  51018. }
  51019. }
  51020. declare module BABYLON {
  51021. /**
  51022. * Listen to keyboard events to control the camera.
  51023. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51024. */
  51025. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51026. /**
  51027. * Defines the camera the input is attached to.
  51028. */
  51029. camera: FlyCamera;
  51030. /**
  51031. * The list of keyboard keys used to control the forward move of the camera.
  51032. */
  51033. keysForward: number[];
  51034. /**
  51035. * The list of keyboard keys used to control the backward move of the camera.
  51036. */
  51037. keysBackward: number[];
  51038. /**
  51039. * The list of keyboard keys used to control the forward move of the camera.
  51040. */
  51041. keysUp: number[];
  51042. /**
  51043. * The list of keyboard keys used to control the backward move of the camera.
  51044. */
  51045. keysDown: number[];
  51046. /**
  51047. * The list of keyboard keys used to control the right strafe move of the camera.
  51048. */
  51049. keysRight: number[];
  51050. /**
  51051. * The list of keyboard keys used to control the left strafe move of the camera.
  51052. */
  51053. keysLeft: number[];
  51054. private _keys;
  51055. private _onCanvasBlurObserver;
  51056. private _onKeyboardObserver;
  51057. private _engine;
  51058. private _scene;
  51059. /**
  51060. * Attach the input controls to a specific dom element to get the input from.
  51061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51062. */
  51063. attachControl(noPreventDefault?: boolean): void;
  51064. /**
  51065. * Detach the current controls from the specified dom element.
  51066. */
  51067. detachControl(): void;
  51068. /**
  51069. * Gets the class name of the current intput.
  51070. * @returns the class name
  51071. */
  51072. getClassName(): string;
  51073. /** @hidden */
  51074. _onLostFocus(e: FocusEvent): void;
  51075. /**
  51076. * Get the friendly name associated with the input class.
  51077. * @returns the input friendly name
  51078. */
  51079. getSimpleName(): string;
  51080. /**
  51081. * Update the current camera state depending on the inputs that have been used this frame.
  51082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51083. */
  51084. checkInputs(): void;
  51085. }
  51086. }
  51087. declare module BABYLON {
  51088. /**
  51089. * Manage the mouse wheel inputs to control a follow camera.
  51090. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51091. */
  51092. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51093. /**
  51094. * Defines the camera the input is attached to.
  51095. */
  51096. camera: FollowCamera;
  51097. /**
  51098. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51099. */
  51100. axisControlRadius: boolean;
  51101. /**
  51102. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51103. */
  51104. axisControlHeight: boolean;
  51105. /**
  51106. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51107. */
  51108. axisControlRotation: boolean;
  51109. /**
  51110. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51111. * relation to mouseWheel events.
  51112. */
  51113. wheelPrecision: number;
  51114. /**
  51115. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51116. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51117. */
  51118. wheelDeltaPercentage: number;
  51119. private _wheel;
  51120. private _observer;
  51121. /**
  51122. * Attach the input controls to a specific dom element to get the input from.
  51123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51124. */
  51125. attachControl(noPreventDefault?: boolean): void;
  51126. /**
  51127. * Detach the current controls from the specified dom element.
  51128. */
  51129. detachControl(): void;
  51130. /**
  51131. * Gets the class name of the current intput.
  51132. * @returns the class name
  51133. */
  51134. getClassName(): string;
  51135. /**
  51136. * Get the friendly name associated with the input class.
  51137. * @returns the input friendly name
  51138. */
  51139. getSimpleName(): string;
  51140. }
  51141. }
  51142. declare module BABYLON {
  51143. /**
  51144. * Manage the pointers inputs to control an follow camera.
  51145. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51146. */
  51147. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51148. /**
  51149. * Defines the camera the input is attached to.
  51150. */
  51151. camera: FollowCamera;
  51152. /**
  51153. * Gets the class name of the current input.
  51154. * @returns the class name
  51155. */
  51156. getClassName(): string;
  51157. /**
  51158. * Defines the pointer angular sensibility along the X axis or how fast is
  51159. * the camera rotating.
  51160. * A negative number will reverse the axis direction.
  51161. */
  51162. angularSensibilityX: number;
  51163. /**
  51164. * Defines the pointer angular sensibility along the Y axis or how fast is
  51165. * the camera rotating.
  51166. * A negative number will reverse the axis direction.
  51167. */
  51168. angularSensibilityY: number;
  51169. /**
  51170. * Defines the pointer pinch precision or how fast is the camera zooming.
  51171. * A negative number will reverse the axis direction.
  51172. */
  51173. pinchPrecision: number;
  51174. /**
  51175. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51176. * from 0.
  51177. * It defines the percentage of current camera.radius to use as delta when
  51178. * pinch zoom is used.
  51179. */
  51180. pinchDeltaPercentage: number;
  51181. /**
  51182. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51183. */
  51184. axisXControlRadius: boolean;
  51185. /**
  51186. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51187. */
  51188. axisXControlHeight: boolean;
  51189. /**
  51190. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51191. */
  51192. axisXControlRotation: boolean;
  51193. /**
  51194. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51195. */
  51196. axisYControlRadius: boolean;
  51197. /**
  51198. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51199. */
  51200. axisYControlHeight: boolean;
  51201. /**
  51202. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51203. */
  51204. axisYControlRotation: boolean;
  51205. /**
  51206. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51207. */
  51208. axisPinchControlRadius: boolean;
  51209. /**
  51210. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51211. */
  51212. axisPinchControlHeight: boolean;
  51213. /**
  51214. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51215. */
  51216. axisPinchControlRotation: boolean;
  51217. /**
  51218. * Log error messages if basic misconfiguration has occurred.
  51219. */
  51220. warningEnable: boolean;
  51221. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51222. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51223. private _warningCounter;
  51224. private _warning;
  51225. }
  51226. }
  51227. declare module BABYLON {
  51228. /**
  51229. * Default Inputs manager for the FollowCamera.
  51230. * It groups all the default supported inputs for ease of use.
  51231. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51232. */
  51233. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51234. /**
  51235. * Instantiates a new FollowCameraInputsManager.
  51236. * @param camera Defines the camera the inputs belong to
  51237. */
  51238. constructor(camera: FollowCamera);
  51239. /**
  51240. * Add keyboard input support to the input manager.
  51241. * @returns the current input manager
  51242. */
  51243. addKeyboard(): FollowCameraInputsManager;
  51244. /**
  51245. * Add mouse wheel input support to the input manager.
  51246. * @returns the current input manager
  51247. */
  51248. addMouseWheel(): FollowCameraInputsManager;
  51249. /**
  51250. * Add pointers input support to the input manager.
  51251. * @returns the current input manager
  51252. */
  51253. addPointers(): FollowCameraInputsManager;
  51254. /**
  51255. * Add orientation input support to the input manager.
  51256. * @returns the current input manager
  51257. */
  51258. addVRDeviceOrientation(): FollowCameraInputsManager;
  51259. }
  51260. }
  51261. declare module BABYLON {
  51262. /**
  51263. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51264. * an arc rotate version arcFollowCamera are available.
  51265. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51266. */
  51267. export class FollowCamera extends TargetCamera {
  51268. /**
  51269. * Distance the follow camera should follow an object at
  51270. */
  51271. radius: number;
  51272. /**
  51273. * Minimum allowed distance of the camera to the axis of rotation
  51274. * (The camera can not get closer).
  51275. * This can help limiting how the Camera is able to move in the scene.
  51276. */
  51277. lowerRadiusLimit: Nullable<number>;
  51278. /**
  51279. * Maximum allowed distance of the camera to the axis of rotation
  51280. * (The camera can not get further).
  51281. * This can help limiting how the Camera is able to move in the scene.
  51282. */
  51283. upperRadiusLimit: Nullable<number>;
  51284. /**
  51285. * Define a rotation offset between the camera and the object it follows
  51286. */
  51287. rotationOffset: number;
  51288. /**
  51289. * Minimum allowed angle to camera position relative to target object.
  51290. * This can help limiting how the Camera is able to move in the scene.
  51291. */
  51292. lowerRotationOffsetLimit: Nullable<number>;
  51293. /**
  51294. * Maximum allowed angle to camera position relative to target object.
  51295. * This can help limiting how the Camera is able to move in the scene.
  51296. */
  51297. upperRotationOffsetLimit: Nullable<number>;
  51298. /**
  51299. * Define a height offset between the camera and the object it follows.
  51300. * It can help following an object from the top (like a car chaing a plane)
  51301. */
  51302. heightOffset: number;
  51303. /**
  51304. * Minimum allowed height of camera position relative to target object.
  51305. * This can help limiting how the Camera is able to move in the scene.
  51306. */
  51307. lowerHeightOffsetLimit: Nullable<number>;
  51308. /**
  51309. * Maximum allowed height of camera position relative to target object.
  51310. * This can help limiting how the Camera is able to move in the scene.
  51311. */
  51312. upperHeightOffsetLimit: Nullable<number>;
  51313. /**
  51314. * Define how fast the camera can accelerate to follow it s target.
  51315. */
  51316. cameraAcceleration: number;
  51317. /**
  51318. * Define the speed limit of the camera following an object.
  51319. */
  51320. maxCameraSpeed: number;
  51321. /**
  51322. * Define the target of the camera.
  51323. */
  51324. lockedTarget: Nullable<AbstractMesh>;
  51325. /**
  51326. * Defines the input associated with the camera.
  51327. */
  51328. inputs: FollowCameraInputsManager;
  51329. /**
  51330. * Instantiates the follow camera.
  51331. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51332. * @param name Define the name of the camera in the scene
  51333. * @param position Define the position of the camera
  51334. * @param scene Define the scene the camera belong to
  51335. * @param lockedTarget Define the target of the camera
  51336. */
  51337. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51338. private _follow;
  51339. /**
  51340. * Attach the input controls to a specific dom element to get the input from.
  51341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51342. */
  51343. attachControl(noPreventDefault?: boolean): void;
  51344. /**
  51345. * Detach the current controls from the specified dom element.
  51346. */
  51347. detachControl(): void;
  51348. /** @hidden */
  51349. _checkInputs(): void;
  51350. private _checkLimits;
  51351. /**
  51352. * Gets the camera class name.
  51353. * @returns the class name
  51354. */
  51355. getClassName(): string;
  51356. }
  51357. /**
  51358. * Arc Rotate version of the follow camera.
  51359. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51360. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51361. */
  51362. export class ArcFollowCamera extends TargetCamera {
  51363. /** The longitudinal angle of the camera */
  51364. alpha: number;
  51365. /** The latitudinal angle of the camera */
  51366. beta: number;
  51367. /** The radius of the camera from its target */
  51368. radius: number;
  51369. private _cartesianCoordinates;
  51370. /** Define the camera target (the mesh it should follow) */
  51371. private _meshTarget;
  51372. /**
  51373. * Instantiates a new ArcFollowCamera
  51374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51375. * @param name Define the name of the camera
  51376. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51377. * @param beta Define the rotation angle of the camera around the elevation axis
  51378. * @param radius Define the radius of the camera from its target point
  51379. * @param target Define the target of the camera
  51380. * @param scene Define the scene the camera belongs to
  51381. */
  51382. constructor(name: string,
  51383. /** The longitudinal angle of the camera */
  51384. alpha: number,
  51385. /** The latitudinal angle of the camera */
  51386. beta: number,
  51387. /** The radius of the camera from its target */
  51388. radius: number,
  51389. /** Define the camera target (the mesh it should follow) */
  51390. target: Nullable<AbstractMesh>, scene: Scene);
  51391. private _follow;
  51392. /** @hidden */
  51393. _checkInputs(): void;
  51394. /**
  51395. * Returns the class name of the object.
  51396. * It is mostly used internally for serialization purposes.
  51397. */
  51398. getClassName(): string;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /**
  51403. * Manage the keyboard inputs to control the movement of a follow camera.
  51404. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51405. */
  51406. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51407. /**
  51408. * Defines the camera the input is attached to.
  51409. */
  51410. camera: FollowCamera;
  51411. /**
  51412. * Defines the list of key codes associated with the up action (increase heightOffset)
  51413. */
  51414. keysHeightOffsetIncr: number[];
  51415. /**
  51416. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51417. */
  51418. keysHeightOffsetDecr: number[];
  51419. /**
  51420. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51421. */
  51422. keysHeightOffsetModifierAlt: boolean;
  51423. /**
  51424. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51425. */
  51426. keysHeightOffsetModifierCtrl: boolean;
  51427. /**
  51428. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51429. */
  51430. keysHeightOffsetModifierShift: boolean;
  51431. /**
  51432. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51433. */
  51434. keysRotationOffsetIncr: number[];
  51435. /**
  51436. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51437. */
  51438. keysRotationOffsetDecr: number[];
  51439. /**
  51440. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51441. */
  51442. keysRotationOffsetModifierAlt: boolean;
  51443. /**
  51444. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51445. */
  51446. keysRotationOffsetModifierCtrl: boolean;
  51447. /**
  51448. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51449. */
  51450. keysRotationOffsetModifierShift: boolean;
  51451. /**
  51452. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51453. */
  51454. keysRadiusIncr: number[];
  51455. /**
  51456. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51457. */
  51458. keysRadiusDecr: number[];
  51459. /**
  51460. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51461. */
  51462. keysRadiusModifierAlt: boolean;
  51463. /**
  51464. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51465. */
  51466. keysRadiusModifierCtrl: boolean;
  51467. /**
  51468. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51469. */
  51470. keysRadiusModifierShift: boolean;
  51471. /**
  51472. * Defines the rate of change of heightOffset.
  51473. */
  51474. heightSensibility: number;
  51475. /**
  51476. * Defines the rate of change of rotationOffset.
  51477. */
  51478. rotationSensibility: number;
  51479. /**
  51480. * Defines the rate of change of radius.
  51481. */
  51482. radiusSensibility: number;
  51483. private _keys;
  51484. private _ctrlPressed;
  51485. private _altPressed;
  51486. private _shiftPressed;
  51487. private _onCanvasBlurObserver;
  51488. private _onKeyboardObserver;
  51489. private _engine;
  51490. private _scene;
  51491. /**
  51492. * Attach the input controls to a specific dom element to get the input from.
  51493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51494. */
  51495. attachControl(noPreventDefault?: boolean): void;
  51496. /**
  51497. * Detach the current controls from the specified dom element.
  51498. */
  51499. detachControl(): void;
  51500. /**
  51501. * Update the current camera state depending on the inputs that have been used this frame.
  51502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51503. */
  51504. checkInputs(): void;
  51505. /**
  51506. * Gets the class name of the current input.
  51507. * @returns the class name
  51508. */
  51509. getClassName(): string;
  51510. /**
  51511. * Get the friendly name associated with the input class.
  51512. * @returns the input friendly name
  51513. */
  51514. getSimpleName(): string;
  51515. /**
  51516. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51517. * allow modification of the heightOffset value.
  51518. */
  51519. private _modifierHeightOffset;
  51520. /**
  51521. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51522. * allow modification of the rotationOffset value.
  51523. */
  51524. private _modifierRotationOffset;
  51525. /**
  51526. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51527. * allow modification of the radius value.
  51528. */
  51529. private _modifierRadius;
  51530. }
  51531. }
  51532. declare module BABYLON {
  51533. interface FreeCameraInputsManager {
  51534. /**
  51535. * @hidden
  51536. */
  51537. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51538. /**
  51539. * Add orientation input support to the input manager.
  51540. * @returns the current input manager
  51541. */
  51542. addDeviceOrientation(): FreeCameraInputsManager;
  51543. }
  51544. /**
  51545. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51546. * Screen rotation is taken into account.
  51547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51548. */
  51549. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51550. private _camera;
  51551. private _screenOrientationAngle;
  51552. private _constantTranform;
  51553. private _screenQuaternion;
  51554. private _alpha;
  51555. private _beta;
  51556. private _gamma;
  51557. /**
  51558. * Can be used to detect if a device orientation sensor is available on a device
  51559. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51560. * @returns a promise that will resolve on orientation change
  51561. */
  51562. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51563. /**
  51564. * @hidden
  51565. */
  51566. _onDeviceOrientationChangedObservable: Observable<void>;
  51567. /**
  51568. * Instantiates a new input
  51569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51570. */
  51571. constructor();
  51572. /**
  51573. * Define the camera controlled by the input.
  51574. */
  51575. get camera(): FreeCamera;
  51576. set camera(camera: FreeCamera);
  51577. /**
  51578. * Attach the input controls to a specific dom element to get the input from.
  51579. */
  51580. attachControl(): void;
  51581. private _orientationChanged;
  51582. private _deviceOrientation;
  51583. /**
  51584. * Detach the current controls from the specified dom element.
  51585. */
  51586. detachControl(): void;
  51587. /**
  51588. * Update the current camera state depending on the inputs that have been used this frame.
  51589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51590. */
  51591. checkInputs(): void;
  51592. /**
  51593. * Gets the class name of the current intput.
  51594. * @returns the class name
  51595. */
  51596. getClassName(): string;
  51597. /**
  51598. * Get the friendly name associated with the input class.
  51599. * @returns the input friendly name
  51600. */
  51601. getSimpleName(): string;
  51602. }
  51603. }
  51604. declare module BABYLON {
  51605. /**
  51606. * Manage the gamepad inputs to control a free camera.
  51607. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51608. */
  51609. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51610. /**
  51611. * Define the camera the input is attached to.
  51612. */
  51613. camera: FreeCamera;
  51614. /**
  51615. * Define the Gamepad controlling the input
  51616. */
  51617. gamepad: Nullable<Gamepad>;
  51618. /**
  51619. * Defines the gamepad rotation sensiblity.
  51620. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51621. */
  51622. gamepadAngularSensibility: number;
  51623. /**
  51624. * Defines the gamepad move sensiblity.
  51625. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51626. */
  51627. gamepadMoveSensibility: number;
  51628. private _yAxisScale;
  51629. /**
  51630. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51631. */
  51632. get invertYAxis(): boolean;
  51633. set invertYAxis(value: boolean);
  51634. private _onGamepadConnectedObserver;
  51635. private _onGamepadDisconnectedObserver;
  51636. private _cameraTransform;
  51637. private _deltaTransform;
  51638. private _vector3;
  51639. private _vector2;
  51640. /**
  51641. * Attach the input controls to a specific dom element to get the input from.
  51642. */
  51643. attachControl(): void;
  51644. /**
  51645. * Detach the current controls from the specified dom element.
  51646. */
  51647. detachControl(): void;
  51648. /**
  51649. * Update the current camera state depending on the inputs that have been used this frame.
  51650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51651. */
  51652. checkInputs(): void;
  51653. /**
  51654. * Gets the class name of the current intput.
  51655. * @returns the class name
  51656. */
  51657. getClassName(): string;
  51658. /**
  51659. * Get the friendly name associated with the input class.
  51660. * @returns the input friendly name
  51661. */
  51662. getSimpleName(): string;
  51663. }
  51664. }
  51665. declare module BABYLON {
  51666. /**
  51667. * Defines the potential axis of a Joystick
  51668. */
  51669. export enum JoystickAxis {
  51670. /** X axis */
  51671. X = 0,
  51672. /** Y axis */
  51673. Y = 1,
  51674. /** Z axis */
  51675. Z = 2
  51676. }
  51677. /**
  51678. * Represents the different customization options available
  51679. * for VirtualJoystick
  51680. */
  51681. interface VirtualJoystickCustomizations {
  51682. /**
  51683. * Size of the joystick's puck
  51684. */
  51685. puckSize: number;
  51686. /**
  51687. * Size of the joystick's container
  51688. */
  51689. containerSize: number;
  51690. /**
  51691. * Color of the joystick && puck
  51692. */
  51693. color: string;
  51694. /**
  51695. * Image URL for the joystick's puck
  51696. */
  51697. puckImage?: string;
  51698. /**
  51699. * Image URL for the joystick's container
  51700. */
  51701. containerImage?: string;
  51702. /**
  51703. * Defines the unmoving position of the joystick container
  51704. */
  51705. position?: {
  51706. x: number;
  51707. y: number;
  51708. };
  51709. /**
  51710. * Defines whether or not the joystick container is always visible
  51711. */
  51712. alwaysVisible: boolean;
  51713. /**
  51714. * Defines whether or not to limit the movement of the puck to the joystick's container
  51715. */
  51716. limitToContainer: boolean;
  51717. }
  51718. /**
  51719. * Class used to define virtual joystick (used in touch mode)
  51720. */
  51721. export class VirtualJoystick {
  51722. /**
  51723. * Gets or sets a boolean indicating that left and right values must be inverted
  51724. */
  51725. reverseLeftRight: boolean;
  51726. /**
  51727. * Gets or sets a boolean indicating that up and down values must be inverted
  51728. */
  51729. reverseUpDown: boolean;
  51730. /**
  51731. * Gets the offset value for the position (ie. the change of the position value)
  51732. */
  51733. deltaPosition: Vector3;
  51734. /**
  51735. * Gets a boolean indicating if the virtual joystick was pressed
  51736. */
  51737. pressed: boolean;
  51738. /**
  51739. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51740. */
  51741. static Canvas: Nullable<HTMLCanvasElement>;
  51742. /**
  51743. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51744. */
  51745. limitToContainer: boolean;
  51746. private static _globalJoystickIndex;
  51747. private static _alwaysVisibleSticks;
  51748. private static vjCanvasContext;
  51749. private static vjCanvasWidth;
  51750. private static vjCanvasHeight;
  51751. private static halfWidth;
  51752. private static _GetDefaultOptions;
  51753. private _action;
  51754. private _axisTargetedByLeftAndRight;
  51755. private _axisTargetedByUpAndDown;
  51756. private _joystickSensibility;
  51757. private _inversedSensibility;
  51758. private _joystickPointerID;
  51759. private _joystickColor;
  51760. private _joystickPointerPos;
  51761. private _joystickPreviousPointerPos;
  51762. private _joystickPointerStartPos;
  51763. private _deltaJoystickVector;
  51764. private _leftJoystick;
  51765. private _touches;
  51766. private _joystickPosition;
  51767. private _alwaysVisible;
  51768. private _puckImage;
  51769. private _containerImage;
  51770. private _joystickPuckSize;
  51771. private _joystickContainerSize;
  51772. private _clearPuckSize;
  51773. private _clearContainerSize;
  51774. private _clearPuckSizeOffset;
  51775. private _clearContainerSizeOffset;
  51776. private _onPointerDownHandlerRef;
  51777. private _onPointerMoveHandlerRef;
  51778. private _onPointerUpHandlerRef;
  51779. private _onResize;
  51780. /**
  51781. * Creates a new virtual joystick
  51782. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51783. * @param customizations Defines the options we want to customize the VirtualJoystick
  51784. */
  51785. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51786. /**
  51787. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51788. * @param newJoystickSensibility defines the new sensibility
  51789. */
  51790. setJoystickSensibility(newJoystickSensibility: number): void;
  51791. private _onPointerDown;
  51792. private _onPointerMove;
  51793. private _onPointerUp;
  51794. /**
  51795. * Change the color of the virtual joystick
  51796. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51797. */
  51798. setJoystickColor(newColor: string): void;
  51799. /**
  51800. * Size of the joystick's container
  51801. */
  51802. set containerSize(newSize: number);
  51803. get containerSize(): number;
  51804. /**
  51805. * Size of the joystick's puck
  51806. */
  51807. set puckSize(newSize: number);
  51808. get puckSize(): number;
  51809. /**
  51810. * Clears the set position of the joystick
  51811. */
  51812. clearPosition(): void;
  51813. /**
  51814. * Defines whether or not the joystick container is always visible
  51815. */
  51816. set alwaysVisible(value: boolean);
  51817. get alwaysVisible(): boolean;
  51818. /**
  51819. * Sets the constant position of the Joystick container
  51820. * @param x X axis coordinate
  51821. * @param y Y axis coordinate
  51822. */
  51823. setPosition(x: number, y: number): void;
  51824. /**
  51825. * Defines a callback to call when the joystick is touched
  51826. * @param action defines the callback
  51827. */
  51828. setActionOnTouch(action: () => any): void;
  51829. /**
  51830. * Defines which axis you'd like to control for left & right
  51831. * @param axis defines the axis to use
  51832. */
  51833. setAxisForLeftRight(axis: JoystickAxis): void;
  51834. /**
  51835. * Defines which axis you'd like to control for up & down
  51836. * @param axis defines the axis to use
  51837. */
  51838. setAxisForUpDown(axis: JoystickAxis): void;
  51839. /**
  51840. * Clears the canvas from the previous puck / container draw
  51841. */
  51842. private _clearPreviousDraw;
  51843. /**
  51844. * Loads `urlPath` to be used for the container's image
  51845. * @param urlPath defines the urlPath of an image to use
  51846. */
  51847. setContainerImage(urlPath: string): void;
  51848. /**
  51849. * Loads `urlPath` to be used for the puck's image
  51850. * @param urlPath defines the urlPath of an image to use
  51851. */
  51852. setPuckImage(urlPath: string): void;
  51853. /**
  51854. * Draws the Virtual Joystick's container
  51855. */
  51856. private _drawContainer;
  51857. /**
  51858. * Draws the Virtual Joystick's puck
  51859. */
  51860. private _drawPuck;
  51861. private _drawVirtualJoystick;
  51862. /**
  51863. * Release internal HTML canvas
  51864. */
  51865. releaseCanvas(): void;
  51866. }
  51867. }
  51868. declare module BABYLON {
  51869. interface FreeCameraInputsManager {
  51870. /**
  51871. * Add virtual joystick input support to the input manager.
  51872. * @returns the current input manager
  51873. */
  51874. addVirtualJoystick(): FreeCameraInputsManager;
  51875. }
  51876. /**
  51877. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51879. */
  51880. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51881. /**
  51882. * Defines the camera the input is attached to.
  51883. */
  51884. camera: FreeCamera;
  51885. private _leftjoystick;
  51886. private _rightjoystick;
  51887. /**
  51888. * Gets the left stick of the virtual joystick.
  51889. * @returns The virtual Joystick
  51890. */
  51891. getLeftJoystick(): VirtualJoystick;
  51892. /**
  51893. * Gets the right stick of the virtual joystick.
  51894. * @returns The virtual Joystick
  51895. */
  51896. getRightJoystick(): VirtualJoystick;
  51897. /**
  51898. * Update the current camera state depending on the inputs that have been used this frame.
  51899. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51900. */
  51901. checkInputs(): void;
  51902. /**
  51903. * Attach the input controls to a specific dom element to get the input from.
  51904. */
  51905. attachControl(): void;
  51906. /**
  51907. * Detach the current controls from the specified dom element.
  51908. */
  51909. detachControl(): void;
  51910. /**
  51911. * Gets the class name of the current intput.
  51912. * @returns the class name
  51913. */
  51914. getClassName(): string;
  51915. /**
  51916. * Get the friendly name associated with the input class.
  51917. * @returns the input friendly name
  51918. */
  51919. getSimpleName(): string;
  51920. }
  51921. }
  51922. declare module BABYLON {
  51923. /**
  51924. * This represents a FPS type of camera controlled by touch.
  51925. * This is like a universal camera minus the Gamepad controls.
  51926. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51927. */
  51928. export class TouchCamera extends FreeCamera {
  51929. /**
  51930. * Defines the touch sensibility for rotation.
  51931. * The higher the faster.
  51932. */
  51933. get touchAngularSensibility(): number;
  51934. set touchAngularSensibility(value: number);
  51935. /**
  51936. * Defines the touch sensibility for move.
  51937. * The higher the faster.
  51938. */
  51939. get touchMoveSensibility(): number;
  51940. set touchMoveSensibility(value: number);
  51941. /**
  51942. * Instantiates a new touch camera.
  51943. * This represents a FPS type of camera controlled by touch.
  51944. * This is like a universal camera minus the Gamepad controls.
  51945. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51946. * @param name Define the name of the camera in the scene
  51947. * @param position Define the start position of the camera in the scene
  51948. * @param scene Define the scene the camera belongs to
  51949. */
  51950. constructor(name: string, position: Vector3, scene: Scene);
  51951. /**
  51952. * Gets the current object class name.
  51953. * @return the class name
  51954. */
  51955. getClassName(): string;
  51956. /** @hidden */
  51957. _setupInputs(): void;
  51958. }
  51959. }
  51960. declare module BABYLON {
  51961. /**
  51962. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51963. * being tilted forward or back and left or right.
  51964. */
  51965. export class DeviceOrientationCamera extends FreeCamera {
  51966. private _initialQuaternion;
  51967. private _quaternionCache;
  51968. private _tmpDragQuaternion;
  51969. private _disablePointerInputWhenUsingDeviceOrientation;
  51970. /**
  51971. * Creates a new device orientation camera
  51972. * @param name The name of the camera
  51973. * @param position The start position camera
  51974. * @param scene The scene the camera belongs to
  51975. */
  51976. constructor(name: string, position: Vector3, scene: Scene);
  51977. /**
  51978. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51979. */
  51980. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51981. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51982. private _dragFactor;
  51983. /**
  51984. * Enabled turning on the y axis when the orientation sensor is active
  51985. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51986. */
  51987. enableHorizontalDragging(dragFactor?: number): void;
  51988. /**
  51989. * Gets the current instance class name ("DeviceOrientationCamera").
  51990. * This helps avoiding instanceof at run time.
  51991. * @returns the class name
  51992. */
  51993. getClassName(): string;
  51994. /**
  51995. * @hidden
  51996. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51997. */
  51998. _checkInputs(): void;
  51999. /**
  52000. * Reset the camera to its default orientation on the specified axis only.
  52001. * @param axis The axis to reset
  52002. */
  52003. resetToCurrentRotation(axis?: Axis): void;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * Defines supported buttons for XBox360 compatible gamepads
  52009. */
  52010. export enum Xbox360Button {
  52011. /** A */
  52012. A = 0,
  52013. /** B */
  52014. B = 1,
  52015. /** X */
  52016. X = 2,
  52017. /** Y */
  52018. Y = 3,
  52019. /** Left button */
  52020. LB = 4,
  52021. /** Right button */
  52022. RB = 5,
  52023. /** Back */
  52024. Back = 8,
  52025. /** Start */
  52026. Start = 9,
  52027. /** Left stick */
  52028. LeftStick = 10,
  52029. /** Right stick */
  52030. RightStick = 11
  52031. }
  52032. /** Defines values for XBox360 DPad */
  52033. export enum Xbox360Dpad {
  52034. /** Up */
  52035. Up = 12,
  52036. /** Down */
  52037. Down = 13,
  52038. /** Left */
  52039. Left = 14,
  52040. /** Right */
  52041. Right = 15
  52042. }
  52043. /**
  52044. * Defines a XBox360 gamepad
  52045. */
  52046. export class Xbox360Pad extends Gamepad {
  52047. private _leftTrigger;
  52048. private _rightTrigger;
  52049. private _onlefttriggerchanged;
  52050. private _onrighttriggerchanged;
  52051. private _onbuttondown;
  52052. private _onbuttonup;
  52053. private _ondpaddown;
  52054. private _ondpadup;
  52055. /** Observable raised when a button is pressed */
  52056. onButtonDownObservable: Observable<Xbox360Button>;
  52057. /** Observable raised when a button is released */
  52058. onButtonUpObservable: Observable<Xbox360Button>;
  52059. /** Observable raised when a pad is pressed */
  52060. onPadDownObservable: Observable<Xbox360Dpad>;
  52061. /** Observable raised when a pad is released */
  52062. onPadUpObservable: Observable<Xbox360Dpad>;
  52063. private _buttonA;
  52064. private _buttonB;
  52065. private _buttonX;
  52066. private _buttonY;
  52067. private _buttonBack;
  52068. private _buttonStart;
  52069. private _buttonLB;
  52070. private _buttonRB;
  52071. private _buttonLeftStick;
  52072. private _buttonRightStick;
  52073. private _dPadUp;
  52074. private _dPadDown;
  52075. private _dPadLeft;
  52076. private _dPadRight;
  52077. private _isXboxOnePad;
  52078. /**
  52079. * Creates a new XBox360 gamepad object
  52080. * @param id defines the id of this gamepad
  52081. * @param index defines its index
  52082. * @param gamepad defines the internal HTML gamepad object
  52083. * @param xboxOne defines if it is a XBox One gamepad
  52084. */
  52085. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52086. /**
  52087. * Defines the callback to call when left trigger is pressed
  52088. * @param callback defines the callback to use
  52089. */
  52090. onlefttriggerchanged(callback: (value: number) => void): void;
  52091. /**
  52092. * Defines the callback to call when right trigger is pressed
  52093. * @param callback defines the callback to use
  52094. */
  52095. onrighttriggerchanged(callback: (value: number) => void): void;
  52096. /**
  52097. * Gets the left trigger value
  52098. */
  52099. get leftTrigger(): number;
  52100. /**
  52101. * Sets the left trigger value
  52102. */
  52103. set leftTrigger(newValue: number);
  52104. /**
  52105. * Gets the right trigger value
  52106. */
  52107. get rightTrigger(): number;
  52108. /**
  52109. * Sets the right trigger value
  52110. */
  52111. set rightTrigger(newValue: number);
  52112. /**
  52113. * Defines the callback to call when a button is pressed
  52114. * @param callback defines the callback to use
  52115. */
  52116. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52117. /**
  52118. * Defines the callback to call when a button is released
  52119. * @param callback defines the callback to use
  52120. */
  52121. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52122. /**
  52123. * Defines the callback to call when a pad is pressed
  52124. * @param callback defines the callback to use
  52125. */
  52126. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52127. /**
  52128. * Defines the callback to call when a pad is released
  52129. * @param callback defines the callback to use
  52130. */
  52131. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52132. private _setButtonValue;
  52133. private _setDPadValue;
  52134. /**
  52135. * Gets the value of the `A` button
  52136. */
  52137. get buttonA(): number;
  52138. /**
  52139. * Sets the value of the `A` button
  52140. */
  52141. set buttonA(value: number);
  52142. /**
  52143. * Gets the value of the `B` button
  52144. */
  52145. get buttonB(): number;
  52146. /**
  52147. * Sets the value of the `B` button
  52148. */
  52149. set buttonB(value: number);
  52150. /**
  52151. * Gets the value of the `X` button
  52152. */
  52153. get buttonX(): number;
  52154. /**
  52155. * Sets the value of the `X` button
  52156. */
  52157. set buttonX(value: number);
  52158. /**
  52159. * Gets the value of the `Y` button
  52160. */
  52161. get buttonY(): number;
  52162. /**
  52163. * Sets the value of the `Y` button
  52164. */
  52165. set buttonY(value: number);
  52166. /**
  52167. * Gets the value of the `Start` button
  52168. */
  52169. get buttonStart(): number;
  52170. /**
  52171. * Sets the value of the `Start` button
  52172. */
  52173. set buttonStart(value: number);
  52174. /**
  52175. * Gets the value of the `Back` button
  52176. */
  52177. get buttonBack(): number;
  52178. /**
  52179. * Sets the value of the `Back` button
  52180. */
  52181. set buttonBack(value: number);
  52182. /**
  52183. * Gets the value of the `Left` button
  52184. */
  52185. get buttonLB(): number;
  52186. /**
  52187. * Sets the value of the `Left` button
  52188. */
  52189. set buttonLB(value: number);
  52190. /**
  52191. * Gets the value of the `Right` button
  52192. */
  52193. get buttonRB(): number;
  52194. /**
  52195. * Sets the value of the `Right` button
  52196. */
  52197. set buttonRB(value: number);
  52198. /**
  52199. * Gets the value of the Left joystick
  52200. */
  52201. get buttonLeftStick(): number;
  52202. /**
  52203. * Sets the value of the Left joystick
  52204. */
  52205. set buttonLeftStick(value: number);
  52206. /**
  52207. * Gets the value of the Right joystick
  52208. */
  52209. get buttonRightStick(): number;
  52210. /**
  52211. * Sets the value of the Right joystick
  52212. */
  52213. set buttonRightStick(value: number);
  52214. /**
  52215. * Gets the value of D-pad up
  52216. */
  52217. get dPadUp(): number;
  52218. /**
  52219. * Sets the value of D-pad up
  52220. */
  52221. set dPadUp(value: number);
  52222. /**
  52223. * Gets the value of D-pad down
  52224. */
  52225. get dPadDown(): number;
  52226. /**
  52227. * Sets the value of D-pad down
  52228. */
  52229. set dPadDown(value: number);
  52230. /**
  52231. * Gets the value of D-pad left
  52232. */
  52233. get dPadLeft(): number;
  52234. /**
  52235. * Sets the value of D-pad left
  52236. */
  52237. set dPadLeft(value: number);
  52238. /**
  52239. * Gets the value of D-pad right
  52240. */
  52241. get dPadRight(): number;
  52242. /**
  52243. * Sets the value of D-pad right
  52244. */
  52245. set dPadRight(value: number);
  52246. /**
  52247. * Force the gamepad to synchronize with device values
  52248. */
  52249. update(): void;
  52250. /**
  52251. * Disposes the gamepad
  52252. */
  52253. dispose(): void;
  52254. }
  52255. }
  52256. declare module BABYLON {
  52257. /**
  52258. * Defines supported buttons for DualShock compatible gamepads
  52259. */
  52260. export enum DualShockButton {
  52261. /** Cross */
  52262. Cross = 0,
  52263. /** Circle */
  52264. Circle = 1,
  52265. /** Square */
  52266. Square = 2,
  52267. /** Triangle */
  52268. Triangle = 3,
  52269. /** L1 */
  52270. L1 = 4,
  52271. /** R1 */
  52272. R1 = 5,
  52273. /** Share */
  52274. Share = 8,
  52275. /** Options */
  52276. Options = 9,
  52277. /** Left stick */
  52278. LeftStick = 10,
  52279. /** Right stick */
  52280. RightStick = 11
  52281. }
  52282. /** Defines values for DualShock DPad */
  52283. export enum DualShockDpad {
  52284. /** Up */
  52285. Up = 12,
  52286. /** Down */
  52287. Down = 13,
  52288. /** Left */
  52289. Left = 14,
  52290. /** Right */
  52291. Right = 15
  52292. }
  52293. /**
  52294. * Defines a DualShock gamepad
  52295. */
  52296. export class DualShockPad extends Gamepad {
  52297. private _leftTrigger;
  52298. private _rightTrigger;
  52299. private _onlefttriggerchanged;
  52300. private _onrighttriggerchanged;
  52301. private _onbuttondown;
  52302. private _onbuttonup;
  52303. private _ondpaddown;
  52304. private _ondpadup;
  52305. /** Observable raised when a button is pressed */
  52306. onButtonDownObservable: Observable<DualShockButton>;
  52307. /** Observable raised when a button is released */
  52308. onButtonUpObservable: Observable<DualShockButton>;
  52309. /** Observable raised when a pad is pressed */
  52310. onPadDownObservable: Observable<DualShockDpad>;
  52311. /** Observable raised when a pad is released */
  52312. onPadUpObservable: Observable<DualShockDpad>;
  52313. private _buttonCross;
  52314. private _buttonCircle;
  52315. private _buttonSquare;
  52316. private _buttonTriangle;
  52317. private _buttonShare;
  52318. private _buttonOptions;
  52319. private _buttonL1;
  52320. private _buttonR1;
  52321. private _buttonLeftStick;
  52322. private _buttonRightStick;
  52323. private _dPadUp;
  52324. private _dPadDown;
  52325. private _dPadLeft;
  52326. private _dPadRight;
  52327. /**
  52328. * Creates a new DualShock gamepad object
  52329. * @param id defines the id of this gamepad
  52330. * @param index defines its index
  52331. * @param gamepad defines the internal HTML gamepad object
  52332. */
  52333. constructor(id: string, index: number, gamepad: any);
  52334. /**
  52335. * Defines the callback to call when left trigger is pressed
  52336. * @param callback defines the callback to use
  52337. */
  52338. onlefttriggerchanged(callback: (value: number) => void): void;
  52339. /**
  52340. * Defines the callback to call when right trigger is pressed
  52341. * @param callback defines the callback to use
  52342. */
  52343. onrighttriggerchanged(callback: (value: number) => void): void;
  52344. /**
  52345. * Gets the left trigger value
  52346. */
  52347. get leftTrigger(): number;
  52348. /**
  52349. * Sets the left trigger value
  52350. */
  52351. set leftTrigger(newValue: number);
  52352. /**
  52353. * Gets the right trigger value
  52354. */
  52355. get rightTrigger(): number;
  52356. /**
  52357. * Sets the right trigger value
  52358. */
  52359. set rightTrigger(newValue: number);
  52360. /**
  52361. * Defines the callback to call when a button is pressed
  52362. * @param callback defines the callback to use
  52363. */
  52364. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52365. /**
  52366. * Defines the callback to call when a button is released
  52367. * @param callback defines the callback to use
  52368. */
  52369. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52370. /**
  52371. * Defines the callback to call when a pad is pressed
  52372. * @param callback defines the callback to use
  52373. */
  52374. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52375. /**
  52376. * Defines the callback to call when a pad is released
  52377. * @param callback defines the callback to use
  52378. */
  52379. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52380. private _setButtonValue;
  52381. private _setDPadValue;
  52382. /**
  52383. * Gets the value of the `Cross` button
  52384. */
  52385. get buttonCross(): number;
  52386. /**
  52387. * Sets the value of the `Cross` button
  52388. */
  52389. set buttonCross(value: number);
  52390. /**
  52391. * Gets the value of the `Circle` button
  52392. */
  52393. get buttonCircle(): number;
  52394. /**
  52395. * Sets the value of the `Circle` button
  52396. */
  52397. set buttonCircle(value: number);
  52398. /**
  52399. * Gets the value of the `Square` button
  52400. */
  52401. get buttonSquare(): number;
  52402. /**
  52403. * Sets the value of the `Square` button
  52404. */
  52405. set buttonSquare(value: number);
  52406. /**
  52407. * Gets the value of the `Triangle` button
  52408. */
  52409. get buttonTriangle(): number;
  52410. /**
  52411. * Sets the value of the `Triangle` button
  52412. */
  52413. set buttonTriangle(value: number);
  52414. /**
  52415. * Gets the value of the `Options` button
  52416. */
  52417. get buttonOptions(): number;
  52418. /**
  52419. * Sets the value of the `Options` button
  52420. */
  52421. set buttonOptions(value: number);
  52422. /**
  52423. * Gets the value of the `Share` button
  52424. */
  52425. get buttonShare(): number;
  52426. /**
  52427. * Sets the value of the `Share` button
  52428. */
  52429. set buttonShare(value: number);
  52430. /**
  52431. * Gets the value of the `L1` button
  52432. */
  52433. get buttonL1(): number;
  52434. /**
  52435. * Sets the value of the `L1` button
  52436. */
  52437. set buttonL1(value: number);
  52438. /**
  52439. * Gets the value of the `R1` button
  52440. */
  52441. get buttonR1(): number;
  52442. /**
  52443. * Sets the value of the `R1` button
  52444. */
  52445. set buttonR1(value: number);
  52446. /**
  52447. * Gets the value of the Left joystick
  52448. */
  52449. get buttonLeftStick(): number;
  52450. /**
  52451. * Sets the value of the Left joystick
  52452. */
  52453. set buttonLeftStick(value: number);
  52454. /**
  52455. * Gets the value of the Right joystick
  52456. */
  52457. get buttonRightStick(): number;
  52458. /**
  52459. * Sets the value of the Right joystick
  52460. */
  52461. set buttonRightStick(value: number);
  52462. /**
  52463. * Gets the value of D-pad up
  52464. */
  52465. get dPadUp(): number;
  52466. /**
  52467. * Sets the value of D-pad up
  52468. */
  52469. set dPadUp(value: number);
  52470. /**
  52471. * Gets the value of D-pad down
  52472. */
  52473. get dPadDown(): number;
  52474. /**
  52475. * Sets the value of D-pad down
  52476. */
  52477. set dPadDown(value: number);
  52478. /**
  52479. * Gets the value of D-pad left
  52480. */
  52481. get dPadLeft(): number;
  52482. /**
  52483. * Sets the value of D-pad left
  52484. */
  52485. set dPadLeft(value: number);
  52486. /**
  52487. * Gets the value of D-pad right
  52488. */
  52489. get dPadRight(): number;
  52490. /**
  52491. * Sets the value of D-pad right
  52492. */
  52493. set dPadRight(value: number);
  52494. /**
  52495. * Force the gamepad to synchronize with device values
  52496. */
  52497. update(): void;
  52498. /**
  52499. * Disposes the gamepad
  52500. */
  52501. dispose(): void;
  52502. }
  52503. }
  52504. declare module BABYLON {
  52505. /**
  52506. * Manager for handling gamepads
  52507. */
  52508. export class GamepadManager {
  52509. private _scene?;
  52510. private _babylonGamepads;
  52511. private _oneGamepadConnected;
  52512. /** @hidden */
  52513. _isMonitoring: boolean;
  52514. private _gamepadEventSupported;
  52515. private _gamepadSupport?;
  52516. /**
  52517. * observable to be triggered when the gamepad controller has been connected
  52518. */
  52519. onGamepadConnectedObservable: Observable<Gamepad>;
  52520. /**
  52521. * observable to be triggered when the gamepad controller has been disconnected
  52522. */
  52523. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52524. private _onGamepadConnectedEvent;
  52525. private _onGamepadDisconnectedEvent;
  52526. /**
  52527. * Initializes the gamepad manager
  52528. * @param _scene BabylonJS scene
  52529. */
  52530. constructor(_scene?: Scene | undefined);
  52531. /**
  52532. * The gamepads in the game pad manager
  52533. */
  52534. get gamepads(): Gamepad[];
  52535. /**
  52536. * Get the gamepad controllers based on type
  52537. * @param type The type of gamepad controller
  52538. * @returns Nullable gamepad
  52539. */
  52540. getGamepadByType(type?: number): Nullable<Gamepad>;
  52541. /**
  52542. * Disposes the gamepad manager
  52543. */
  52544. dispose(): void;
  52545. private _addNewGamepad;
  52546. private _startMonitoringGamepads;
  52547. private _stopMonitoringGamepads;
  52548. /** @hidden */
  52549. _checkGamepadsStatus(): void;
  52550. private _updateGamepadObjects;
  52551. }
  52552. }
  52553. declare module BABYLON {
  52554. interface Scene {
  52555. /** @hidden */
  52556. _gamepadManager: Nullable<GamepadManager>;
  52557. /**
  52558. * Gets the gamepad manager associated with the scene
  52559. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52560. */
  52561. gamepadManager: GamepadManager;
  52562. }
  52563. /**
  52564. * Interface representing a free camera inputs manager
  52565. */
  52566. interface FreeCameraInputsManager {
  52567. /**
  52568. * Adds gamepad input support to the FreeCameraInputsManager.
  52569. * @returns the FreeCameraInputsManager
  52570. */
  52571. addGamepad(): FreeCameraInputsManager;
  52572. }
  52573. /**
  52574. * Interface representing an arc rotate camera inputs manager
  52575. */
  52576. interface ArcRotateCameraInputsManager {
  52577. /**
  52578. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52579. * @returns the camera inputs manager
  52580. */
  52581. addGamepad(): ArcRotateCameraInputsManager;
  52582. }
  52583. /**
  52584. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52585. */
  52586. export class GamepadSystemSceneComponent implements ISceneComponent {
  52587. /**
  52588. * The component name helpfull to identify the component in the list of scene components.
  52589. */
  52590. readonly name: string;
  52591. /**
  52592. * The scene the component belongs to.
  52593. */
  52594. scene: Scene;
  52595. /**
  52596. * Creates a new instance of the component for the given scene
  52597. * @param scene Defines the scene to register the component in
  52598. */
  52599. constructor(scene: Scene);
  52600. /**
  52601. * Registers the component in a given scene
  52602. */
  52603. register(): void;
  52604. /**
  52605. * Rebuilds the elements related to this component in case of
  52606. * context lost for instance.
  52607. */
  52608. rebuild(): void;
  52609. /**
  52610. * Disposes the component and the associated ressources
  52611. */
  52612. dispose(): void;
  52613. private _beforeCameraUpdate;
  52614. }
  52615. }
  52616. declare module BABYLON {
  52617. /**
  52618. * 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,
  52619. * which still works and will still be found in many Playgrounds.
  52620. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52621. */
  52622. export class UniversalCamera extends TouchCamera {
  52623. /**
  52624. * Defines the gamepad rotation sensiblity.
  52625. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52626. */
  52627. get gamepadAngularSensibility(): number;
  52628. set gamepadAngularSensibility(value: number);
  52629. /**
  52630. * Defines the gamepad move sensiblity.
  52631. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52632. */
  52633. get gamepadMoveSensibility(): number;
  52634. set gamepadMoveSensibility(value: number);
  52635. /**
  52636. * 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,
  52637. * which still works and will still be found in many Playgrounds.
  52638. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52639. * @param name Define the name of the camera in the scene
  52640. * @param position Define the start position of the camera in the scene
  52641. * @param scene Define the scene the camera belongs to
  52642. */
  52643. constructor(name: string, position: Vector3, scene: Scene);
  52644. /**
  52645. * Gets the current object class name.
  52646. * @return the class name
  52647. */
  52648. getClassName(): string;
  52649. }
  52650. }
  52651. declare module BABYLON {
  52652. /**
  52653. * This represents a FPS type of camera. This is only here for back compat purpose.
  52654. * Please use the UniversalCamera instead as both are identical.
  52655. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52656. */
  52657. export class GamepadCamera extends UniversalCamera {
  52658. /**
  52659. * Instantiates a new Gamepad Camera
  52660. * This represents a FPS type of camera. This is only here for back compat purpose.
  52661. * Please use the UniversalCamera instead as both are identical.
  52662. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52663. * @param name Define the name of the camera in the scene
  52664. * @param position Define the start position of the camera in the scene
  52665. * @param scene Define the scene the camera belongs to
  52666. */
  52667. constructor(name: string, position: Vector3, scene: Scene);
  52668. /**
  52669. * Gets the current object class name.
  52670. * @return the class name
  52671. */
  52672. getClassName(): string;
  52673. }
  52674. }
  52675. declare module BABYLON {
  52676. /** @hidden */
  52677. export var anaglyphPixelShader: {
  52678. name: string;
  52679. shader: string;
  52680. };
  52681. }
  52682. declare module BABYLON {
  52683. /**
  52684. * Postprocess used to generate anaglyphic rendering
  52685. */
  52686. export class AnaglyphPostProcess extends PostProcess {
  52687. private _passedProcess;
  52688. /**
  52689. * Gets a string identifying the name of the class
  52690. * @returns "AnaglyphPostProcess" string
  52691. */
  52692. getClassName(): string;
  52693. /**
  52694. * Creates a new AnaglyphPostProcess
  52695. * @param name defines postprocess name
  52696. * @param options defines creation options or target ratio scale
  52697. * @param rigCameras defines cameras using this postprocess
  52698. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52699. * @param engine defines hosting engine
  52700. * @param reusable defines if the postprocess will be reused multiple times per frame
  52701. */
  52702. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52703. }
  52704. }
  52705. declare module BABYLON {
  52706. /**
  52707. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52708. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52709. */
  52710. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52711. /**
  52712. * Creates a new AnaglyphArcRotateCamera
  52713. * @param name defines camera name
  52714. * @param alpha defines alpha angle (in radians)
  52715. * @param beta defines beta angle (in radians)
  52716. * @param radius defines radius
  52717. * @param target defines camera target
  52718. * @param interaxialDistance defines distance between each color axis
  52719. * @param scene defines the hosting scene
  52720. */
  52721. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52722. /**
  52723. * Gets camera class name
  52724. * @returns AnaglyphArcRotateCamera
  52725. */
  52726. getClassName(): string;
  52727. }
  52728. }
  52729. declare module BABYLON {
  52730. /**
  52731. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52732. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52733. */
  52734. export class AnaglyphFreeCamera extends FreeCamera {
  52735. /**
  52736. * Creates a new AnaglyphFreeCamera
  52737. * @param name defines camera name
  52738. * @param position defines initial position
  52739. * @param interaxialDistance defines distance between each color axis
  52740. * @param scene defines the hosting scene
  52741. */
  52742. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52743. /**
  52744. * Gets camera class name
  52745. * @returns AnaglyphFreeCamera
  52746. */
  52747. getClassName(): string;
  52748. }
  52749. }
  52750. declare module BABYLON {
  52751. /**
  52752. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52753. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52754. */
  52755. export class AnaglyphGamepadCamera extends GamepadCamera {
  52756. /**
  52757. * Creates a new AnaglyphGamepadCamera
  52758. * @param name defines camera name
  52759. * @param position defines initial position
  52760. * @param interaxialDistance defines distance between each color axis
  52761. * @param scene defines the hosting scene
  52762. */
  52763. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52764. /**
  52765. * Gets camera class name
  52766. * @returns AnaglyphGamepadCamera
  52767. */
  52768. getClassName(): string;
  52769. }
  52770. }
  52771. declare module BABYLON {
  52772. /**
  52773. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52774. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52775. */
  52776. export class AnaglyphUniversalCamera extends UniversalCamera {
  52777. /**
  52778. * Creates a new AnaglyphUniversalCamera
  52779. * @param name defines camera name
  52780. * @param position defines initial position
  52781. * @param interaxialDistance defines distance between each color axis
  52782. * @param scene defines the hosting scene
  52783. */
  52784. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52785. /**
  52786. * Gets camera class name
  52787. * @returns AnaglyphUniversalCamera
  52788. */
  52789. getClassName(): string;
  52790. }
  52791. }
  52792. declare module BABYLON {
  52793. /** @hidden */
  52794. export var stereoscopicInterlacePixelShader: {
  52795. name: string;
  52796. shader: string;
  52797. };
  52798. }
  52799. declare module BABYLON {
  52800. /**
  52801. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  52802. */
  52803. export class StereoscopicInterlacePostProcessI extends PostProcess {
  52804. private _stepSize;
  52805. private _passedProcess;
  52806. /**
  52807. * Gets a string identifying the name of the class
  52808. * @returns "StereoscopicInterlacePostProcessI" string
  52809. */
  52810. getClassName(): string;
  52811. /**
  52812. * Initializes a StereoscopicInterlacePostProcessI
  52813. * @param name The name of the effect.
  52814. * @param rigCameras The rig cameras to be appled to the post process
  52815. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  52816. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  52817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52818. * @param engine The engine which the post process will be applied. (default: current engine)
  52819. * @param reusable If the post process can be reused on the same frame. (default: false)
  52820. */
  52821. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52822. }
  52823. /**
  52824. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  52825. */
  52826. export class StereoscopicInterlacePostProcess extends PostProcess {
  52827. private _stepSize;
  52828. private _passedProcess;
  52829. /**
  52830. * Gets a string identifying the name of the class
  52831. * @returns "StereoscopicInterlacePostProcess" string
  52832. */
  52833. getClassName(): string;
  52834. /**
  52835. * Initializes a StereoscopicInterlacePostProcess
  52836. * @param name The name of the effect.
  52837. * @param rigCameras The rig cameras to be appled to the post process
  52838. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  52839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52840. * @param engine The engine which the post process will be applied. (default: current engine)
  52841. * @param reusable If the post process can be reused on the same frame. (default: false)
  52842. */
  52843. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52844. }
  52845. }
  52846. declare module BABYLON {
  52847. /**
  52848. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52849. * @see https://doc.babylonjs.com/features/cameras
  52850. */
  52851. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52852. /**
  52853. * Creates a new StereoscopicArcRotateCamera
  52854. * @param name defines camera name
  52855. * @param alpha defines alpha angle (in radians)
  52856. * @param beta defines beta angle (in radians)
  52857. * @param radius defines radius
  52858. * @param target defines camera target
  52859. * @param interaxialDistance defines distance between each color axis
  52860. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52861. * @param scene defines the hosting scene
  52862. */
  52863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52864. /**
  52865. * Gets camera class name
  52866. * @returns StereoscopicArcRotateCamera
  52867. */
  52868. getClassName(): string;
  52869. }
  52870. }
  52871. declare module BABYLON {
  52872. /**
  52873. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52874. * @see https://doc.babylonjs.com/features/cameras
  52875. */
  52876. export class StereoscopicFreeCamera extends FreeCamera {
  52877. /**
  52878. * Creates a new StereoscopicFreeCamera
  52879. * @param name defines camera name
  52880. * @param position defines initial position
  52881. * @param interaxialDistance defines distance between each color axis
  52882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52883. * @param scene defines the hosting scene
  52884. */
  52885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52886. /**
  52887. * Gets camera class name
  52888. * @returns StereoscopicFreeCamera
  52889. */
  52890. getClassName(): string;
  52891. }
  52892. }
  52893. declare module BABYLON {
  52894. /**
  52895. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52896. * @see https://doc.babylonjs.com/features/cameras
  52897. */
  52898. export class StereoscopicGamepadCamera extends GamepadCamera {
  52899. /**
  52900. * Creates a new StereoscopicGamepadCamera
  52901. * @param name defines camera name
  52902. * @param position defines initial position
  52903. * @param interaxialDistance defines distance between each color axis
  52904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52905. * @param scene defines the hosting scene
  52906. */
  52907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52908. /**
  52909. * Gets camera class name
  52910. * @returns StereoscopicGamepadCamera
  52911. */
  52912. getClassName(): string;
  52913. }
  52914. }
  52915. declare module BABYLON {
  52916. /**
  52917. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52918. * @see https://doc.babylonjs.com/features/cameras
  52919. */
  52920. export class StereoscopicUniversalCamera extends UniversalCamera {
  52921. /**
  52922. * Creates a new StereoscopicUniversalCamera
  52923. * @param name defines camera name
  52924. * @param position defines initial position
  52925. * @param interaxialDistance defines distance between each color axis
  52926. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52927. * @param scene defines the hosting scene
  52928. */
  52929. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52930. /**
  52931. * Gets camera class name
  52932. * @returns StereoscopicUniversalCamera
  52933. */
  52934. getClassName(): string;
  52935. }
  52936. }
  52937. declare module BABYLON {
  52938. /**
  52939. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52940. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52941. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52942. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52943. */
  52944. export class VirtualJoysticksCamera extends FreeCamera {
  52945. /**
  52946. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52947. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52948. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52949. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52950. * @param name Define the name of the camera in the scene
  52951. * @param position Define the start position of the camera in the scene
  52952. * @param scene Define the scene the camera belongs to
  52953. */
  52954. constructor(name: string, position: Vector3, scene: Scene);
  52955. /**
  52956. * Gets the current object class name.
  52957. * @return the class name
  52958. */
  52959. getClassName(): string;
  52960. }
  52961. }
  52962. declare module BABYLON {
  52963. /**
  52964. * This represents all the required metrics to create a VR camera.
  52965. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52966. */
  52967. export class VRCameraMetrics {
  52968. /**
  52969. * Define the horizontal resolution off the screen.
  52970. */
  52971. hResolution: number;
  52972. /**
  52973. * Define the vertical resolution off the screen.
  52974. */
  52975. vResolution: number;
  52976. /**
  52977. * Define the horizontal screen size.
  52978. */
  52979. hScreenSize: number;
  52980. /**
  52981. * Define the vertical screen size.
  52982. */
  52983. vScreenSize: number;
  52984. /**
  52985. * Define the vertical screen center position.
  52986. */
  52987. vScreenCenter: number;
  52988. /**
  52989. * Define the distance of the eyes to the screen.
  52990. */
  52991. eyeToScreenDistance: number;
  52992. /**
  52993. * Define the distance between both lenses
  52994. */
  52995. lensSeparationDistance: number;
  52996. /**
  52997. * Define the distance between both viewer's eyes.
  52998. */
  52999. interpupillaryDistance: number;
  53000. /**
  53001. * Define the distortion factor of the VR postprocess.
  53002. * Please, touch with care.
  53003. */
  53004. distortionK: number[];
  53005. /**
  53006. * Define the chromatic aberration correction factors for the VR post process.
  53007. */
  53008. chromaAbCorrection: number[];
  53009. /**
  53010. * Define the scale factor of the post process.
  53011. * The smaller the better but the slower.
  53012. */
  53013. postProcessScaleFactor: number;
  53014. /**
  53015. * Define an offset for the lens center.
  53016. */
  53017. lensCenterOffset: number;
  53018. /**
  53019. * Define if the current vr camera should compensate the distortion of the lense or not.
  53020. */
  53021. compensateDistortion: boolean;
  53022. /**
  53023. * Defines if multiview should be enabled when rendering (Default: false)
  53024. */
  53025. multiviewEnabled: boolean;
  53026. /**
  53027. * Gets the rendering aspect ratio based on the provided resolutions.
  53028. */
  53029. get aspectRatio(): number;
  53030. /**
  53031. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53032. */
  53033. get aspectRatioFov(): number;
  53034. /**
  53035. * @hidden
  53036. */
  53037. get leftHMatrix(): Matrix;
  53038. /**
  53039. * @hidden
  53040. */
  53041. get rightHMatrix(): Matrix;
  53042. /**
  53043. * @hidden
  53044. */
  53045. get leftPreViewMatrix(): Matrix;
  53046. /**
  53047. * @hidden
  53048. */
  53049. get rightPreViewMatrix(): Matrix;
  53050. /**
  53051. * Get the default VRMetrics based on the most generic setup.
  53052. * @returns the default vr metrics
  53053. */
  53054. static GetDefault(): VRCameraMetrics;
  53055. }
  53056. }
  53057. declare module BABYLON {
  53058. /** @hidden */
  53059. export var vrDistortionCorrectionPixelShader: {
  53060. name: string;
  53061. shader: string;
  53062. };
  53063. }
  53064. declare module BABYLON {
  53065. /**
  53066. * VRDistortionCorrectionPostProcess used for mobile VR
  53067. */
  53068. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53069. private _isRightEye;
  53070. private _distortionFactors;
  53071. private _postProcessScaleFactor;
  53072. private _lensCenterOffset;
  53073. private _scaleIn;
  53074. private _scaleFactor;
  53075. private _lensCenter;
  53076. /**
  53077. * Gets a string identifying the name of the class
  53078. * @returns "VRDistortionCorrectionPostProcess" string
  53079. */
  53080. getClassName(): string;
  53081. /**
  53082. * Initializes the VRDistortionCorrectionPostProcess
  53083. * @param name The name of the effect.
  53084. * @param camera The camera to apply the render pass to.
  53085. * @param isRightEye If this is for the right eye distortion
  53086. * @param vrMetrics All the required metrics for the VR camera
  53087. */
  53088. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53089. }
  53090. }
  53091. declare module BABYLON {
  53092. /**
  53093. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53094. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53095. */
  53096. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53097. /**
  53098. * Creates a new VRDeviceOrientationArcRotateCamera
  53099. * @param name defines camera name
  53100. * @param alpha defines the camera rotation along the logitudinal axis
  53101. * @param beta defines the camera rotation along the latitudinal axis
  53102. * @param radius defines the camera distance from its target
  53103. * @param target defines the camera target
  53104. * @param scene defines the scene the camera belongs to
  53105. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53106. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53107. */
  53108. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53109. /**
  53110. * Gets camera class name
  53111. * @returns VRDeviceOrientationArcRotateCamera
  53112. */
  53113. getClassName(): string;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /**
  53118. * Camera used to simulate VR rendering (based on FreeCamera)
  53119. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53120. */
  53121. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53122. /**
  53123. * Creates a new VRDeviceOrientationFreeCamera
  53124. * @param name defines camera name
  53125. * @param position defines the start position of the camera
  53126. * @param scene defines the scene the camera belongs to
  53127. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53128. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53129. */
  53130. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53131. /**
  53132. * Gets camera class name
  53133. * @returns VRDeviceOrientationFreeCamera
  53134. */
  53135. getClassName(): string;
  53136. }
  53137. }
  53138. declare module BABYLON {
  53139. /**
  53140. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53141. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53142. */
  53143. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53144. /**
  53145. * Creates a new VRDeviceOrientationGamepadCamera
  53146. * @param name defines camera name
  53147. * @param position defines the start position of the camera
  53148. * @param scene defines the scene the camera belongs to
  53149. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53150. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53151. */
  53152. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53153. /**
  53154. * Gets camera class name
  53155. * @returns VRDeviceOrientationGamepadCamera
  53156. */
  53157. getClassName(): string;
  53158. }
  53159. }
  53160. declare module BABYLON {
  53161. /**
  53162. * A class extending Texture allowing drawing on a texture
  53163. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53164. */
  53165. export class DynamicTexture extends Texture {
  53166. private _generateMipMaps;
  53167. private _canvas;
  53168. private _context;
  53169. /**
  53170. * Creates a DynamicTexture
  53171. * @param name defines the name of the texture
  53172. * @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
  53173. * @param scene defines the scene where you want the texture
  53174. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53175. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53176. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53177. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53178. */
  53179. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53180. /**
  53181. * Get the current class name of the texture useful for serialization or dynamic coding.
  53182. * @returns "DynamicTexture"
  53183. */
  53184. getClassName(): string;
  53185. /**
  53186. * Gets the current state of canRescale
  53187. */
  53188. get canRescale(): boolean;
  53189. private _recreate;
  53190. /**
  53191. * Scales the texture
  53192. * @param ratio the scale factor to apply to both width and height
  53193. */
  53194. scale(ratio: number): void;
  53195. /**
  53196. * Resizes the texture
  53197. * @param width the new width
  53198. * @param height the new height
  53199. */
  53200. scaleTo(width: number, height: number): void;
  53201. /**
  53202. * Gets the context of the canvas used by the texture
  53203. * @returns the canvas context of the dynamic texture
  53204. */
  53205. getContext(): CanvasRenderingContext2D;
  53206. /**
  53207. * Clears the texture
  53208. */
  53209. clear(): void;
  53210. /**
  53211. * Updates the texture
  53212. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53213. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53214. */
  53215. update(invertY?: boolean, premulAlpha?: boolean): void;
  53216. /**
  53217. * Draws text onto the texture
  53218. * @param text defines the text to be drawn
  53219. * @param x defines the placement of the text from the left
  53220. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53221. * @param font defines the font to be used with font-style, font-size, font-name
  53222. * @param color defines the color used for the text
  53223. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53224. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53225. * @param update defines whether texture is immediately update (default is true)
  53226. */
  53227. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53228. /**
  53229. * Clones the texture
  53230. * @returns the clone of the texture.
  53231. */
  53232. clone(): DynamicTexture;
  53233. /**
  53234. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53235. * @returns a serialized dynamic texture object
  53236. */
  53237. serialize(): any;
  53238. private _IsCanvasElement;
  53239. /** @hidden */
  53240. _rebuild(): void;
  53241. }
  53242. }
  53243. declare module BABYLON {
  53244. /**
  53245. * Class containing static functions to help procedurally build meshes
  53246. */
  53247. export class GroundBuilder {
  53248. /**
  53249. * Creates a ground mesh
  53250. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53251. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53253. * @param name defines the name of the mesh
  53254. * @param options defines the options used to create the mesh
  53255. * @param scene defines the hosting scene
  53256. * @returns the ground mesh
  53257. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53258. */
  53259. static CreateGround(name: string, options: {
  53260. width?: number;
  53261. height?: number;
  53262. subdivisions?: number;
  53263. subdivisionsX?: number;
  53264. subdivisionsY?: number;
  53265. updatable?: boolean;
  53266. }, scene: any): Mesh;
  53267. /**
  53268. * Creates a tiled ground mesh
  53269. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53270. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53271. * * 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
  53272. * * 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
  53273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53274. * @param name defines the name of the mesh
  53275. * @param options defines the options used to create the mesh
  53276. * @param scene defines the hosting scene
  53277. * @returns the tiled ground mesh
  53278. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53279. */
  53280. static CreateTiledGround(name: string, options: {
  53281. xmin: number;
  53282. zmin: number;
  53283. xmax: number;
  53284. zmax: number;
  53285. subdivisions?: {
  53286. w: number;
  53287. h: number;
  53288. };
  53289. precision?: {
  53290. w: number;
  53291. h: number;
  53292. };
  53293. updatable?: boolean;
  53294. }, scene?: Nullable<Scene>): Mesh;
  53295. /**
  53296. * Creates a ground mesh from a height map
  53297. * * The parameter `url` sets the URL of the height map image resource.
  53298. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53299. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53300. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53301. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53302. * * 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.
  53303. * * 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).
  53304. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53306. * @param name defines the name of the mesh
  53307. * @param url defines the url to the height map
  53308. * @param options defines the options used to create the mesh
  53309. * @param scene defines the hosting scene
  53310. * @returns the ground mesh
  53311. * @see https://doc.babylonjs.com/babylon101/height_map
  53312. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53313. */
  53314. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53315. width?: number;
  53316. height?: number;
  53317. subdivisions?: number;
  53318. minHeight?: number;
  53319. maxHeight?: number;
  53320. colorFilter?: Color3;
  53321. alphaFilter?: number;
  53322. updatable?: boolean;
  53323. onReady?: (mesh: GroundMesh) => void;
  53324. }, scene?: Nullable<Scene>): GroundMesh;
  53325. }
  53326. }
  53327. declare module BABYLON {
  53328. /**
  53329. * Class containing static functions to help procedurally build meshes
  53330. */
  53331. export class TorusBuilder {
  53332. /**
  53333. * Creates a torus mesh
  53334. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53335. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53336. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53338. * * 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
  53339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53340. * @param name defines the name of the mesh
  53341. * @param options defines the options used to create the mesh
  53342. * @param scene defines the hosting scene
  53343. * @returns the torus mesh
  53344. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53345. */
  53346. static CreateTorus(name: string, options: {
  53347. diameter?: number;
  53348. thickness?: number;
  53349. tessellation?: number;
  53350. updatable?: boolean;
  53351. sideOrientation?: number;
  53352. frontUVs?: Vector4;
  53353. backUVs?: Vector4;
  53354. }, scene: any): Mesh;
  53355. }
  53356. }
  53357. declare module BABYLON {
  53358. /**
  53359. * Class containing static functions to help procedurally build meshes
  53360. */
  53361. export class CylinderBuilder {
  53362. /**
  53363. * Creates a cylinder or a cone mesh
  53364. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53365. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53366. * * 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.
  53367. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53368. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53369. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53370. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53371. * * 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).
  53372. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53373. * * 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).
  53374. * * 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
  53375. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53376. * * 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
  53377. * * 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.
  53378. * * If `enclose` is false, a ring surface is one element.
  53379. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53380. * * 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
  53381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53382. * * 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
  53383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53384. * @param name defines the name of the mesh
  53385. * @param options defines the options used to create the mesh
  53386. * @param scene defines the hosting scene
  53387. * @returns the cylinder mesh
  53388. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53389. */
  53390. static CreateCylinder(name: string, options: {
  53391. height?: number;
  53392. diameterTop?: number;
  53393. diameterBottom?: number;
  53394. diameter?: number;
  53395. tessellation?: number;
  53396. subdivisions?: number;
  53397. arc?: number;
  53398. faceColors?: Color4[];
  53399. faceUV?: Vector4[];
  53400. updatable?: boolean;
  53401. hasRings?: boolean;
  53402. enclose?: boolean;
  53403. cap?: number;
  53404. sideOrientation?: number;
  53405. frontUVs?: Vector4;
  53406. backUVs?: Vector4;
  53407. }, scene: any): Mesh;
  53408. }
  53409. }
  53410. declare module BABYLON {
  53411. /**
  53412. * States of the webXR experience
  53413. */
  53414. export enum WebXRState {
  53415. /**
  53416. * Transitioning to being in XR mode
  53417. */
  53418. ENTERING_XR = 0,
  53419. /**
  53420. * Transitioning to non XR mode
  53421. */
  53422. EXITING_XR = 1,
  53423. /**
  53424. * In XR mode and presenting
  53425. */
  53426. IN_XR = 2,
  53427. /**
  53428. * Not entered XR mode
  53429. */
  53430. NOT_IN_XR = 3
  53431. }
  53432. /**
  53433. * The state of the XR camera's tracking
  53434. */
  53435. export enum WebXRTrackingState {
  53436. /**
  53437. * No transformation received, device is not being tracked
  53438. */
  53439. NOT_TRACKING = 0,
  53440. /**
  53441. * Tracking lost - using emulated position
  53442. */
  53443. TRACKING_LOST = 1,
  53444. /**
  53445. * Transformation tracking works normally
  53446. */
  53447. TRACKING = 2
  53448. }
  53449. /**
  53450. * Abstraction of the XR render target
  53451. */
  53452. export interface WebXRRenderTarget extends IDisposable {
  53453. /**
  53454. * xrpresent context of the canvas which can be used to display/mirror xr content
  53455. */
  53456. canvasContext: WebGLRenderingContext;
  53457. /**
  53458. * xr layer for the canvas
  53459. */
  53460. xrLayer: Nullable<XRWebGLLayer>;
  53461. /**
  53462. * Initializes the xr layer for the session
  53463. * @param xrSession xr session
  53464. * @returns a promise that will resolve once the XR Layer has been created
  53465. */
  53466. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53467. }
  53468. }
  53469. declare module BABYLON {
  53470. /**
  53471. * COnfiguration object for WebXR output canvas
  53472. */
  53473. export class WebXRManagedOutputCanvasOptions {
  53474. /**
  53475. * An optional canvas in case you wish to create it yourself and provide it here.
  53476. * If not provided, a new canvas will be created
  53477. */
  53478. canvasElement?: HTMLCanvasElement;
  53479. /**
  53480. * Options for this XR Layer output
  53481. */
  53482. canvasOptions?: XRWebGLLayerInit;
  53483. /**
  53484. * CSS styling for a newly created canvas (if not provided)
  53485. */
  53486. newCanvasCssStyle?: string;
  53487. /**
  53488. * Get the default values of the configuration object
  53489. * @param engine defines the engine to use (can be null)
  53490. * @returns default values of this configuration object
  53491. */
  53492. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53493. }
  53494. /**
  53495. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53496. */
  53497. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53498. private _options;
  53499. private _canvas;
  53500. private _engine;
  53501. private _originalCanvasSize;
  53502. /**
  53503. * Rendering context of the canvas which can be used to display/mirror xr content
  53504. */
  53505. canvasContext: WebGLRenderingContext;
  53506. /**
  53507. * xr layer for the canvas
  53508. */
  53509. xrLayer: Nullable<XRWebGLLayer>;
  53510. /**
  53511. * Obseervers registered here will be triggered when the xr layer was initialized
  53512. */
  53513. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53514. /**
  53515. * Initializes the canvas to be added/removed upon entering/exiting xr
  53516. * @param _xrSessionManager The XR Session manager
  53517. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53518. */
  53519. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53520. /**
  53521. * Disposes of the object
  53522. */
  53523. dispose(): void;
  53524. /**
  53525. * Initializes the xr layer for the session
  53526. * @param xrSession xr session
  53527. * @returns a promise that will resolve once the XR Layer has been created
  53528. */
  53529. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53530. private _addCanvas;
  53531. private _removeCanvas;
  53532. private _setCanvasSize;
  53533. private _setManagedOutputCanvas;
  53534. }
  53535. }
  53536. declare module BABYLON {
  53537. /**
  53538. * Manages an XRSession to work with Babylon's engine
  53539. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53540. */
  53541. export class WebXRSessionManager implements IDisposable {
  53542. /** The scene which the session should be created for */
  53543. scene: Scene;
  53544. private _referenceSpace;
  53545. private _rttProvider;
  53546. private _sessionEnded;
  53547. private _xrNavigator;
  53548. private baseLayer;
  53549. /**
  53550. * The base reference space from which the session started. good if you want to reset your
  53551. * reference space
  53552. */
  53553. baseReferenceSpace: XRReferenceSpace;
  53554. /**
  53555. * Current XR frame
  53556. */
  53557. currentFrame: Nullable<XRFrame>;
  53558. /** WebXR timestamp updated every frame */
  53559. currentTimestamp: number;
  53560. /**
  53561. * Used just in case of a failure to initialize an immersive session.
  53562. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53563. */
  53564. defaultHeightCompensation: number;
  53565. /**
  53566. * Fires every time a new xrFrame arrives which can be used to update the camera
  53567. */
  53568. onXRFrameObservable: Observable<XRFrame>;
  53569. /**
  53570. * Fires when the reference space changed
  53571. */
  53572. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53573. /**
  53574. * Fires when the xr session is ended either by the device or manually done
  53575. */
  53576. onXRSessionEnded: Observable<any>;
  53577. /**
  53578. * Fires when the xr session is ended either by the device or manually done
  53579. */
  53580. onXRSessionInit: Observable<XRSession>;
  53581. /**
  53582. * Underlying xr session
  53583. */
  53584. session: XRSession;
  53585. /**
  53586. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53587. * or get the offset the player is currently at.
  53588. */
  53589. viewerReferenceSpace: XRReferenceSpace;
  53590. /**
  53591. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53592. * @param scene The scene which the session should be created for
  53593. */
  53594. constructor(
  53595. /** The scene which the session should be created for */
  53596. scene: Scene);
  53597. /**
  53598. * The current reference space used in this session. This reference space can constantly change!
  53599. * It is mainly used to offset the camera's position.
  53600. */
  53601. get referenceSpace(): XRReferenceSpace;
  53602. /**
  53603. * Set a new reference space and triggers the observable
  53604. */
  53605. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53606. /**
  53607. * Disposes of the session manager
  53608. */
  53609. dispose(): void;
  53610. /**
  53611. * Stops the xrSession and restores the render loop
  53612. * @returns Promise which resolves after it exits XR
  53613. */
  53614. exitXRAsync(): Promise<void>;
  53615. /**
  53616. * Gets the correct render target texture to be rendered this frame for this eye
  53617. * @param eye the eye for which to get the render target
  53618. * @returns the render target for the specified eye
  53619. */
  53620. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53621. /**
  53622. * Creates a WebXRRenderTarget object for the XR session
  53623. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53624. * @param options optional options to provide when creating a new render target
  53625. * @returns a WebXR render target to which the session can render
  53626. */
  53627. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53628. /**
  53629. * Initializes the manager
  53630. * After initialization enterXR can be called to start an XR session
  53631. * @returns Promise which resolves after it is initialized
  53632. */
  53633. initializeAsync(): Promise<void>;
  53634. /**
  53635. * Initializes an xr session
  53636. * @param xrSessionMode mode to initialize
  53637. * @param xrSessionInit defines optional and required values to pass to the session builder
  53638. * @returns a promise which will resolve once the session has been initialized
  53639. */
  53640. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53641. /**
  53642. * Checks if a session would be supported for the creation options specified
  53643. * @param sessionMode session mode to check if supported eg. immersive-vr
  53644. * @returns A Promise that resolves to true if supported and false if not
  53645. */
  53646. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53647. /**
  53648. * Resets the reference space to the one started the session
  53649. */
  53650. resetReferenceSpace(): void;
  53651. /**
  53652. * Starts rendering to the xr layer
  53653. */
  53654. runXRRenderLoop(): void;
  53655. /**
  53656. * Sets the reference space on the xr session
  53657. * @param referenceSpaceType space to set
  53658. * @returns a promise that will resolve once the reference space has been set
  53659. */
  53660. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53661. /**
  53662. * Updates the render state of the session
  53663. * @param state state to set
  53664. * @returns a promise that resolves once the render state has been updated
  53665. */
  53666. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53667. /**
  53668. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53669. * @param sessionMode defines the session to test
  53670. * @returns a promise with boolean as final value
  53671. */
  53672. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53673. /**
  53674. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53675. */
  53676. get isNative(): boolean;
  53677. private _createRenderTargetTexture;
  53678. }
  53679. }
  53680. declare module BABYLON {
  53681. /**
  53682. * WebXR Camera which holds the views for the xrSession
  53683. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53684. */
  53685. export class WebXRCamera extends FreeCamera {
  53686. private _xrSessionManager;
  53687. private _firstFrame;
  53688. private _referenceQuaternion;
  53689. private _referencedPosition;
  53690. private _xrInvPositionCache;
  53691. private _xrInvQuaternionCache;
  53692. private _trackingState;
  53693. /**
  53694. * Observable raised before camera teleportation
  53695. */
  53696. onBeforeCameraTeleport: Observable<Vector3>;
  53697. /**
  53698. * Observable raised after camera teleportation
  53699. */
  53700. onAfterCameraTeleport: Observable<Vector3>;
  53701. /**
  53702. * Notifies when the camera's tracking state has changed.
  53703. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53704. */
  53705. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53706. /**
  53707. * Should position compensation execute on first frame.
  53708. * This is used when copying the position from a native (non XR) camera
  53709. */
  53710. compensateOnFirstFrame: boolean;
  53711. /**
  53712. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53713. * @param name the name of the camera
  53714. * @param scene the scene to add the camera to
  53715. * @param _xrSessionManager a constructed xr session manager
  53716. */
  53717. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53718. /**
  53719. * Get the current XR tracking state of the camera
  53720. */
  53721. get trackingState(): WebXRTrackingState;
  53722. private _setTrackingState;
  53723. /**
  53724. * Return the user's height, unrelated to the current ground.
  53725. * This will be the y position of this camera, when ground level is 0.
  53726. */
  53727. get realWorldHeight(): number;
  53728. /** @hidden */
  53729. _updateForDualEyeDebugging(): void;
  53730. /**
  53731. * Sets this camera's transformation based on a non-vr camera
  53732. * @param otherCamera the non-vr camera to copy the transformation from
  53733. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53734. */
  53735. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53736. /**
  53737. * Gets the current instance class name ("WebXRCamera").
  53738. * @returns the class name
  53739. */
  53740. getClassName(): string;
  53741. private _rotate180;
  53742. private _updateFromXRSession;
  53743. private _updateNumberOfRigCameras;
  53744. private _updateReferenceSpace;
  53745. private _updateReferenceSpaceOffset;
  53746. }
  53747. }
  53748. declare module BABYLON {
  53749. /**
  53750. * Defining the interface required for a (webxr) feature
  53751. */
  53752. export interface IWebXRFeature extends IDisposable {
  53753. /**
  53754. * Is this feature attached
  53755. */
  53756. attached: boolean;
  53757. /**
  53758. * Should auto-attach be disabled?
  53759. */
  53760. disableAutoAttach: boolean;
  53761. /**
  53762. * Attach the feature to the session
  53763. * Will usually be called by the features manager
  53764. *
  53765. * @param force should attachment be forced (even when already attached)
  53766. * @returns true if successful.
  53767. */
  53768. attach(force?: boolean): boolean;
  53769. /**
  53770. * Detach the feature from the session
  53771. * Will usually be called by the features manager
  53772. *
  53773. * @returns true if successful.
  53774. */
  53775. detach(): boolean;
  53776. /**
  53777. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53778. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53779. *
  53780. * @returns whether or not the feature is compatible in this environment
  53781. */
  53782. isCompatible(): boolean;
  53783. /**
  53784. * Was this feature disposed;
  53785. */
  53786. isDisposed: boolean;
  53787. /**
  53788. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53789. */
  53790. xrNativeFeatureName?: string;
  53791. /**
  53792. * A list of (Babylon WebXR) features this feature depends on
  53793. */
  53794. dependsOn?: string[];
  53795. /**
  53796. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53797. */
  53798. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53799. }
  53800. /**
  53801. * A list of the currently available features without referencing them
  53802. */
  53803. export class WebXRFeatureName {
  53804. /**
  53805. * The name of the anchor system feature
  53806. */
  53807. static readonly ANCHOR_SYSTEM: string;
  53808. /**
  53809. * The name of the background remover feature
  53810. */
  53811. static readonly BACKGROUND_REMOVER: string;
  53812. /**
  53813. * The name of the hit test feature
  53814. */
  53815. static readonly HIT_TEST: string;
  53816. /**
  53817. * The name of the mesh detection feature
  53818. */
  53819. static readonly MESH_DETECTION: string;
  53820. /**
  53821. * physics impostors for xr controllers feature
  53822. */
  53823. static readonly PHYSICS_CONTROLLERS: string;
  53824. /**
  53825. * The name of the plane detection feature
  53826. */
  53827. static readonly PLANE_DETECTION: string;
  53828. /**
  53829. * The name of the pointer selection feature
  53830. */
  53831. static readonly POINTER_SELECTION: string;
  53832. /**
  53833. * The name of the teleportation feature
  53834. */
  53835. static readonly TELEPORTATION: string;
  53836. /**
  53837. * The name of the feature points feature.
  53838. */
  53839. static readonly FEATURE_POINTS: string;
  53840. /**
  53841. * The name of the hand tracking feature.
  53842. */
  53843. static readonly HAND_TRACKING: string;
  53844. /**
  53845. * The name of the image tracking feature
  53846. */
  53847. static readonly IMAGE_TRACKING: string;
  53848. }
  53849. /**
  53850. * Defining the constructor of a feature. Used to register the modules.
  53851. */
  53852. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53853. /**
  53854. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53855. * It is mainly used in AR sessions.
  53856. *
  53857. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53858. */
  53859. export class WebXRFeaturesManager implements IDisposable {
  53860. private _xrSessionManager;
  53861. private static readonly _AvailableFeatures;
  53862. private _features;
  53863. /**
  53864. * constructs a new features manages.
  53865. *
  53866. * @param _xrSessionManager an instance of WebXRSessionManager
  53867. */
  53868. constructor(_xrSessionManager: WebXRSessionManager);
  53869. /**
  53870. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53871. * Mainly used internally.
  53872. *
  53873. * @param featureName the name of the feature to register
  53874. * @param constructorFunction the function used to construct the module
  53875. * @param version the (babylon) version of the module
  53876. * @param stable is that a stable version of this module
  53877. */
  53878. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53879. /**
  53880. * Returns a constructor of a specific feature.
  53881. *
  53882. * @param featureName the name of the feature to construct
  53883. * @param version the version of the feature to load
  53884. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53885. * @param options optional options provided to the module.
  53886. * @returns a function that, when called, will return a new instance of this feature
  53887. */
  53888. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53889. /**
  53890. * Can be used to return the list of features currently registered
  53891. *
  53892. * @returns an Array of available features
  53893. */
  53894. static GetAvailableFeatures(): string[];
  53895. /**
  53896. * Gets the versions available for a specific feature
  53897. * @param featureName the name of the feature
  53898. * @returns an array with the available versions
  53899. */
  53900. static GetAvailableVersions(featureName: string): string[];
  53901. /**
  53902. * Return the latest unstable version of this feature
  53903. * @param featureName the name of the feature to search
  53904. * @returns the version number. if not found will return -1
  53905. */
  53906. static GetLatestVersionOfFeature(featureName: string): number;
  53907. /**
  53908. * Return the latest stable version of this feature
  53909. * @param featureName the name of the feature to search
  53910. * @returns the version number. if not found will return -1
  53911. */
  53912. static GetStableVersionOfFeature(featureName: string): number;
  53913. /**
  53914. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53915. * Can be used during a session to start a feature
  53916. * @param featureName the name of feature to attach
  53917. */
  53918. attachFeature(featureName: string): void;
  53919. /**
  53920. * Can be used inside a session or when the session ends to detach a specific feature
  53921. * @param featureName the name of the feature to detach
  53922. */
  53923. detachFeature(featureName: string): void;
  53924. /**
  53925. * Used to disable an already-enabled feature
  53926. * The feature will be disposed and will be recreated once enabled.
  53927. * @param featureName the feature to disable
  53928. * @returns true if disable was successful
  53929. */
  53930. disableFeature(featureName: string | {
  53931. Name: string;
  53932. }): boolean;
  53933. /**
  53934. * dispose this features manager
  53935. */
  53936. dispose(): void;
  53937. /**
  53938. * 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.
  53939. * 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.
  53940. *
  53941. * @param featureName the name of the feature to load or the class of the feature
  53942. * @param version optional version to load. if not provided the latest version will be enabled
  53943. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53944. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53945. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53946. * @returns a new constructed feature or throws an error if feature not found.
  53947. */
  53948. enableFeature(featureName: string | {
  53949. Name: string;
  53950. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53951. /**
  53952. * get the implementation of an enabled feature.
  53953. * @param featureName the name of the feature to load
  53954. * @returns the feature class, if found
  53955. */
  53956. getEnabledFeature(featureName: string): IWebXRFeature;
  53957. /**
  53958. * Get the list of enabled features
  53959. * @returns an array of enabled features
  53960. */
  53961. getEnabledFeatures(): string[];
  53962. /**
  53963. * This function will extend the session creation configuration object with enabled features.
  53964. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53965. * according to the defined "required" variable, provided during enableFeature call
  53966. * @param xrSessionInit the xr Session init object to extend
  53967. *
  53968. * @returns an extended XRSessionInit object
  53969. */
  53970. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  53971. }
  53972. }
  53973. declare module BABYLON {
  53974. /**
  53975. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53976. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53977. */
  53978. export class WebXRExperienceHelper implements IDisposable {
  53979. private scene;
  53980. private _nonVRCamera;
  53981. private _originalSceneAutoClear;
  53982. private _supported;
  53983. /**
  53984. * Camera used to render xr content
  53985. */
  53986. camera: WebXRCamera;
  53987. /** A features manager for this xr session */
  53988. featuresManager: WebXRFeaturesManager;
  53989. /**
  53990. * Observers registered here will be triggered after the camera's initial transformation is set
  53991. * This can be used to set a different ground level or an extra rotation.
  53992. *
  53993. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53994. * to the position set after this observable is done executing.
  53995. */
  53996. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53997. /**
  53998. * Fires when the state of the experience helper has changed
  53999. */
  54000. onStateChangedObservable: Observable<WebXRState>;
  54001. /** Session manager used to keep track of xr session */
  54002. sessionManager: WebXRSessionManager;
  54003. /**
  54004. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54005. */
  54006. state: WebXRState;
  54007. /**
  54008. * Creates a WebXRExperienceHelper
  54009. * @param scene The scene the helper should be created in
  54010. */
  54011. private constructor();
  54012. /**
  54013. * Creates the experience helper
  54014. * @param scene the scene to attach the experience helper to
  54015. * @returns a promise for the experience helper
  54016. */
  54017. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54018. /**
  54019. * Disposes of the experience helper
  54020. */
  54021. dispose(): void;
  54022. /**
  54023. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54024. * @param sessionMode options for the XR session
  54025. * @param referenceSpaceType frame of reference of the XR session
  54026. * @param renderTarget the output canvas that will be used to enter XR mode
  54027. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54028. * @returns promise that resolves after xr mode has entered
  54029. */
  54030. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54031. /**
  54032. * Exits XR mode and returns the scene to its original state
  54033. * @returns promise that resolves after xr mode has exited
  54034. */
  54035. exitXRAsync(): Promise<void>;
  54036. private _nonXRToXRCamera;
  54037. private _setState;
  54038. }
  54039. }
  54040. declare module BABYLON {
  54041. /**
  54042. * X-Y values for axes in WebXR
  54043. */
  54044. export interface IWebXRMotionControllerAxesValue {
  54045. /**
  54046. * The value of the x axis
  54047. */
  54048. x: number;
  54049. /**
  54050. * The value of the y-axis
  54051. */
  54052. y: number;
  54053. }
  54054. /**
  54055. * changed / previous values for the values of this component
  54056. */
  54057. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54058. /**
  54059. * current (this frame) value
  54060. */
  54061. current: T;
  54062. /**
  54063. * previous (last change) value
  54064. */
  54065. previous: T;
  54066. }
  54067. /**
  54068. * Represents changes in the component between current frame and last values recorded
  54069. */
  54070. export interface IWebXRMotionControllerComponentChanges {
  54071. /**
  54072. * will be populated with previous and current values if axes changed
  54073. */
  54074. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54075. /**
  54076. * will be populated with previous and current values if pressed changed
  54077. */
  54078. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54079. /**
  54080. * will be populated with previous and current values if touched changed
  54081. */
  54082. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54083. /**
  54084. * will be populated with previous and current values if value changed
  54085. */
  54086. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54087. }
  54088. /**
  54089. * This class represents a single component (for example button or thumbstick) of a motion controller
  54090. */
  54091. export class WebXRControllerComponent implements IDisposable {
  54092. /**
  54093. * the id of this component
  54094. */
  54095. id: string;
  54096. /**
  54097. * the type of the component
  54098. */
  54099. type: MotionControllerComponentType;
  54100. private _buttonIndex;
  54101. private _axesIndices;
  54102. private _axes;
  54103. private _changes;
  54104. private _currentValue;
  54105. private _hasChanges;
  54106. private _pressed;
  54107. private _touched;
  54108. /**
  54109. * button component type
  54110. */
  54111. static BUTTON_TYPE: MotionControllerComponentType;
  54112. /**
  54113. * squeeze component type
  54114. */
  54115. static SQUEEZE_TYPE: MotionControllerComponentType;
  54116. /**
  54117. * Thumbstick component type
  54118. */
  54119. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54120. /**
  54121. * Touchpad component type
  54122. */
  54123. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54124. /**
  54125. * trigger component type
  54126. */
  54127. static TRIGGER_TYPE: MotionControllerComponentType;
  54128. /**
  54129. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54130. * the axes data changes
  54131. */
  54132. onAxisValueChangedObservable: Observable<{
  54133. x: number;
  54134. y: number;
  54135. }>;
  54136. /**
  54137. * Observers registered here will be triggered when the state of a button changes
  54138. * State change is either pressed / touched / value
  54139. */
  54140. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54141. /**
  54142. * Creates a new component for a motion controller.
  54143. * It is created by the motion controller itself
  54144. *
  54145. * @param id the id of this component
  54146. * @param type the type of the component
  54147. * @param _buttonIndex index in the buttons array of the gamepad
  54148. * @param _axesIndices indices of the values in the axes array of the gamepad
  54149. */
  54150. constructor(
  54151. /**
  54152. * the id of this component
  54153. */
  54154. id: string,
  54155. /**
  54156. * the type of the component
  54157. */
  54158. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54159. /**
  54160. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54161. */
  54162. get axes(): IWebXRMotionControllerAxesValue;
  54163. /**
  54164. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54165. */
  54166. get changes(): IWebXRMotionControllerComponentChanges;
  54167. /**
  54168. * Return whether or not the component changed the last frame
  54169. */
  54170. get hasChanges(): boolean;
  54171. /**
  54172. * is the button currently pressed
  54173. */
  54174. get pressed(): boolean;
  54175. /**
  54176. * is the button currently touched
  54177. */
  54178. get touched(): boolean;
  54179. /**
  54180. * Get the current value of this component
  54181. */
  54182. get value(): number;
  54183. /**
  54184. * Dispose this component
  54185. */
  54186. dispose(): void;
  54187. /**
  54188. * Are there axes correlating to this component
  54189. * @return true is axes data is available
  54190. */
  54191. isAxes(): boolean;
  54192. /**
  54193. * Is this component a button (hence - pressable)
  54194. * @returns true if can be pressed
  54195. */
  54196. isButton(): boolean;
  54197. /**
  54198. * update this component using the gamepad object it is in. Called on every frame
  54199. * @param nativeController the native gamepad controller object
  54200. */
  54201. update(nativeController: IMinimalMotionControllerObject): void;
  54202. }
  54203. }
  54204. declare module BABYLON {
  54205. /**
  54206. * Type used for the success callback of ImportMesh
  54207. */
  54208. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54209. /**
  54210. * Interface used for the result of ImportMeshAsync
  54211. */
  54212. export interface ISceneLoaderAsyncResult {
  54213. /**
  54214. * The array of loaded meshes
  54215. */
  54216. readonly meshes: AbstractMesh[];
  54217. /**
  54218. * The array of loaded particle systems
  54219. */
  54220. readonly particleSystems: IParticleSystem[];
  54221. /**
  54222. * The array of loaded skeletons
  54223. */
  54224. readonly skeletons: Skeleton[];
  54225. /**
  54226. * The array of loaded animation groups
  54227. */
  54228. readonly animationGroups: AnimationGroup[];
  54229. /**
  54230. * The array of loaded transform nodes
  54231. */
  54232. readonly transformNodes: TransformNode[];
  54233. /**
  54234. * The array of loaded geometries
  54235. */
  54236. readonly geometries: Geometry[];
  54237. /**
  54238. * The array of loaded lights
  54239. */
  54240. readonly lights: Light[];
  54241. }
  54242. /**
  54243. * Interface used to represent data loading progression
  54244. */
  54245. export interface ISceneLoaderProgressEvent {
  54246. /**
  54247. * Defines if data length to load can be evaluated
  54248. */
  54249. readonly lengthComputable: boolean;
  54250. /**
  54251. * Defines the loaded data length
  54252. */
  54253. readonly loaded: number;
  54254. /**
  54255. * Defines the data length to load
  54256. */
  54257. readonly total: number;
  54258. }
  54259. /**
  54260. * Interface used by SceneLoader plugins to define supported file extensions
  54261. */
  54262. export interface ISceneLoaderPluginExtensions {
  54263. /**
  54264. * Defines the list of supported extensions
  54265. */
  54266. [extension: string]: {
  54267. isBinary: boolean;
  54268. };
  54269. }
  54270. /**
  54271. * Interface used by SceneLoader plugin factory
  54272. */
  54273. export interface ISceneLoaderPluginFactory {
  54274. /**
  54275. * Defines the name of the factory
  54276. */
  54277. name: string;
  54278. /**
  54279. * Function called to create a new plugin
  54280. * @return the new plugin
  54281. */
  54282. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54283. /**
  54284. * The callback that returns true if the data can be directly loaded.
  54285. * @param data string containing the file data
  54286. * @returns if the data can be loaded directly
  54287. */
  54288. canDirectLoad?(data: string): boolean;
  54289. }
  54290. /**
  54291. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54292. */
  54293. export interface ISceneLoaderPluginBase {
  54294. /**
  54295. * The friendly name of this plugin.
  54296. */
  54297. name: string;
  54298. /**
  54299. * The file extensions supported by this plugin.
  54300. */
  54301. extensions: string | ISceneLoaderPluginExtensions;
  54302. /**
  54303. * The callback called when loading from a url.
  54304. * @param scene scene loading this url
  54305. * @param url url to load
  54306. * @param onSuccess callback called when the file successfully loads
  54307. * @param onProgress callback called while file is loading (if the server supports this mode)
  54308. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54309. * @param onError callback called when the file fails to load
  54310. * @returns a file request object
  54311. */
  54312. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54313. /**
  54314. * The callback called when loading from a file object.
  54315. * @param scene scene loading this file
  54316. * @param file defines the file to load
  54317. * @param onSuccess defines the callback to call when data is loaded
  54318. * @param onProgress defines the callback to call during loading process
  54319. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54320. * @param onError defines the callback to call when an error occurs
  54321. * @returns a file request object
  54322. */
  54323. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54324. /**
  54325. * The callback that returns true if the data can be directly loaded.
  54326. * @param data string containing the file data
  54327. * @returns if the data can be loaded directly
  54328. */
  54329. canDirectLoad?(data: string): boolean;
  54330. /**
  54331. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54332. * @param scene scene loading this data
  54333. * @param data string containing the data
  54334. * @returns data to pass to the plugin
  54335. */
  54336. directLoad?(scene: Scene, data: string): any;
  54337. /**
  54338. * The callback that allows custom handling of the root url based on the response url.
  54339. * @param rootUrl the original root url
  54340. * @param responseURL the response url if available
  54341. * @returns the new root url
  54342. */
  54343. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54344. }
  54345. /**
  54346. * Interface used to define a SceneLoader plugin
  54347. */
  54348. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54349. /**
  54350. * Import meshes into a scene.
  54351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54352. * @param scene The scene to import into
  54353. * @param data The data to import
  54354. * @param rootUrl The root url for scene and resources
  54355. * @param meshes The meshes array to import into
  54356. * @param particleSystems The particle systems array to import into
  54357. * @param skeletons The skeletons array to import into
  54358. * @param onError The callback when import fails
  54359. * @returns True if successful or false otherwise
  54360. */
  54361. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54362. /**
  54363. * Load into a scene.
  54364. * @param scene The scene to load into
  54365. * @param data The data to import
  54366. * @param rootUrl The root url for scene and resources
  54367. * @param onError The callback when import fails
  54368. * @returns True if successful or false otherwise
  54369. */
  54370. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54371. /**
  54372. * Load into an asset container.
  54373. * @param scene The scene to load into
  54374. * @param data The data to import
  54375. * @param rootUrl The root url for scene and resources
  54376. * @param onError The callback when import fails
  54377. * @returns The loaded asset container
  54378. */
  54379. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54380. }
  54381. /**
  54382. * Interface used to define an async SceneLoader plugin
  54383. */
  54384. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54385. /**
  54386. * Import meshes into a scene.
  54387. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54388. * @param scene The scene to import into
  54389. * @param data The data to import
  54390. * @param rootUrl The root url for scene and resources
  54391. * @param onProgress The callback when the load progresses
  54392. * @param fileName Defines the name of the file to load
  54393. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54394. */
  54395. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54396. /**
  54397. * Load into a scene.
  54398. * @param scene The scene to load into
  54399. * @param data The data to import
  54400. * @param rootUrl The root url for scene and resources
  54401. * @param onProgress The callback when the load progresses
  54402. * @param fileName Defines the name of the file to load
  54403. * @returns Nothing
  54404. */
  54405. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54406. /**
  54407. * Load into an asset container.
  54408. * @param scene The scene to load into
  54409. * @param data The data to import
  54410. * @param rootUrl The root url for scene and resources
  54411. * @param onProgress The callback when the load progresses
  54412. * @param fileName Defines the name of the file to load
  54413. * @returns The loaded asset container
  54414. */
  54415. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54416. }
  54417. /**
  54418. * Mode that determines how to handle old animation groups before loading new ones.
  54419. */
  54420. export enum SceneLoaderAnimationGroupLoadingMode {
  54421. /**
  54422. * Reset all old animations to initial state then dispose them.
  54423. */
  54424. Clean = 0,
  54425. /**
  54426. * Stop all old animations.
  54427. */
  54428. Stop = 1,
  54429. /**
  54430. * Restart old animations from first frame.
  54431. */
  54432. Sync = 2,
  54433. /**
  54434. * Old animations remains untouched.
  54435. */
  54436. NoSync = 3
  54437. }
  54438. /**
  54439. * Defines a plugin registered by the SceneLoader
  54440. */
  54441. interface IRegisteredPlugin {
  54442. /**
  54443. * Defines the plugin to use
  54444. */
  54445. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54446. /**
  54447. * Defines if the plugin supports binary data
  54448. */
  54449. isBinary: boolean;
  54450. }
  54451. /**
  54452. * Class used to load scene from various file formats using registered plugins
  54453. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54454. */
  54455. export class SceneLoader {
  54456. /**
  54457. * No logging while loading
  54458. */
  54459. static readonly NO_LOGGING: number;
  54460. /**
  54461. * Minimal logging while loading
  54462. */
  54463. static readonly MINIMAL_LOGGING: number;
  54464. /**
  54465. * Summary logging while loading
  54466. */
  54467. static readonly SUMMARY_LOGGING: number;
  54468. /**
  54469. * Detailled logging while loading
  54470. */
  54471. static readonly DETAILED_LOGGING: number;
  54472. /**
  54473. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54474. */
  54475. static get ForceFullSceneLoadingForIncremental(): boolean;
  54476. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54477. /**
  54478. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54479. */
  54480. static get ShowLoadingScreen(): boolean;
  54481. static set ShowLoadingScreen(value: boolean);
  54482. /**
  54483. * Defines the current logging level (while loading the scene)
  54484. * @ignorenaming
  54485. */
  54486. static get loggingLevel(): number;
  54487. static set loggingLevel(value: number);
  54488. /**
  54489. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54490. */
  54491. static get CleanBoneMatrixWeights(): boolean;
  54492. static set CleanBoneMatrixWeights(value: boolean);
  54493. /**
  54494. * Event raised when a plugin is used to load a scene
  54495. */
  54496. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54497. private static _registeredPlugins;
  54498. private static _showingLoadingScreen;
  54499. /**
  54500. * Gets the default plugin (used to load Babylon files)
  54501. * @returns the .babylon plugin
  54502. */
  54503. static GetDefaultPlugin(): IRegisteredPlugin;
  54504. private static _GetPluginForExtension;
  54505. private static _GetPluginForDirectLoad;
  54506. private static _GetPluginForFilename;
  54507. private static _GetDirectLoad;
  54508. private static _LoadData;
  54509. private static _GetFileInfo;
  54510. /**
  54511. * Gets a plugin that can load the given extension
  54512. * @param extension defines the extension to load
  54513. * @returns a plugin or null if none works
  54514. */
  54515. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54516. /**
  54517. * Gets a boolean indicating that the given extension can be loaded
  54518. * @param extension defines the extension to load
  54519. * @returns true if the extension is supported
  54520. */
  54521. static IsPluginForExtensionAvailable(extension: string): boolean;
  54522. /**
  54523. * Adds a new plugin to the list of registered plugins
  54524. * @param plugin defines the plugin to add
  54525. */
  54526. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54527. /**
  54528. * Import meshes into a scene
  54529. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54530. * @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)
  54531. * @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)
  54532. * @param scene the instance of BABYLON.Scene to append to
  54533. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54534. * @param onProgress a callback with a progress event for each file being loaded
  54535. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54536. * @param pluginExtension the extension used to determine the plugin
  54537. * @returns The loaded plugin
  54538. */
  54539. 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>;
  54540. /**
  54541. * Import meshes into a scene
  54542. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54543. * @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)
  54544. * @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)
  54545. * @param scene the instance of BABYLON.Scene to append to
  54546. * @param onProgress a callback with a progress event for each file being loaded
  54547. * @param pluginExtension the extension used to determine the plugin
  54548. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54549. */
  54550. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54551. /**
  54552. * Load a scene
  54553. * @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)
  54554. * @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)
  54555. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54556. * @param onSuccess a callback with the scene when import succeeds
  54557. * @param onProgress a callback with a progress event for each file being loaded
  54558. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54559. * @param pluginExtension the extension used to determine the plugin
  54560. * @returns The loaded plugin
  54561. */
  54562. 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>;
  54563. /**
  54564. * Load a scene
  54565. * @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)
  54566. * @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)
  54567. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54568. * @param onProgress a callback with a progress event for each file being loaded
  54569. * @param pluginExtension the extension used to determine the plugin
  54570. * @returns The loaded scene
  54571. */
  54572. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54573. /**
  54574. * Append a scene
  54575. * @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)
  54576. * @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)
  54577. * @param scene is the instance of BABYLON.Scene to append to
  54578. * @param onSuccess a callback with the scene when import succeeds
  54579. * @param onProgress a callback with a progress event for each file being loaded
  54580. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54581. * @param pluginExtension the extension used to determine the plugin
  54582. * @returns The loaded plugin
  54583. */
  54584. 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>;
  54585. /**
  54586. * Append a scene
  54587. * @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)
  54588. * @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)
  54589. * @param scene is the instance of BABYLON.Scene to append to
  54590. * @param onProgress a callback with a progress event for each file being loaded
  54591. * @param pluginExtension the extension used to determine the plugin
  54592. * @returns The given scene
  54593. */
  54594. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54595. /**
  54596. * Load a scene into an asset container
  54597. * @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)
  54598. * @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)
  54599. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54600. * @param onSuccess a callback with the scene when import succeeds
  54601. * @param onProgress a callback with a progress event for each file being loaded
  54602. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54603. * @param pluginExtension the extension used to determine the plugin
  54604. * @returns The loaded plugin
  54605. */
  54606. 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>;
  54607. /**
  54608. * Load a scene into an asset container
  54609. * @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)
  54610. * @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)
  54611. * @param scene is the instance of Scene to append to
  54612. * @param onProgress a callback with a progress event for each file being loaded
  54613. * @param pluginExtension the extension used to determine the plugin
  54614. * @returns The loaded asset container
  54615. */
  54616. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54617. /**
  54618. * Import animations from a file into a scene
  54619. * @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)
  54620. * @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)
  54621. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54622. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54623. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54624. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54625. * @param onSuccess a callback with the scene when import succeeds
  54626. * @param onProgress a callback with a progress event for each file being loaded
  54627. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54628. * @param pluginExtension the extension used to determine the plugin
  54629. */
  54630. 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;
  54631. /**
  54632. * Import animations from a file into a scene
  54633. * @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)
  54634. * @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)
  54635. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54636. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54637. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54638. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54639. * @param onSuccess a callback with the scene when import succeeds
  54640. * @param onProgress a callback with a progress event for each file being loaded
  54641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54642. * @param pluginExtension the extension used to determine the plugin
  54643. * @returns the updated scene with imported animations
  54644. */
  54645. 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>;
  54646. }
  54647. }
  54648. declare module BABYLON {
  54649. /**
  54650. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54651. */
  54652. export type MotionControllerHandedness = "none" | "left" | "right";
  54653. /**
  54654. * The type of components available in motion controllers.
  54655. * This is not the name of the component.
  54656. */
  54657. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54658. /**
  54659. * The state of a controller component
  54660. */
  54661. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54662. /**
  54663. * The schema of motion controller layout.
  54664. * No object will be initialized using this interface
  54665. * This is used just to define the profile.
  54666. */
  54667. export interface IMotionControllerLayout {
  54668. /**
  54669. * Path to load the assets. Usually relative to the base path
  54670. */
  54671. assetPath: string;
  54672. /**
  54673. * Available components (unsorted)
  54674. */
  54675. components: {
  54676. /**
  54677. * A map of component Ids
  54678. */
  54679. [componentId: string]: {
  54680. /**
  54681. * The type of input the component outputs
  54682. */
  54683. type: MotionControllerComponentType;
  54684. /**
  54685. * The indices of this component in the gamepad object
  54686. */
  54687. gamepadIndices: {
  54688. /**
  54689. * Index of button
  54690. */
  54691. button?: number;
  54692. /**
  54693. * If available, index of x-axis
  54694. */
  54695. xAxis?: number;
  54696. /**
  54697. * If available, index of y-axis
  54698. */
  54699. yAxis?: number;
  54700. };
  54701. /**
  54702. * The mesh's root node name
  54703. */
  54704. rootNodeName: string;
  54705. /**
  54706. * Animation definitions for this model
  54707. */
  54708. visualResponses: {
  54709. [stateKey: string]: {
  54710. /**
  54711. * What property will be animated
  54712. */
  54713. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54714. /**
  54715. * What states influence this visual response
  54716. */
  54717. states: MotionControllerComponentStateType[];
  54718. /**
  54719. * Type of animation - movement or visibility
  54720. */
  54721. valueNodeProperty: "transform" | "visibility";
  54722. /**
  54723. * Base node name to move. Its position will be calculated according to the min and max nodes
  54724. */
  54725. valueNodeName?: string;
  54726. /**
  54727. * Minimum movement node
  54728. */
  54729. minNodeName?: string;
  54730. /**
  54731. * Max movement node
  54732. */
  54733. maxNodeName?: string;
  54734. };
  54735. };
  54736. /**
  54737. * If touch enabled, what is the name of node to display user feedback
  54738. */
  54739. touchPointNodeName?: string;
  54740. };
  54741. };
  54742. /**
  54743. * Is it xr standard mapping or not
  54744. */
  54745. gamepadMapping: "" | "xr-standard";
  54746. /**
  54747. * Base root node of this entire model
  54748. */
  54749. rootNodeName: string;
  54750. /**
  54751. * Defines the main button component id
  54752. */
  54753. selectComponentId: string;
  54754. }
  54755. /**
  54756. * A definition for the layout map in the input profile
  54757. */
  54758. export interface IMotionControllerLayoutMap {
  54759. /**
  54760. * Layouts with handedness type as a key
  54761. */
  54762. [handedness: string]: IMotionControllerLayout;
  54763. }
  54764. /**
  54765. * The XR Input profile schema
  54766. * Profiles can be found here:
  54767. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54768. */
  54769. export interface IMotionControllerProfile {
  54770. /**
  54771. * fallback profiles for this profileId
  54772. */
  54773. fallbackProfileIds: string[];
  54774. /**
  54775. * The layout map, with handedness as key
  54776. */
  54777. layouts: IMotionControllerLayoutMap;
  54778. /**
  54779. * The id of this profile
  54780. * correlates to the profile(s) in the xrInput.profiles array
  54781. */
  54782. profileId: string;
  54783. }
  54784. /**
  54785. * A helper-interface for the 3 meshes needed for controller button animation
  54786. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54787. */
  54788. export interface IMotionControllerButtonMeshMap {
  54789. /**
  54790. * the mesh that defines the pressed value mesh position.
  54791. * This is used to find the max-position of this button
  54792. */
  54793. pressedMesh: AbstractMesh;
  54794. /**
  54795. * the mesh that defines the unpressed value mesh position.
  54796. * This is used to find the min (or initial) position of this button
  54797. */
  54798. unpressedMesh: AbstractMesh;
  54799. /**
  54800. * The mesh that will be changed when value changes
  54801. */
  54802. valueMesh: AbstractMesh;
  54803. }
  54804. /**
  54805. * A helper-interface for the 3 meshes needed for controller axis animation.
  54806. * This will be expanded when touchpad animations are fully supported
  54807. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54808. */
  54809. export interface IMotionControllerMeshMap {
  54810. /**
  54811. * the mesh that defines the maximum value mesh position.
  54812. */
  54813. maxMesh?: AbstractMesh;
  54814. /**
  54815. * the mesh that defines the minimum value mesh position.
  54816. */
  54817. minMesh?: AbstractMesh;
  54818. /**
  54819. * The mesh that will be changed when axis value changes
  54820. */
  54821. valueMesh?: AbstractMesh;
  54822. }
  54823. /**
  54824. * The elements needed for change-detection of the gamepad objects in motion controllers
  54825. */
  54826. export interface IMinimalMotionControllerObject {
  54827. /**
  54828. * Available axes of this controller
  54829. */
  54830. axes: number[];
  54831. /**
  54832. * An array of available buttons
  54833. */
  54834. buttons: Array<{
  54835. /**
  54836. * Value of the button/trigger
  54837. */
  54838. value: number;
  54839. /**
  54840. * If the button/trigger is currently touched
  54841. */
  54842. touched: boolean;
  54843. /**
  54844. * If the button/trigger is currently pressed
  54845. */
  54846. pressed: boolean;
  54847. }>;
  54848. /**
  54849. * EXPERIMENTAL haptic support.
  54850. */
  54851. hapticActuators?: Array<{
  54852. pulse: (value: number, duration: number) => Promise<boolean>;
  54853. }>;
  54854. }
  54855. /**
  54856. * An Abstract Motion controller
  54857. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54858. * Each component has an observable to check for changes in value and state
  54859. */
  54860. export abstract class WebXRAbstractMotionController implements IDisposable {
  54861. protected scene: Scene;
  54862. protected layout: IMotionControllerLayout;
  54863. /**
  54864. * The gamepad object correlating to this controller
  54865. */
  54866. gamepadObject: IMinimalMotionControllerObject;
  54867. /**
  54868. * handedness (left/right/none) of this controller
  54869. */
  54870. handedness: MotionControllerHandedness;
  54871. private _initComponent;
  54872. private _modelReady;
  54873. /**
  54874. * A map of components (WebXRControllerComponent) in this motion controller
  54875. * Components have a ComponentType and can also have both button and axis definitions
  54876. */
  54877. readonly components: {
  54878. [id: string]: WebXRControllerComponent;
  54879. };
  54880. /**
  54881. * Disable the model's animation. Can be set at any time.
  54882. */
  54883. disableAnimation: boolean;
  54884. /**
  54885. * Observers registered here will be triggered when the model of this controller is done loading
  54886. */
  54887. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54888. /**
  54889. * The profile id of this motion controller
  54890. */
  54891. abstract profileId: string;
  54892. /**
  54893. * The root mesh of the model. It is null if the model was not yet initialized
  54894. */
  54895. rootMesh: Nullable<AbstractMesh>;
  54896. /**
  54897. * constructs a new abstract motion controller
  54898. * @param scene the scene to which the model of the controller will be added
  54899. * @param layout The profile layout to load
  54900. * @param gamepadObject The gamepad object correlating to this controller
  54901. * @param handedness handedness (left/right/none) of this controller
  54902. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54903. */
  54904. constructor(scene: Scene, layout: IMotionControllerLayout,
  54905. /**
  54906. * The gamepad object correlating to this controller
  54907. */
  54908. gamepadObject: IMinimalMotionControllerObject,
  54909. /**
  54910. * handedness (left/right/none) of this controller
  54911. */
  54912. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54913. /**
  54914. * Dispose this controller, the model mesh and all its components
  54915. */
  54916. dispose(): void;
  54917. /**
  54918. * Returns all components of specific type
  54919. * @param type the type to search for
  54920. * @return an array of components with this type
  54921. */
  54922. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54923. /**
  54924. * get a component based an its component id as defined in layout.components
  54925. * @param id the id of the component
  54926. * @returns the component correlates to the id or undefined if not found
  54927. */
  54928. getComponent(id: string): WebXRControllerComponent;
  54929. /**
  54930. * Get the list of components available in this motion controller
  54931. * @returns an array of strings correlating to available components
  54932. */
  54933. getComponentIds(): string[];
  54934. /**
  54935. * Get the first component of specific type
  54936. * @param type type of component to find
  54937. * @return a controller component or null if not found
  54938. */
  54939. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54940. /**
  54941. * Get the main (Select) component of this controller as defined in the layout
  54942. * @returns the main component of this controller
  54943. */
  54944. getMainComponent(): WebXRControllerComponent;
  54945. /**
  54946. * Loads the model correlating to this controller
  54947. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54948. * @returns A promise fulfilled with the result of the model loading
  54949. */
  54950. loadModel(): Promise<boolean>;
  54951. /**
  54952. * Update this model using the current XRFrame
  54953. * @param xrFrame the current xr frame to use and update the model
  54954. */
  54955. updateFromXRFrame(xrFrame: XRFrame): void;
  54956. /**
  54957. * Backwards compatibility due to a deeply-integrated typo
  54958. */
  54959. get handness(): XREye;
  54960. /**
  54961. * Pulse (vibrate) this controller
  54962. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54963. * Consecutive calls to this function will cancel the last pulse call
  54964. *
  54965. * @param value the strength of the pulse in 0.0...1.0 range
  54966. * @param duration Duration of the pulse in milliseconds
  54967. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54968. * @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
  54969. */
  54970. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54971. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54972. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54973. /**
  54974. * Moves the axis on the controller mesh based on its current state
  54975. * @param axis the index of the axis
  54976. * @param axisValue the value of the axis which determines the meshes new position
  54977. * @hidden
  54978. */
  54979. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54980. /**
  54981. * Update the model itself with the current frame data
  54982. * @param xrFrame the frame to use for updating the model mesh
  54983. */
  54984. protected updateModel(xrFrame: XRFrame): void;
  54985. /**
  54986. * Get the filename and path for this controller's model
  54987. * @returns a map of filename and path
  54988. */
  54989. protected abstract _getFilenameAndPath(): {
  54990. filename: string;
  54991. path: string;
  54992. };
  54993. /**
  54994. * This function is called before the mesh is loaded. It checks for loading constraints.
  54995. * For example, this function can check if the GLB loader is available
  54996. * If this function returns false, the generic controller will be loaded instead
  54997. * @returns Is the client ready to load the mesh
  54998. */
  54999. protected abstract _getModelLoadingConstraints(): boolean;
  55000. /**
  55001. * This function will be called after the model was successfully loaded and can be used
  55002. * for mesh transformations before it is available for the user
  55003. * @param meshes the loaded meshes
  55004. */
  55005. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55006. /**
  55007. * Set the root mesh for this controller. Important for the WebXR controller class
  55008. * @param meshes the loaded meshes
  55009. */
  55010. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55011. /**
  55012. * A function executed each frame that updates the mesh (if needed)
  55013. * @param xrFrame the current xrFrame
  55014. */
  55015. protected abstract _updateModel(xrFrame: XRFrame): void;
  55016. private _getGenericFilenameAndPath;
  55017. private _getGenericParentMesh;
  55018. }
  55019. }
  55020. declare module BABYLON {
  55021. /**
  55022. * A generic trigger-only motion controller for WebXR
  55023. */
  55024. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55025. /**
  55026. * Static version of the profile id of this controller
  55027. */
  55028. static ProfileId: string;
  55029. profileId: string;
  55030. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55031. protected _getFilenameAndPath(): {
  55032. filename: string;
  55033. path: string;
  55034. };
  55035. protected _getModelLoadingConstraints(): boolean;
  55036. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55037. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55038. protected _updateModel(): void;
  55039. }
  55040. }
  55041. declare module BABYLON {
  55042. /**
  55043. * Class containing static functions to help procedurally build meshes
  55044. */
  55045. export class SphereBuilder {
  55046. /**
  55047. * Creates a sphere mesh
  55048. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55049. * * 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`)
  55050. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55051. * * 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
  55052. * * 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)
  55053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55054. * * 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
  55055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55056. * @param name defines the name of the mesh
  55057. * @param options defines the options used to create the mesh
  55058. * @param scene defines the hosting scene
  55059. * @returns the sphere mesh
  55060. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55061. */
  55062. static CreateSphere(name: string, options: {
  55063. segments?: number;
  55064. diameter?: number;
  55065. diameterX?: number;
  55066. diameterY?: number;
  55067. diameterZ?: number;
  55068. arc?: number;
  55069. slice?: number;
  55070. sideOrientation?: number;
  55071. frontUVs?: Vector4;
  55072. backUVs?: Vector4;
  55073. updatable?: boolean;
  55074. }, scene?: Nullable<Scene>): Mesh;
  55075. }
  55076. }
  55077. declare module BABYLON {
  55078. /**
  55079. * A profiled motion controller has its profile loaded from an online repository.
  55080. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55081. */
  55082. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55083. private _repositoryUrl;
  55084. private _buttonMeshMapping;
  55085. private _touchDots;
  55086. /**
  55087. * The profile ID of this controller. Will be populated when the controller initializes.
  55088. */
  55089. profileId: string;
  55090. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55091. dispose(): void;
  55092. protected _getFilenameAndPath(): {
  55093. filename: string;
  55094. path: string;
  55095. };
  55096. protected _getModelLoadingConstraints(): boolean;
  55097. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55098. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55099. protected _updateModel(_xrFrame: XRFrame): void;
  55100. }
  55101. }
  55102. declare module BABYLON {
  55103. /**
  55104. * A construction function type to create a new controller based on an xrInput object
  55105. */
  55106. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55107. /**
  55108. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55109. *
  55110. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55111. * it should be replaced with auto-loaded controllers.
  55112. *
  55113. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55114. */
  55115. export class WebXRMotionControllerManager {
  55116. private static _AvailableControllers;
  55117. private static _Fallbacks;
  55118. private static _ProfileLoadingPromises;
  55119. private static _ProfilesList;
  55120. /**
  55121. * The base URL of the online controller repository. Can be changed at any time.
  55122. */
  55123. static BaseRepositoryUrl: string;
  55124. /**
  55125. * Which repository gets priority - local or online
  55126. */
  55127. static PrioritizeOnlineRepository: boolean;
  55128. /**
  55129. * Use the online repository, or use only locally-defined controllers
  55130. */
  55131. static UseOnlineRepository: boolean;
  55132. /**
  55133. * Clear the cache used for profile loading and reload when requested again
  55134. */
  55135. static ClearProfilesCache(): void;
  55136. /**
  55137. * Register the default fallbacks.
  55138. * This function is called automatically when this file is imported.
  55139. */
  55140. static DefaultFallbacks(): void;
  55141. /**
  55142. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55143. * @param profileId the profile to which a fallback needs to be found
  55144. * @return an array with corresponding fallback profiles
  55145. */
  55146. static FindFallbackWithProfileId(profileId: string): string[];
  55147. /**
  55148. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55149. * The order of search:
  55150. *
  55151. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55152. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55153. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55154. * 4) return the generic trigger controller if none were found
  55155. *
  55156. * @param xrInput the xrInput to which a new controller is initialized
  55157. * @param scene the scene to which the model will be added
  55158. * @param forceProfile force a certain profile for this controller
  55159. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55160. */
  55161. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55162. /**
  55163. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55164. *
  55165. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55166. *
  55167. * @param type the profile type to register
  55168. * @param constructFunction the function to be called when loading this profile
  55169. */
  55170. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55171. /**
  55172. * Register a fallback to a specific profile.
  55173. * @param profileId the profileId that will receive the fallbacks
  55174. * @param fallbacks A list of fallback profiles
  55175. */
  55176. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55177. /**
  55178. * Will update the list of profiles available in the repository
  55179. * @return a promise that resolves to a map of profiles available online
  55180. */
  55181. static UpdateProfilesList(): Promise<{
  55182. [profile: string]: string;
  55183. }>;
  55184. private static _LoadProfileFromRepository;
  55185. private static _LoadProfilesFromAvailableControllers;
  55186. }
  55187. }
  55188. declare module BABYLON {
  55189. /**
  55190. * Configuration options for the WebXR controller creation
  55191. */
  55192. export interface IWebXRControllerOptions {
  55193. /**
  55194. * Should the controller mesh be animated when a user interacts with it
  55195. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55196. */
  55197. disableMotionControllerAnimation?: boolean;
  55198. /**
  55199. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55200. */
  55201. doNotLoadControllerMesh?: boolean;
  55202. /**
  55203. * Force a specific controller type for this controller.
  55204. * This can be used when creating your own profile or when testing different controllers
  55205. */
  55206. forceControllerProfile?: string;
  55207. /**
  55208. * Defines a rendering group ID for meshes that will be loaded.
  55209. * This is for the default controllers only.
  55210. */
  55211. renderingGroupId?: number;
  55212. }
  55213. /**
  55214. * Represents an XR controller
  55215. */
  55216. export class WebXRInputSource {
  55217. private _scene;
  55218. /** The underlying input source for the controller */
  55219. inputSource: XRInputSource;
  55220. private _options;
  55221. private _tmpVector;
  55222. private _uniqueId;
  55223. private _disposed;
  55224. /**
  55225. * 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
  55226. */
  55227. grip?: AbstractMesh;
  55228. /**
  55229. * If available, this is the gamepad object related to this controller.
  55230. * Using this object it is possible to get click events and trackpad changes of the
  55231. * webxr controller that is currently being used.
  55232. */
  55233. motionController?: WebXRAbstractMotionController;
  55234. /**
  55235. * Event that fires when the controller is removed/disposed.
  55236. * The object provided as event data is this controller, after associated assets were disposed.
  55237. * uniqueId is still available.
  55238. */
  55239. onDisposeObservable: Observable<WebXRInputSource>;
  55240. /**
  55241. * Will be triggered when the mesh associated with the motion controller is done loading.
  55242. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55243. * A shortened version of controller -> motion controller -> on mesh loaded.
  55244. */
  55245. onMeshLoadedObservable: Observable<AbstractMesh>;
  55246. /**
  55247. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55248. */
  55249. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55250. /**
  55251. * Pointer which can be used to select objects or attach a visible laser to
  55252. */
  55253. pointer: AbstractMesh;
  55254. /**
  55255. * Creates the input source object
  55256. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55257. * @param _scene the scene which the controller should be associated to
  55258. * @param inputSource the underlying input source for the controller
  55259. * @param _options options for this controller creation
  55260. */
  55261. constructor(_scene: Scene,
  55262. /** The underlying input source for the controller */
  55263. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55264. /**
  55265. * Get this controllers unique id
  55266. */
  55267. get uniqueId(): string;
  55268. /**
  55269. * Disposes of the object
  55270. */
  55271. dispose(): void;
  55272. /**
  55273. * Gets a world space ray coming from the pointer or grip
  55274. * @param result the resulting ray
  55275. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55276. */
  55277. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55278. /**
  55279. * Updates the controller pose based on the given XRFrame
  55280. * @param xrFrame xr frame to update the pose with
  55281. * @param referenceSpace reference space to use
  55282. */
  55283. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55284. }
  55285. }
  55286. declare module BABYLON {
  55287. /**
  55288. * The schema for initialization options of the XR Input class
  55289. */
  55290. export interface IWebXRInputOptions {
  55291. /**
  55292. * If set to true no model will be automatically loaded
  55293. */
  55294. doNotLoadControllerMeshes?: boolean;
  55295. /**
  55296. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55297. * If not found, the xr input profile data will be used.
  55298. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55299. */
  55300. forceInputProfile?: string;
  55301. /**
  55302. * Do not send a request to the controller repository to load the profile.
  55303. *
  55304. * Instead, use the controllers available in babylon itself.
  55305. */
  55306. disableOnlineControllerRepository?: boolean;
  55307. /**
  55308. * A custom URL for the controllers repository
  55309. */
  55310. customControllersRepositoryURL?: string;
  55311. /**
  55312. * Should the controller model's components not move according to the user input
  55313. */
  55314. disableControllerAnimation?: boolean;
  55315. /**
  55316. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55317. */
  55318. controllerOptions?: IWebXRControllerOptions;
  55319. }
  55320. /**
  55321. * XR input used to track XR inputs such as controllers/rays
  55322. */
  55323. export class WebXRInput implements IDisposable {
  55324. /**
  55325. * the xr session manager for this session
  55326. */
  55327. xrSessionManager: WebXRSessionManager;
  55328. /**
  55329. * the WebXR camera for this session. Mainly used for teleportation
  55330. */
  55331. xrCamera: WebXRCamera;
  55332. private readonly options;
  55333. /**
  55334. * XR controllers being tracked
  55335. */
  55336. controllers: Array<WebXRInputSource>;
  55337. private _frameObserver;
  55338. private _sessionEndedObserver;
  55339. private _sessionInitObserver;
  55340. /**
  55341. * Event when a controller has been connected/added
  55342. */
  55343. onControllerAddedObservable: Observable<WebXRInputSource>;
  55344. /**
  55345. * Event when a controller has been removed/disconnected
  55346. */
  55347. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55348. /**
  55349. * Initializes the WebXRInput
  55350. * @param xrSessionManager the xr session manager for this session
  55351. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55352. * @param options = initialization options for this xr input
  55353. */
  55354. constructor(
  55355. /**
  55356. * the xr session manager for this session
  55357. */
  55358. xrSessionManager: WebXRSessionManager,
  55359. /**
  55360. * the WebXR camera for this session. Mainly used for teleportation
  55361. */
  55362. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55363. private _onInputSourcesChange;
  55364. private _addAndRemoveControllers;
  55365. /**
  55366. * Disposes of the object
  55367. */
  55368. dispose(): void;
  55369. }
  55370. }
  55371. declare module BABYLON {
  55372. /**
  55373. * This is the base class for all WebXR features.
  55374. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55375. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55376. */
  55377. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55378. protected _xrSessionManager: WebXRSessionManager;
  55379. private _attached;
  55380. private _removeOnDetach;
  55381. /**
  55382. * Is this feature disposed?
  55383. */
  55384. isDisposed: boolean;
  55385. /**
  55386. * Should auto-attach be disabled?
  55387. */
  55388. disableAutoAttach: boolean;
  55389. /**
  55390. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55391. */
  55392. xrNativeFeatureName: string;
  55393. /**
  55394. * Construct a new (abstract) WebXR feature
  55395. * @param _xrSessionManager the xr session manager for this feature
  55396. */
  55397. constructor(_xrSessionManager: WebXRSessionManager);
  55398. /**
  55399. * Is this feature attached
  55400. */
  55401. get attached(): boolean;
  55402. /**
  55403. * attach this feature
  55404. *
  55405. * @param force should attachment be forced (even when already attached)
  55406. * @returns true if successful, false is failed or already attached
  55407. */
  55408. attach(force?: boolean): boolean;
  55409. /**
  55410. * detach this feature.
  55411. *
  55412. * @returns true if successful, false if failed or already detached
  55413. */
  55414. detach(): boolean;
  55415. /**
  55416. * Dispose this feature and all of the resources attached
  55417. */
  55418. dispose(): void;
  55419. /**
  55420. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55421. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55422. *
  55423. * @returns whether or not the feature is compatible in this environment
  55424. */
  55425. isCompatible(): boolean;
  55426. /**
  55427. * This is used to register callbacks that will automatically be removed when detach is called.
  55428. * @param observable the observable to which the observer will be attached
  55429. * @param callback the callback to register
  55430. */
  55431. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55432. /**
  55433. * Code in this function will be executed on each xrFrame received from the browser.
  55434. * This function will not execute after the feature is detached.
  55435. * @param _xrFrame the current frame
  55436. */
  55437. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55438. }
  55439. }
  55440. declare module BABYLON {
  55441. /**
  55442. * Renders a layer on top of an existing scene
  55443. */
  55444. export class UtilityLayerRenderer implements IDisposable {
  55445. /** the original scene that will be rendered on top of */
  55446. originalScene: Scene;
  55447. private _pointerCaptures;
  55448. private _lastPointerEvents;
  55449. private static _DefaultUtilityLayer;
  55450. private static _DefaultKeepDepthUtilityLayer;
  55451. private _sharedGizmoLight;
  55452. private _renderCamera;
  55453. /**
  55454. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55455. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55456. * @returns the camera that is used when rendering the utility layer
  55457. */
  55458. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55459. /**
  55460. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55461. * @param cam the camera that should be used when rendering the utility layer
  55462. */
  55463. setRenderCamera(cam: Nullable<Camera>): void;
  55464. /**
  55465. * @hidden
  55466. * Light which used by gizmos to get light shading
  55467. */
  55468. _getSharedGizmoLight(): HemisphericLight;
  55469. /**
  55470. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55471. */
  55472. pickUtilitySceneFirst: boolean;
  55473. /**
  55474. * 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)
  55475. */
  55476. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55477. /**
  55478. * 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)
  55479. */
  55480. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55481. /**
  55482. * The scene that is rendered on top of the original scene
  55483. */
  55484. utilityLayerScene: Scene;
  55485. /**
  55486. * If the utility layer should automatically be rendered on top of existing scene
  55487. */
  55488. shouldRender: boolean;
  55489. /**
  55490. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55491. */
  55492. onlyCheckPointerDownEvents: boolean;
  55493. /**
  55494. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55495. */
  55496. processAllEvents: boolean;
  55497. /**
  55498. * Observable raised when the pointer move from the utility layer scene to the main scene
  55499. */
  55500. onPointerOutObservable: Observable<number>;
  55501. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55502. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55503. private _afterRenderObserver;
  55504. private _sceneDisposeObserver;
  55505. private _originalPointerObserver;
  55506. /**
  55507. * Instantiates a UtilityLayerRenderer
  55508. * @param originalScene the original scene that will be rendered on top of
  55509. * @param handleEvents boolean indicating if the utility layer should handle events
  55510. */
  55511. constructor(
  55512. /** the original scene that will be rendered on top of */
  55513. originalScene: Scene, handleEvents?: boolean);
  55514. private _notifyObservers;
  55515. /**
  55516. * Renders the utility layers scene on top of the original scene
  55517. */
  55518. render(): void;
  55519. /**
  55520. * Disposes of the renderer
  55521. */
  55522. dispose(): void;
  55523. private _updateCamera;
  55524. }
  55525. }
  55526. declare module BABYLON {
  55527. /**
  55528. * Options interface for the pointer selection module
  55529. */
  55530. export interface IWebXRControllerPointerSelectionOptions {
  55531. /**
  55532. * if provided, this scene will be used to render meshes.
  55533. */
  55534. customUtilityLayerScene?: Scene;
  55535. /**
  55536. * 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)
  55537. * If not disabled, the last picked point will be used to execute a pointer up event
  55538. * If disabled, pointer up event will be triggered right after the pointer down event.
  55539. * Used in screen and gaze target ray mode only
  55540. */
  55541. disablePointerUpOnTouchOut: boolean;
  55542. /**
  55543. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55544. */
  55545. forceGazeMode: boolean;
  55546. /**
  55547. * 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
  55548. * to start a new countdown to the pointer down event.
  55549. * Defaults to 1.
  55550. */
  55551. gazeModePointerMovedFactor?: number;
  55552. /**
  55553. * Different button type to use instead of the main component
  55554. */
  55555. overrideButtonId?: string;
  55556. /**
  55557. * use this rendering group id for the meshes (optional)
  55558. */
  55559. renderingGroupId?: number;
  55560. /**
  55561. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55562. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55563. * 3000 means 3 seconds between pointing at something and selecting it
  55564. */
  55565. timeToSelect?: number;
  55566. /**
  55567. * Should meshes created here be added to a utility layer or the main scene
  55568. */
  55569. useUtilityLayer?: boolean;
  55570. /**
  55571. * Optional WebXR camera to be used for gaze selection
  55572. */
  55573. gazeCamera?: WebXRCamera;
  55574. /**
  55575. * the xr input to use with this pointer selection
  55576. */
  55577. xrInput: WebXRInput;
  55578. /**
  55579. * Should the scene pointerX and pointerY update be disabled
  55580. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55581. * Disable in VR, if not needed.
  55582. * The first rig camera (left eye) will be used to calculate the projection
  55583. */
  55584. disableScenePointerVectorUpdate: boolean;
  55585. /**
  55586. * Enable pointer selection on all controllers instead of switching between them
  55587. */
  55588. enablePointerSelectionOnAllControllers?: boolean;
  55589. /**
  55590. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55591. * If switch is enabled, it will still allow the user to switch between the different controllers
  55592. */
  55593. preferredHandedness?: XRHandedness;
  55594. /**
  55595. * Disable switching the pointer selection from one controller to the other.
  55596. * 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
  55597. */
  55598. disableSwitchOnClick?: boolean;
  55599. /**
  55600. * The maximum distance of the pointer selection feature. Defaults to 100.
  55601. */
  55602. maxPointerDistance?: number;
  55603. }
  55604. /**
  55605. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55606. */
  55607. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55608. private readonly _options;
  55609. private static _idCounter;
  55610. private _attachController;
  55611. private _controllers;
  55612. private _scene;
  55613. private _tmpVectorForPickCompare;
  55614. private _attachedController;
  55615. /**
  55616. * The module's name
  55617. */
  55618. static readonly Name: string;
  55619. /**
  55620. * The (Babylon) version of this module.
  55621. * This is an integer representing the implementation version.
  55622. * This number does not correspond to the WebXR specs version
  55623. */
  55624. static readonly Version: number;
  55625. /**
  55626. * Disable lighting on the laser pointer (so it will always be visible)
  55627. */
  55628. disablePointerLighting: boolean;
  55629. /**
  55630. * Disable lighting on the selection mesh (so it will always be visible)
  55631. */
  55632. disableSelectionMeshLighting: boolean;
  55633. /**
  55634. * Should the laser pointer be displayed
  55635. */
  55636. displayLaserPointer: boolean;
  55637. /**
  55638. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55639. */
  55640. displaySelectionMesh: boolean;
  55641. /**
  55642. * This color will be set to the laser pointer when selection is triggered
  55643. */
  55644. laserPointerPickedColor: Color3;
  55645. /**
  55646. * Default color of the laser pointer
  55647. */
  55648. laserPointerDefaultColor: Color3;
  55649. /**
  55650. * default color of the selection ring
  55651. */
  55652. selectionMeshDefaultColor: Color3;
  55653. /**
  55654. * This color will be applied to the selection ring when selection is triggered
  55655. */
  55656. selectionMeshPickedColor: Color3;
  55657. /**
  55658. * Optional filter to be used for ray selection. This predicate shares behavior with
  55659. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55660. */
  55661. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55662. /**
  55663. * constructs a new background remover module
  55664. * @param _xrSessionManager the session manager for this module
  55665. * @param _options read-only options to be used in this module
  55666. */
  55667. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55668. /**
  55669. * attach this feature
  55670. * Will usually be called by the features manager
  55671. *
  55672. * @returns true if successful.
  55673. */
  55674. attach(): boolean;
  55675. /**
  55676. * detach this feature.
  55677. * Will usually be called by the features manager
  55678. *
  55679. * @returns true if successful.
  55680. */
  55681. detach(): boolean;
  55682. /**
  55683. * Will get the mesh under a specific pointer.
  55684. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55685. * @param controllerId the controllerId to check
  55686. * @returns The mesh under pointer or null if no mesh is under the pointer
  55687. */
  55688. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55689. /**
  55690. * Get the xr controller that correlates to the pointer id in the pointer event
  55691. *
  55692. * @param id the pointer id to search for
  55693. * @returns the controller that correlates to this id or null if not found
  55694. */
  55695. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55696. private _identityMatrix;
  55697. private _screenCoordinatesRef;
  55698. private _viewportRef;
  55699. protected _onXRFrame(_xrFrame: XRFrame): void;
  55700. private _attachGazeMode;
  55701. private _attachScreenRayMode;
  55702. private _attachTrackedPointerRayMode;
  55703. private _convertNormalToDirectionOfRay;
  55704. private _detachController;
  55705. private _generateNewMeshPair;
  55706. private _pickingMoved;
  55707. private _updatePointerDistance;
  55708. /** @hidden */
  55709. get lasterPointerDefaultColor(): Color3;
  55710. }
  55711. }
  55712. declare module BABYLON {
  55713. /**
  55714. * Button which can be used to enter a different mode of XR
  55715. */
  55716. export class WebXREnterExitUIButton {
  55717. /** button element */
  55718. element: HTMLElement;
  55719. /** XR initialization options for the button */
  55720. sessionMode: XRSessionMode;
  55721. /** Reference space type */
  55722. referenceSpaceType: XRReferenceSpaceType;
  55723. /**
  55724. * Creates a WebXREnterExitUIButton
  55725. * @param element button element
  55726. * @param sessionMode XR initialization session mode
  55727. * @param referenceSpaceType the type of reference space to be used
  55728. */
  55729. constructor(
  55730. /** button element */
  55731. element: HTMLElement,
  55732. /** XR initialization options for the button */
  55733. sessionMode: XRSessionMode,
  55734. /** Reference space type */
  55735. referenceSpaceType: XRReferenceSpaceType);
  55736. /**
  55737. * Extendable function which can be used to update the button's visuals when the state changes
  55738. * @param activeButton the current active button in the UI
  55739. */
  55740. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55741. }
  55742. /**
  55743. * Options to create the webXR UI
  55744. */
  55745. export class WebXREnterExitUIOptions {
  55746. /**
  55747. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55748. */
  55749. customButtons?: Array<WebXREnterExitUIButton>;
  55750. /**
  55751. * A reference space type to use when creating the default button.
  55752. * Default is local-floor
  55753. */
  55754. referenceSpaceType?: XRReferenceSpaceType;
  55755. /**
  55756. * Context to enter xr with
  55757. */
  55758. renderTarget?: Nullable<WebXRRenderTarget>;
  55759. /**
  55760. * A session mode to use when creating the default button.
  55761. * Default is immersive-vr
  55762. */
  55763. sessionMode?: XRSessionMode;
  55764. /**
  55765. * A list of optional features to init the session with
  55766. */
  55767. optionalFeatures?: string[];
  55768. /**
  55769. * A list of optional features to init the session with
  55770. */
  55771. requiredFeatures?: string[];
  55772. /**
  55773. * If defined, this function will be executed if the UI encounters an error when entering XR
  55774. */
  55775. onError?: (error: any) => void;
  55776. }
  55777. /**
  55778. * UI to allow the user to enter/exit XR mode
  55779. */
  55780. export class WebXREnterExitUI implements IDisposable {
  55781. private scene;
  55782. /** version of the options passed to this UI */
  55783. options: WebXREnterExitUIOptions;
  55784. private _activeButton;
  55785. private _buttons;
  55786. /**
  55787. * The HTML Div Element to which buttons are added.
  55788. */
  55789. readonly overlay: HTMLDivElement;
  55790. /**
  55791. * Fired every time the active button is changed.
  55792. *
  55793. * When xr is entered via a button that launches xr that button will be the callback parameter
  55794. *
  55795. * When exiting xr the callback parameter will be null)
  55796. */
  55797. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55798. /**
  55799. *
  55800. * @param scene babylon scene object to use
  55801. * @param options (read-only) version of the options passed to this UI
  55802. */
  55803. private constructor();
  55804. /**
  55805. * Creates UI to allow the user to enter/exit XR mode
  55806. * @param scene the scene to add the ui to
  55807. * @param helper the xr experience helper to enter/exit xr with
  55808. * @param options options to configure the UI
  55809. * @returns the created ui
  55810. */
  55811. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55812. /**
  55813. * Disposes of the XR UI component
  55814. */
  55815. dispose(): void;
  55816. private _updateButtons;
  55817. }
  55818. }
  55819. declare module BABYLON {
  55820. /**
  55821. * Class containing static functions to help procedurally build meshes
  55822. */
  55823. export class LinesBuilder {
  55824. /**
  55825. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55826. * * 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
  55827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55828. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55829. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55830. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55831. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55832. * * 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
  55833. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55836. * @param name defines the name of the new line system
  55837. * @param options defines the options used to create the line system
  55838. * @param scene defines the hosting scene
  55839. * @returns a new line system mesh
  55840. */
  55841. static CreateLineSystem(name: string, options: {
  55842. lines: Vector3[][];
  55843. updatable?: boolean;
  55844. instance?: Nullable<LinesMesh>;
  55845. colors?: Nullable<Color4[][]>;
  55846. useVertexAlpha?: boolean;
  55847. }, scene: Nullable<Scene>): LinesMesh;
  55848. /**
  55849. * Creates a line mesh
  55850. * 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
  55851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55852. * * The parameter `points` is an array successive Vector3
  55853. * * 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
  55854. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55855. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55856. * * When updating an instance, remember that only point positions can change, not the number of points
  55857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55859. * @param name defines the name of the new line system
  55860. * @param options defines the options used to create the line system
  55861. * @param scene defines the hosting scene
  55862. * @returns a new line mesh
  55863. */
  55864. static CreateLines(name: string, options: {
  55865. points: Vector3[];
  55866. updatable?: boolean;
  55867. instance?: Nullable<LinesMesh>;
  55868. colors?: Color4[];
  55869. useVertexAlpha?: boolean;
  55870. }, scene?: Nullable<Scene>): LinesMesh;
  55871. /**
  55872. * Creates a dashed line mesh
  55873. * * 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
  55874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55875. * * The parameter `points` is an array successive Vector3
  55876. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55877. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55878. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55879. * * 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
  55880. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55881. * * When updating an instance, remember that only point positions can change, not the number of points
  55882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55883. * @param name defines the name of the mesh
  55884. * @param options defines the options used to create the mesh
  55885. * @param scene defines the hosting scene
  55886. * @returns the dashed line mesh
  55887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55888. */
  55889. static CreateDashedLines(name: string, options: {
  55890. points: Vector3[];
  55891. dashSize?: number;
  55892. gapSize?: number;
  55893. dashNb?: number;
  55894. updatable?: boolean;
  55895. instance?: LinesMesh;
  55896. useVertexAlpha?: boolean;
  55897. }, scene?: Nullable<Scene>): LinesMesh;
  55898. }
  55899. }
  55900. declare module BABYLON {
  55901. /**
  55902. * Construction options for a timer
  55903. */
  55904. export interface ITimerOptions<T> {
  55905. /**
  55906. * Time-to-end
  55907. */
  55908. timeout: number;
  55909. /**
  55910. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55911. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55912. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55913. */
  55914. contextObservable: Observable<T>;
  55915. /**
  55916. * Optional parameters when adding an observer to the observable
  55917. */
  55918. observableParameters?: {
  55919. mask?: number;
  55920. insertFirst?: boolean;
  55921. scope?: any;
  55922. };
  55923. /**
  55924. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55925. */
  55926. breakCondition?: (data?: ITimerData<T>) => boolean;
  55927. /**
  55928. * Will be triggered when the time condition has met
  55929. */
  55930. onEnded?: (data: ITimerData<any>) => void;
  55931. /**
  55932. * Will be triggered when the break condition has met (prematurely ended)
  55933. */
  55934. onAborted?: (data: ITimerData<any>) => void;
  55935. /**
  55936. * Optional function to execute on each tick (or count)
  55937. */
  55938. onTick?: (data: ITimerData<any>) => void;
  55939. }
  55940. /**
  55941. * An interface defining the data sent by the timer
  55942. */
  55943. export interface ITimerData<T> {
  55944. /**
  55945. * When did it start
  55946. */
  55947. startTime: number;
  55948. /**
  55949. * Time now
  55950. */
  55951. currentTime: number;
  55952. /**
  55953. * Time passed since started
  55954. */
  55955. deltaTime: number;
  55956. /**
  55957. * How much is completed, in [0.0...1.0].
  55958. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55959. */
  55960. completeRate: number;
  55961. /**
  55962. * What the registered observable sent in the last count
  55963. */
  55964. payload: T;
  55965. }
  55966. /**
  55967. * The current state of the timer
  55968. */
  55969. export enum TimerState {
  55970. /**
  55971. * Timer initialized, not yet started
  55972. */
  55973. INIT = 0,
  55974. /**
  55975. * Timer started and counting
  55976. */
  55977. STARTED = 1,
  55978. /**
  55979. * Timer ended (whether aborted or time reached)
  55980. */
  55981. ENDED = 2
  55982. }
  55983. /**
  55984. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55985. *
  55986. * @param options options with which to initialize this timer
  55987. */
  55988. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55989. /**
  55990. * An advanced implementation of a timer class
  55991. */
  55992. export class AdvancedTimer<T = any> implements IDisposable {
  55993. /**
  55994. * Will notify each time the timer calculates the remaining time
  55995. */
  55996. onEachCountObservable: Observable<ITimerData<T>>;
  55997. /**
  55998. * Will trigger when the timer was aborted due to the break condition
  55999. */
  56000. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56001. /**
  56002. * Will trigger when the timer ended successfully
  56003. */
  56004. onTimerEndedObservable: Observable<ITimerData<T>>;
  56005. /**
  56006. * Will trigger when the timer state has changed
  56007. */
  56008. onStateChangedObservable: Observable<TimerState>;
  56009. private _observer;
  56010. private _contextObservable;
  56011. private _observableParameters;
  56012. private _startTime;
  56013. private _timer;
  56014. private _state;
  56015. private _breakCondition;
  56016. private _timeToEnd;
  56017. private _breakOnNextTick;
  56018. /**
  56019. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56020. * @param options construction options for this advanced timer
  56021. */
  56022. constructor(options: ITimerOptions<T>);
  56023. /**
  56024. * set a breaking condition for this timer. Default is to never break during count
  56025. * @param predicate the new break condition. Returns true to break, false otherwise
  56026. */
  56027. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56028. /**
  56029. * Reset ALL associated observables in this advanced timer
  56030. */
  56031. clearObservables(): void;
  56032. /**
  56033. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56034. *
  56035. * @param timeToEnd how much time to measure until timer ended
  56036. */
  56037. start(timeToEnd?: number): void;
  56038. /**
  56039. * Will force a stop on the next tick.
  56040. */
  56041. stop(): void;
  56042. /**
  56043. * Dispose this timer, clearing all resources
  56044. */
  56045. dispose(): void;
  56046. private _setState;
  56047. private _tick;
  56048. private _stop;
  56049. }
  56050. }
  56051. declare module BABYLON {
  56052. /**
  56053. * The options container for the teleportation module
  56054. */
  56055. export interface IWebXRTeleportationOptions {
  56056. /**
  56057. * if provided, this scene will be used to render meshes.
  56058. */
  56059. customUtilityLayerScene?: Scene;
  56060. /**
  56061. * Values to configure the default target mesh
  56062. */
  56063. defaultTargetMeshOptions?: {
  56064. /**
  56065. * Fill color of the teleportation area
  56066. */
  56067. teleportationFillColor?: string;
  56068. /**
  56069. * Border color for the teleportation area
  56070. */
  56071. teleportationBorderColor?: string;
  56072. /**
  56073. * Disable the mesh's animation sequence
  56074. */
  56075. disableAnimation?: boolean;
  56076. /**
  56077. * Disable lighting on the material or the ring and arrow
  56078. */
  56079. disableLighting?: boolean;
  56080. /**
  56081. * Override the default material of the torus and arrow
  56082. */
  56083. torusArrowMaterial?: Material;
  56084. };
  56085. /**
  56086. * A list of meshes to use as floor meshes.
  56087. * Meshes can be added and removed after initializing the feature using the
  56088. * addFloorMesh and removeFloorMesh functions
  56089. * If empty, rotation will still work
  56090. */
  56091. floorMeshes?: AbstractMesh[];
  56092. /**
  56093. * use this rendering group id for the meshes (optional)
  56094. */
  56095. renderingGroupId?: number;
  56096. /**
  56097. * Should teleportation move only to snap points
  56098. */
  56099. snapPointsOnly?: boolean;
  56100. /**
  56101. * An array of points to which the teleportation will snap to.
  56102. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56103. */
  56104. snapPositions?: Vector3[];
  56105. /**
  56106. * How close should the teleportation ray be in order to snap to position.
  56107. * Default to 0.8 units (meters)
  56108. */
  56109. snapToPositionRadius?: number;
  56110. /**
  56111. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56112. * If you want to support rotation, make sure your mesh has a direction indicator.
  56113. *
  56114. * When left untouched, the default mesh will be initialized.
  56115. */
  56116. teleportationTargetMesh?: AbstractMesh;
  56117. /**
  56118. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56119. */
  56120. timeToTeleport?: number;
  56121. /**
  56122. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56123. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56124. */
  56125. useMainComponentOnly?: boolean;
  56126. /**
  56127. * Should meshes created here be added to a utility layer or the main scene
  56128. */
  56129. useUtilityLayer?: boolean;
  56130. /**
  56131. * Babylon XR Input class for controller
  56132. */
  56133. xrInput: WebXRInput;
  56134. /**
  56135. * Meshes that the teleportation ray cannot go through
  56136. */
  56137. pickBlockerMeshes?: AbstractMesh[];
  56138. /**
  56139. * Should teleport work only on a specific hand?
  56140. */
  56141. forceHandedness?: XRHandedness;
  56142. /**
  56143. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56144. */
  56145. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56146. }
  56147. /**
  56148. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56149. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56150. * the input of the attached controllers.
  56151. */
  56152. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56153. private _options;
  56154. private _controllers;
  56155. private _currentTeleportationControllerId;
  56156. private _floorMeshes;
  56157. private _quadraticBezierCurve;
  56158. private _selectionFeature;
  56159. private _snapToPositions;
  56160. private _snappedToPoint;
  56161. private _teleportationRingMaterial?;
  56162. private _tmpRay;
  56163. private _tmpVector;
  56164. private _tmpQuaternion;
  56165. /**
  56166. * The module's name
  56167. */
  56168. static readonly Name: string;
  56169. /**
  56170. * The (Babylon) version of this module.
  56171. * This is an integer representing the implementation version.
  56172. * This number does not correspond to the webxr specs version
  56173. */
  56174. static readonly Version: number;
  56175. /**
  56176. * Is movement backwards enabled
  56177. */
  56178. backwardsMovementEnabled: boolean;
  56179. /**
  56180. * Distance to travel when moving backwards
  56181. */
  56182. backwardsTeleportationDistance: number;
  56183. /**
  56184. * The distance from the user to the inspection point in the direction of the controller
  56185. * A higher number will allow the user to move further
  56186. * defaults to 5 (meters, in xr units)
  56187. */
  56188. parabolicCheckRadius: number;
  56189. /**
  56190. * Should the module support parabolic ray on top of direct ray
  56191. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56192. * Very helpful when moving between floors / different heights
  56193. */
  56194. parabolicRayEnabled: boolean;
  56195. /**
  56196. * The second type of ray - straight line.
  56197. * Should it be enabled or should the parabolic line be the only one.
  56198. */
  56199. straightRayEnabled: boolean;
  56200. /**
  56201. * How much rotation should be applied when rotating right and left
  56202. */
  56203. rotationAngle: number;
  56204. private _rotationEnabled;
  56205. /**
  56206. * Is rotation enabled when moving forward?
  56207. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56208. */
  56209. get rotationEnabled(): boolean;
  56210. /**
  56211. * Sets wether rotation is enabled or not
  56212. * @param enabled is rotation enabled when teleportation is shown
  56213. */
  56214. set rotationEnabled(enabled: boolean);
  56215. /**
  56216. * Exposes the currently set teleportation target mesh.
  56217. */
  56218. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56219. /**
  56220. * constructs a new anchor system
  56221. * @param _xrSessionManager an instance of WebXRSessionManager
  56222. * @param _options configuration object for this feature
  56223. */
  56224. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56225. /**
  56226. * Get the snapPointsOnly flag
  56227. */
  56228. get snapPointsOnly(): boolean;
  56229. /**
  56230. * Sets the snapPointsOnly flag
  56231. * @param snapToPoints should teleportation be exclusively to snap points
  56232. */
  56233. set snapPointsOnly(snapToPoints: boolean);
  56234. /**
  56235. * Add a new mesh to the floor meshes array
  56236. * @param mesh the mesh to use as floor mesh
  56237. */
  56238. addFloorMesh(mesh: AbstractMesh): void;
  56239. /**
  56240. * Add a new snap-to point to fix teleportation to this position
  56241. * @param newSnapPoint The new Snap-To point
  56242. */
  56243. addSnapPoint(newSnapPoint: Vector3): void;
  56244. attach(): boolean;
  56245. detach(): boolean;
  56246. dispose(): void;
  56247. /**
  56248. * Remove a mesh from the floor meshes array
  56249. * @param mesh the mesh to remove
  56250. */
  56251. removeFloorMesh(mesh: AbstractMesh): void;
  56252. /**
  56253. * Remove a mesh from the floor meshes array using its name
  56254. * @param name the mesh name to remove
  56255. */
  56256. removeFloorMeshByName(name: string): void;
  56257. /**
  56258. * 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
  56259. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56260. * @returns was the point found and removed or not
  56261. */
  56262. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56263. /**
  56264. * This function sets a selection feature that will be disabled when
  56265. * the forward ray is shown and will be reattached when hidden.
  56266. * This is used to remove the selection rays when moving.
  56267. * @param selectionFeature the feature to disable when forward movement is enabled
  56268. */
  56269. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56270. protected _onXRFrame(_xrFrame: XRFrame): void;
  56271. private _attachController;
  56272. private _createDefaultTargetMesh;
  56273. private _detachController;
  56274. private _findClosestSnapPointWithRadius;
  56275. private _setTargetMeshPosition;
  56276. private _setTargetMeshVisibility;
  56277. private _showParabolicPath;
  56278. private _teleportForward;
  56279. }
  56280. }
  56281. declare module BABYLON {
  56282. /**
  56283. * Options for the default xr helper
  56284. */
  56285. export class WebXRDefaultExperienceOptions {
  56286. /**
  56287. * Enable or disable default UI to enter XR
  56288. */
  56289. disableDefaultUI?: boolean;
  56290. /**
  56291. * Should teleportation not initialize. defaults to false.
  56292. */
  56293. disableTeleportation?: boolean;
  56294. /**
  56295. * Floor meshes that will be used for teleport
  56296. */
  56297. floorMeshes?: Array<AbstractMesh>;
  56298. /**
  56299. * If set to true, the first frame will not be used to reset position
  56300. * The first frame is mainly used when copying transformation from the old camera
  56301. * Mainly used in AR
  56302. */
  56303. ignoreNativeCameraTransformation?: boolean;
  56304. /**
  56305. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56306. */
  56307. inputOptions?: IWebXRInputOptions;
  56308. /**
  56309. * optional configuration for the output canvas
  56310. */
  56311. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56312. /**
  56313. * optional UI options. This can be used among other to change session mode and reference space type
  56314. */
  56315. uiOptions?: WebXREnterExitUIOptions;
  56316. /**
  56317. * When loading teleportation and pointer select, use stable versions instead of latest.
  56318. */
  56319. useStablePlugins?: boolean;
  56320. /**
  56321. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56322. */
  56323. renderingGroupId?: number;
  56324. /**
  56325. * A list of optional features to init the session with
  56326. * If set to true, all features we support will be added
  56327. */
  56328. optionalFeatures?: boolean | string[];
  56329. }
  56330. /**
  56331. * Default experience which provides a similar setup to the previous webVRExperience
  56332. */
  56333. export class WebXRDefaultExperience {
  56334. /**
  56335. * Base experience
  56336. */
  56337. baseExperience: WebXRExperienceHelper;
  56338. /**
  56339. * Enables ui for entering/exiting xr
  56340. */
  56341. enterExitUI: WebXREnterExitUI;
  56342. /**
  56343. * Input experience extension
  56344. */
  56345. input: WebXRInput;
  56346. /**
  56347. * Enables laser pointer and selection
  56348. */
  56349. pointerSelection: WebXRControllerPointerSelection;
  56350. /**
  56351. * Default target xr should render to
  56352. */
  56353. renderTarget: WebXRRenderTarget;
  56354. /**
  56355. * Enables teleportation
  56356. */
  56357. teleportation: WebXRMotionControllerTeleportation;
  56358. private constructor();
  56359. /**
  56360. * Creates the default xr experience
  56361. * @param scene scene
  56362. * @param options options for basic configuration
  56363. * @returns resulting WebXRDefaultExperience
  56364. */
  56365. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56366. /**
  56367. * DIsposes of the experience helper
  56368. */
  56369. dispose(): void;
  56370. }
  56371. }
  56372. declare module BABYLON {
  56373. /**
  56374. * Options to modify the vr teleportation behavior.
  56375. */
  56376. export interface VRTeleportationOptions {
  56377. /**
  56378. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56379. */
  56380. floorMeshName?: string;
  56381. /**
  56382. * A list of meshes to be used as the teleportation floor. (default: empty)
  56383. */
  56384. floorMeshes?: Mesh[];
  56385. /**
  56386. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56387. */
  56388. teleportationMode?: number;
  56389. /**
  56390. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56391. */
  56392. teleportationTime?: number;
  56393. /**
  56394. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56395. */
  56396. teleportationSpeed?: number;
  56397. /**
  56398. * The easing function used in the animation or null for Linear. (default CircleEase)
  56399. */
  56400. easingFunction?: EasingFunction;
  56401. }
  56402. /**
  56403. * Options to modify the vr experience helper's behavior.
  56404. */
  56405. export interface VRExperienceHelperOptions extends WebVROptions {
  56406. /**
  56407. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56408. */
  56409. createDeviceOrientationCamera?: boolean;
  56410. /**
  56411. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56412. */
  56413. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56414. /**
  56415. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56416. */
  56417. laserToggle?: boolean;
  56418. /**
  56419. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56420. */
  56421. floorMeshes?: Mesh[];
  56422. /**
  56423. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56424. */
  56425. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56426. /**
  56427. * Defines if WebXR should be used instead of WebVR (if available)
  56428. */
  56429. useXR?: boolean;
  56430. }
  56431. /**
  56432. * Event containing information after VR has been entered
  56433. */
  56434. export class OnAfterEnteringVRObservableEvent {
  56435. /**
  56436. * If entering vr was successful
  56437. */
  56438. success: boolean;
  56439. }
  56440. /**
  56441. * Helps to quickly add VR support to an existing scene.
  56442. * See https://doc.babylonjs.com/how_to/webvr_helper
  56443. */
  56444. export class VRExperienceHelper {
  56445. /** Options to modify the vr experience helper's behavior. */
  56446. webVROptions: VRExperienceHelperOptions;
  56447. private _scene;
  56448. private _position;
  56449. private _btnVR;
  56450. private _btnVRDisplayed;
  56451. private _webVRsupported;
  56452. private _webVRready;
  56453. private _webVRrequesting;
  56454. private _webVRpresenting;
  56455. private _hasEnteredVR;
  56456. private _fullscreenVRpresenting;
  56457. private _inputElement;
  56458. private _webVRCamera;
  56459. private _vrDeviceOrientationCamera;
  56460. private _deviceOrientationCamera;
  56461. private _existingCamera;
  56462. private _onKeyDown;
  56463. private _onVrDisplayPresentChange;
  56464. private _onVRDisplayChanged;
  56465. private _onVRRequestPresentStart;
  56466. private _onVRRequestPresentComplete;
  56467. /**
  56468. * 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)
  56469. */
  56470. enableGazeEvenWhenNoPointerLock: boolean;
  56471. /**
  56472. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56473. */
  56474. exitVROnDoubleTap: boolean;
  56475. /**
  56476. * Observable raised right before entering VR.
  56477. */
  56478. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56479. /**
  56480. * Observable raised when entering VR has completed.
  56481. */
  56482. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56483. /**
  56484. * Observable raised when exiting VR.
  56485. */
  56486. onExitingVRObservable: Observable<VRExperienceHelper>;
  56487. /**
  56488. * Observable raised when controller mesh is loaded.
  56489. */
  56490. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56491. /** Return this.onEnteringVRObservable
  56492. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56493. */
  56494. get onEnteringVR(): Observable<VRExperienceHelper>;
  56495. /** Return this.onExitingVRObservable
  56496. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56497. */
  56498. get onExitingVR(): Observable<VRExperienceHelper>;
  56499. /** Return this.onControllerMeshLoadedObservable
  56500. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56501. */
  56502. get onControllerMeshLoaded(): Observable<WebVRController>;
  56503. private _rayLength;
  56504. private _useCustomVRButton;
  56505. private _teleportationRequested;
  56506. private _teleportActive;
  56507. private _floorMeshName;
  56508. private _floorMeshesCollection;
  56509. private _teleportationMode;
  56510. private _teleportationTime;
  56511. private _teleportationSpeed;
  56512. private _teleportationEasing;
  56513. private _rotationAllowed;
  56514. private _teleportBackwardsVector;
  56515. private _teleportationTarget;
  56516. private _isDefaultTeleportationTarget;
  56517. private _postProcessMove;
  56518. private _teleportationFillColor;
  56519. private _teleportationBorderColor;
  56520. private _rotationAngle;
  56521. private _haloCenter;
  56522. private _cameraGazer;
  56523. private _padSensibilityUp;
  56524. private _padSensibilityDown;
  56525. private _leftController;
  56526. private _rightController;
  56527. private _gazeColor;
  56528. private _laserColor;
  56529. private _pickedLaserColor;
  56530. private _pickedGazeColor;
  56531. /**
  56532. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56533. */
  56534. onNewMeshSelected: Observable<AbstractMesh>;
  56535. /**
  56536. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56537. * This observable will provide the mesh and the controller used to select the mesh
  56538. */
  56539. onMeshSelectedWithController: Observable<{
  56540. mesh: AbstractMesh;
  56541. controller: WebVRController;
  56542. }>;
  56543. /**
  56544. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56545. */
  56546. onNewMeshPicked: Observable<PickingInfo>;
  56547. private _circleEase;
  56548. /**
  56549. * Observable raised before camera teleportation
  56550. */
  56551. onBeforeCameraTeleport: Observable<Vector3>;
  56552. /**
  56553. * Observable raised after camera teleportation
  56554. */
  56555. onAfterCameraTeleport: Observable<Vector3>;
  56556. /**
  56557. * Observable raised when current selected mesh gets unselected
  56558. */
  56559. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56560. private _raySelectionPredicate;
  56561. /**
  56562. * To be optionaly changed by user to define custom ray selection
  56563. */
  56564. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56565. /**
  56566. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56567. */
  56568. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56569. /**
  56570. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56571. */
  56572. teleportationEnabled: boolean;
  56573. private _defaultHeight;
  56574. private _teleportationInitialized;
  56575. private _interactionsEnabled;
  56576. private _interactionsRequested;
  56577. private _displayGaze;
  56578. private _displayLaserPointer;
  56579. /**
  56580. * The mesh used to display where the user is going to teleport.
  56581. */
  56582. get teleportationTarget(): Mesh;
  56583. /**
  56584. * Sets the mesh to be used to display where the user is going to teleport.
  56585. */
  56586. set teleportationTarget(value: Mesh);
  56587. /**
  56588. * 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
  56589. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56590. * See https://doc.babylonjs.com/resources/baking_transformations
  56591. */
  56592. get gazeTrackerMesh(): Mesh;
  56593. set gazeTrackerMesh(value: Mesh);
  56594. /**
  56595. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56596. */
  56597. updateGazeTrackerScale: boolean;
  56598. /**
  56599. * If the gaze trackers color should be updated when selecting meshes
  56600. */
  56601. updateGazeTrackerColor: boolean;
  56602. /**
  56603. * If the controller laser color should be updated when selecting meshes
  56604. */
  56605. updateControllerLaserColor: boolean;
  56606. /**
  56607. * The gaze tracking mesh corresponding to the left controller
  56608. */
  56609. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56610. /**
  56611. * The gaze tracking mesh corresponding to the right controller
  56612. */
  56613. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56614. /**
  56615. * If the ray of the gaze should be displayed.
  56616. */
  56617. get displayGaze(): boolean;
  56618. /**
  56619. * Sets if the ray of the gaze should be displayed.
  56620. */
  56621. set displayGaze(value: boolean);
  56622. /**
  56623. * If the ray of the LaserPointer should be displayed.
  56624. */
  56625. get displayLaserPointer(): boolean;
  56626. /**
  56627. * Sets if the ray of the LaserPointer should be displayed.
  56628. */
  56629. set displayLaserPointer(value: boolean);
  56630. /**
  56631. * The deviceOrientationCamera used as the camera when not in VR.
  56632. */
  56633. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56634. /**
  56635. * Based on the current WebVR support, returns the current VR camera used.
  56636. */
  56637. get currentVRCamera(): Nullable<Camera>;
  56638. /**
  56639. * The webVRCamera which is used when in VR.
  56640. */
  56641. get webVRCamera(): WebVRFreeCamera;
  56642. /**
  56643. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56644. */
  56645. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56646. /**
  56647. * The html button that is used to trigger entering into VR.
  56648. */
  56649. get vrButton(): Nullable<HTMLButtonElement>;
  56650. private get _teleportationRequestInitiated();
  56651. /**
  56652. * Defines whether or not Pointer lock should be requested when switching to
  56653. * full screen.
  56654. */
  56655. requestPointerLockOnFullScreen: boolean;
  56656. /**
  56657. * If asking to force XR, this will be populated with the default xr experience
  56658. */
  56659. xr: WebXRDefaultExperience;
  56660. /**
  56661. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56662. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56663. */
  56664. xrTestDone: boolean;
  56665. /**
  56666. * Instantiates a VRExperienceHelper.
  56667. * Helps to quickly add VR support to an existing scene.
  56668. * @param scene The scene the VRExperienceHelper belongs to.
  56669. * @param webVROptions Options to modify the vr experience helper's behavior.
  56670. */
  56671. constructor(scene: Scene,
  56672. /** Options to modify the vr experience helper's behavior. */
  56673. webVROptions?: VRExperienceHelperOptions);
  56674. private completeVRInit;
  56675. private _onDefaultMeshLoaded;
  56676. private _onResize;
  56677. private _onFullscreenChange;
  56678. /**
  56679. * Gets a value indicating if we are currently in VR mode.
  56680. */
  56681. get isInVRMode(): boolean;
  56682. private onVrDisplayPresentChange;
  56683. private onVRDisplayChanged;
  56684. private moveButtonToBottomRight;
  56685. private displayVRButton;
  56686. private updateButtonVisibility;
  56687. private _cachedAngularSensibility;
  56688. /**
  56689. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56690. * Otherwise, will use the fullscreen API.
  56691. */
  56692. enterVR(): void;
  56693. /**
  56694. * Attempt to exit VR, or fullscreen.
  56695. */
  56696. exitVR(): void;
  56697. /**
  56698. * The position of the vr experience helper.
  56699. */
  56700. get position(): Vector3;
  56701. /**
  56702. * Sets the position of the vr experience helper.
  56703. */
  56704. set position(value: Vector3);
  56705. /**
  56706. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56707. */
  56708. enableInteractions(): void;
  56709. private get _noControllerIsActive();
  56710. private beforeRender;
  56711. private _isTeleportationFloor;
  56712. /**
  56713. * Adds a floor mesh to be used for teleportation.
  56714. * @param floorMesh the mesh to be used for teleportation.
  56715. */
  56716. addFloorMesh(floorMesh: Mesh): void;
  56717. /**
  56718. * Removes a floor mesh from being used for teleportation.
  56719. * @param floorMesh the mesh to be removed.
  56720. */
  56721. removeFloorMesh(floorMesh: Mesh): void;
  56722. /**
  56723. * Enables interactions and teleportation using the VR controllers and gaze.
  56724. * @param vrTeleportationOptions options to modify teleportation behavior.
  56725. */
  56726. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56727. private _onNewGamepadConnected;
  56728. private _tryEnableInteractionOnController;
  56729. private _onNewGamepadDisconnected;
  56730. private _enableInteractionOnController;
  56731. private _checkTeleportWithRay;
  56732. private _checkRotate;
  56733. private _checkTeleportBackwards;
  56734. private _enableTeleportationOnController;
  56735. private _createTeleportationCircles;
  56736. private _displayTeleportationTarget;
  56737. private _hideTeleportationTarget;
  56738. private _rotateCamera;
  56739. private _moveTeleportationSelectorTo;
  56740. private _workingVector;
  56741. private _workingQuaternion;
  56742. private _workingMatrix;
  56743. /**
  56744. * Time Constant Teleportation Mode
  56745. */
  56746. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56747. /**
  56748. * Speed Constant Teleportation Mode
  56749. */
  56750. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56751. /**
  56752. * Teleports the users feet to the desired location
  56753. * @param location The location where the user's feet should be placed
  56754. */
  56755. teleportCamera(location: Vector3): void;
  56756. private _convertNormalToDirectionOfRay;
  56757. private _castRayAndSelectObject;
  56758. private _notifySelectedMeshUnselected;
  56759. /**
  56760. * Permanently set new colors for the laser pointer
  56761. * @param color the new laser color
  56762. * @param pickedColor the new laser color when picked mesh detected
  56763. */
  56764. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56765. /**
  56766. * Set lighting enabled / disabled on the laser pointer of both controllers
  56767. * @param enabled should the lighting be enabled on the laser pointer
  56768. */
  56769. setLaserLightingState(enabled?: boolean): void;
  56770. /**
  56771. * Permanently set new colors for the gaze pointer
  56772. * @param color the new gaze color
  56773. * @param pickedColor the new gaze color when picked mesh detected
  56774. */
  56775. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56776. /**
  56777. * Sets the color of the laser ray from the vr controllers.
  56778. * @param color new color for the ray.
  56779. */
  56780. changeLaserColor(color: Color3): void;
  56781. /**
  56782. * Sets the color of the ray from the vr headsets gaze.
  56783. * @param color new color for the ray.
  56784. */
  56785. changeGazeColor(color: Color3): void;
  56786. /**
  56787. * Exits VR and disposes of the vr experience helper
  56788. */
  56789. dispose(): void;
  56790. /**
  56791. * Gets the name of the VRExperienceHelper class
  56792. * @returns "VRExperienceHelper"
  56793. */
  56794. getClassName(): string;
  56795. }
  56796. }
  56797. declare module BABYLON {
  56798. /**
  56799. * Contains an array of blocks representing the octree
  56800. */
  56801. export interface IOctreeContainer<T> {
  56802. /**
  56803. * Blocks within the octree
  56804. */
  56805. blocks: Array<OctreeBlock<T>>;
  56806. }
  56807. /**
  56808. * Class used to store a cell in an octree
  56809. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56810. */
  56811. export class OctreeBlock<T> {
  56812. /**
  56813. * Gets the content of the current block
  56814. */
  56815. entries: T[];
  56816. /**
  56817. * Gets the list of block children
  56818. */
  56819. blocks: Array<OctreeBlock<T>>;
  56820. private _depth;
  56821. private _maxDepth;
  56822. private _capacity;
  56823. private _minPoint;
  56824. private _maxPoint;
  56825. private _boundingVectors;
  56826. private _creationFunc;
  56827. /**
  56828. * Creates a new block
  56829. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56830. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56831. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56832. * @param depth defines the current depth of this block in the octree
  56833. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56834. * @param creationFunc defines a callback to call when an element is added to the block
  56835. */
  56836. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56837. /**
  56838. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56839. */
  56840. get capacity(): number;
  56841. /**
  56842. * Gets the minimum vector (in world space) of the block's bounding box
  56843. */
  56844. get minPoint(): Vector3;
  56845. /**
  56846. * Gets the maximum vector (in world space) of the block's bounding box
  56847. */
  56848. get maxPoint(): Vector3;
  56849. /**
  56850. * Add a new element to this block
  56851. * @param entry defines the element to add
  56852. */
  56853. addEntry(entry: T): void;
  56854. /**
  56855. * Remove an element from this block
  56856. * @param entry defines the element to remove
  56857. */
  56858. removeEntry(entry: T): void;
  56859. /**
  56860. * Add an array of elements to this block
  56861. * @param entries defines the array of elements to add
  56862. */
  56863. addEntries(entries: T[]): void;
  56864. /**
  56865. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56866. * @param frustumPlanes defines the frustum planes to test
  56867. * @param selection defines the array to store current content if selection is positive
  56868. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56869. */
  56870. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56871. /**
  56872. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56873. * @param sphereCenter defines the bounding sphere center
  56874. * @param sphereRadius defines the bounding sphere radius
  56875. * @param selection defines the array to store current content if selection is positive
  56876. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56877. */
  56878. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56879. /**
  56880. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56881. * @param ray defines the ray to test with
  56882. * @param selection defines the array to store current content if selection is positive
  56883. */
  56884. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56885. /**
  56886. * Subdivide the content into child blocks (this block will then be empty)
  56887. */
  56888. createInnerBlocks(): void;
  56889. /**
  56890. * @hidden
  56891. */
  56892. 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;
  56893. }
  56894. }
  56895. declare module BABYLON {
  56896. /**
  56897. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56899. */
  56900. export class Octree<T> {
  56901. /** 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.) */
  56902. maxDepth: number;
  56903. /**
  56904. * Blocks within the octree containing objects
  56905. */
  56906. blocks: Array<OctreeBlock<T>>;
  56907. /**
  56908. * Content stored in the octree
  56909. */
  56910. dynamicContent: T[];
  56911. private _maxBlockCapacity;
  56912. private _selectionContent;
  56913. private _creationFunc;
  56914. /**
  56915. * Creates a octree
  56916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56917. * @param creationFunc function to be used to instatiate the octree
  56918. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56919. * @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.)
  56920. */
  56921. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56922. /** 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.) */
  56923. maxDepth?: number);
  56924. /**
  56925. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56926. * @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);
  56927. * @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);
  56928. * @param entries meshes to be added to the octree blocks
  56929. */
  56930. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56931. /**
  56932. * Adds a mesh to the octree
  56933. * @param entry Mesh to add to the octree
  56934. */
  56935. addMesh(entry: T): void;
  56936. /**
  56937. * Remove an element from the octree
  56938. * @param entry defines the element to remove
  56939. */
  56940. removeMesh(entry: T): void;
  56941. /**
  56942. * Selects an array of meshes within the frustum
  56943. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56944. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56945. * @returns array of meshes within the frustum
  56946. */
  56947. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56948. /**
  56949. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56950. * @param sphereCenter defines the bounding sphere center
  56951. * @param sphereRadius defines the bounding sphere radius
  56952. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56953. * @returns an array of objects that intersect the sphere
  56954. */
  56955. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56956. /**
  56957. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56958. * @param ray defines the ray to test with
  56959. * @returns array of intersected objects
  56960. */
  56961. intersectsRay(ray: Ray): SmartArray<T>;
  56962. /**
  56963. * Adds a mesh into the octree block if it intersects the block
  56964. */
  56965. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56966. /**
  56967. * Adds a submesh into the octree block if it intersects the block
  56968. */
  56969. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56970. }
  56971. }
  56972. declare module BABYLON {
  56973. interface Scene {
  56974. /**
  56975. * @hidden
  56976. * Backing Filed
  56977. */
  56978. _selectionOctree: Octree<AbstractMesh>;
  56979. /**
  56980. * Gets the octree used to boost mesh selection (picking)
  56981. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56982. */
  56983. selectionOctree: Octree<AbstractMesh>;
  56984. /**
  56985. * Creates or updates the octree used to boost selection (picking)
  56986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56987. * @param maxCapacity defines the maximum capacity per leaf
  56988. * @param maxDepth defines the maximum depth of the octree
  56989. * @returns an octree of AbstractMesh
  56990. */
  56991. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56992. }
  56993. interface AbstractMesh {
  56994. /**
  56995. * @hidden
  56996. * Backing Field
  56997. */
  56998. _submeshesOctree: Octree<SubMesh>;
  56999. /**
  57000. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57001. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57002. * @param maxCapacity defines the maximum size of each block (64 by default)
  57003. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57004. * @returns the new octree
  57005. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57006. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57007. */
  57008. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57009. }
  57010. /**
  57011. * Defines the octree scene component responsible to manage any octrees
  57012. * in a given scene.
  57013. */
  57014. export class OctreeSceneComponent {
  57015. /**
  57016. * The component name help to identify the component in the list of scene components.
  57017. */
  57018. readonly name: string;
  57019. /**
  57020. * The scene the component belongs to.
  57021. */
  57022. scene: Scene;
  57023. /**
  57024. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57025. */
  57026. readonly checksIsEnabled: boolean;
  57027. /**
  57028. * Creates a new instance of the component for the given scene
  57029. * @param scene Defines the scene to register the component in
  57030. */
  57031. constructor(scene: Scene);
  57032. /**
  57033. * Registers the component in a given scene
  57034. */
  57035. register(): void;
  57036. /**
  57037. * Return the list of active meshes
  57038. * @returns the list of active meshes
  57039. */
  57040. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57041. /**
  57042. * Return the list of active sub meshes
  57043. * @param mesh The mesh to get the candidates sub meshes from
  57044. * @returns the list of active sub meshes
  57045. */
  57046. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57047. private _tempRay;
  57048. /**
  57049. * Return the list of sub meshes intersecting with a given local ray
  57050. * @param mesh defines the mesh to find the submesh for
  57051. * @param localRay defines the ray in local space
  57052. * @returns the list of intersecting sub meshes
  57053. */
  57054. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57055. /**
  57056. * Return the list of sub meshes colliding with a collider
  57057. * @param mesh defines the mesh to find the submesh for
  57058. * @param collider defines the collider to evaluate the collision against
  57059. * @returns the list of colliding sub meshes
  57060. */
  57061. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57062. /**
  57063. * Rebuilds the elements related to this component in case of
  57064. * context lost for instance.
  57065. */
  57066. rebuild(): void;
  57067. /**
  57068. * Disposes the component and the associated ressources.
  57069. */
  57070. dispose(): void;
  57071. }
  57072. }
  57073. declare module BABYLON {
  57074. /**
  57075. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57076. */
  57077. export interface GizmoAxisCache {
  57078. /** Mesh used to runder the Gizmo */
  57079. gizmoMeshes: Mesh[];
  57080. /** Mesh used to detect user interaction with Gizmo */
  57081. colliderMeshes: Mesh[];
  57082. /** Material used to inicate color of gizmo mesh */
  57083. material: StandardMaterial;
  57084. /** Material used to inicate hover state of the Gizmo */
  57085. hoverMaterial: StandardMaterial;
  57086. /** Material used to inicate disabled state of the Gizmo */
  57087. disableMaterial: StandardMaterial;
  57088. /** Used to indicate Active state of the Gizmo */
  57089. active: boolean;
  57090. }
  57091. /**
  57092. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57093. */
  57094. export class Gizmo implements IDisposable {
  57095. /** The utility layer the gizmo will be added to */
  57096. gizmoLayer: UtilityLayerRenderer;
  57097. /**
  57098. * The root mesh of the gizmo
  57099. */
  57100. _rootMesh: Mesh;
  57101. private _attachedMesh;
  57102. private _attachedNode;
  57103. /**
  57104. * Ratio for the scale of the gizmo (Default: 1)
  57105. */
  57106. protected _scaleRatio: number;
  57107. /**
  57108. * boolean updated by pointermove when a gizmo mesh is hovered
  57109. */
  57110. protected _isHovered: boolean;
  57111. /**
  57112. * Ratio for the scale of the gizmo (Default: 1)
  57113. */
  57114. set scaleRatio(value: number);
  57115. get scaleRatio(): number;
  57116. /**
  57117. * True when the mouse pointer is hovered a gizmo mesh
  57118. */
  57119. get isHovered(): boolean;
  57120. /**
  57121. * If a custom mesh has been set (Default: false)
  57122. */
  57123. protected _customMeshSet: boolean;
  57124. /**
  57125. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57126. * * When set, interactions will be enabled
  57127. */
  57128. get attachedMesh(): Nullable<AbstractMesh>;
  57129. set attachedMesh(value: Nullable<AbstractMesh>);
  57130. /**
  57131. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57132. * * When set, interactions will be enabled
  57133. */
  57134. get attachedNode(): Nullable<Node>;
  57135. set attachedNode(value: Nullable<Node>);
  57136. /**
  57137. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57138. * @param mesh The mesh to replace the default mesh of the gizmo
  57139. */
  57140. setCustomMesh(mesh: Mesh): void;
  57141. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57142. /**
  57143. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57144. */
  57145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57147. /**
  57148. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57149. */
  57150. updateGizmoPositionToMatchAttachedMesh: boolean;
  57151. /**
  57152. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57153. */
  57154. updateScale: boolean;
  57155. protected _interactionsEnabled: boolean;
  57156. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57157. private _beforeRenderObserver;
  57158. private _tempQuaternion;
  57159. private _tempVector;
  57160. private _tempVector2;
  57161. private _tempMatrix1;
  57162. private _tempMatrix2;
  57163. private _rightHandtoLeftHandMatrix;
  57164. /**
  57165. * Creates a gizmo
  57166. * @param gizmoLayer The utility layer the gizmo will be added to
  57167. */
  57168. constructor(
  57169. /** The utility layer the gizmo will be added to */
  57170. gizmoLayer?: UtilityLayerRenderer);
  57171. /**
  57172. * Updates the gizmo to match the attached mesh's position/rotation
  57173. */
  57174. protected _update(): void;
  57175. /**
  57176. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57177. * @param value Node, TransformNode or mesh
  57178. */
  57179. protected _matrixChanged(): void;
  57180. /**
  57181. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57182. * @param gizmoLayer The utility layer the gizmo will be added to
  57183. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57184. * @returns {Observer<PointerInfo>} pointerObserver
  57185. */
  57186. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57187. /**
  57188. * Disposes of the gizmo
  57189. */
  57190. dispose(): void;
  57191. }
  57192. }
  57193. declare module BABYLON {
  57194. /**
  57195. * Single plane drag gizmo
  57196. */
  57197. export class PlaneDragGizmo extends Gizmo {
  57198. /**
  57199. * Drag behavior responsible for the gizmos dragging interactions
  57200. */
  57201. dragBehavior: PointerDragBehavior;
  57202. private _pointerObserver;
  57203. /**
  57204. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57205. */
  57206. snapDistance: number;
  57207. /**
  57208. * Event that fires each time the gizmo snaps to a new location.
  57209. * * snapDistance is the the change in distance
  57210. */
  57211. onSnapObservable: Observable<{
  57212. snapDistance: number;
  57213. }>;
  57214. private _gizmoMesh;
  57215. private _coloredMaterial;
  57216. private _hoverMaterial;
  57217. private _disableMaterial;
  57218. private _isEnabled;
  57219. private _parent;
  57220. private _dragging;
  57221. /** @hidden */
  57222. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57223. /**
  57224. * Creates a PlaneDragGizmo
  57225. * @param gizmoLayer The utility layer the gizmo will be added to
  57226. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57227. * @param color The color of the gizmo
  57228. */
  57229. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57230. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57231. /**
  57232. * If the gizmo is enabled
  57233. */
  57234. set isEnabled(value: boolean);
  57235. get isEnabled(): boolean;
  57236. /**
  57237. * Disposes of the gizmo
  57238. */
  57239. dispose(): void;
  57240. }
  57241. }
  57242. declare module BABYLON {
  57243. /**
  57244. * Single plane rotation gizmo
  57245. */
  57246. export class PlaneRotationGizmo extends Gizmo {
  57247. /**
  57248. * Drag behavior responsible for the gizmos dragging interactions
  57249. */
  57250. dragBehavior: PointerDragBehavior;
  57251. private _pointerObserver;
  57252. /**
  57253. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57254. */
  57255. snapDistance: number;
  57256. /**
  57257. * Event that fires each time the gizmo snaps to a new location.
  57258. * * snapDistance is the the change in distance
  57259. */
  57260. onSnapObservable: Observable<{
  57261. snapDistance: number;
  57262. }>;
  57263. private _isEnabled;
  57264. private _parent;
  57265. private _coloredMaterial;
  57266. private _hoverMaterial;
  57267. private _disableMaterial;
  57268. private _gizmoMesh;
  57269. private _rotationCircle;
  57270. private _dragging;
  57271. private static _CircleConstants;
  57272. /**
  57273. * Creates a PlaneRotationGizmo
  57274. * @param gizmoLayer The utility layer the gizmo will be added to
  57275. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57276. * @param color The color of the gizmo
  57277. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57278. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57279. * @param thickness display gizmo axis thickness
  57280. */
  57281. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57282. /** Create Geometry for Gizmo */
  57283. private _createGizmoMesh;
  57284. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57285. private setupRotationCircle;
  57286. private updateRotationPath;
  57287. private updateRotationCircle;
  57288. /**
  57289. * If the gizmo is enabled
  57290. */
  57291. set isEnabled(value: boolean);
  57292. get isEnabled(): boolean;
  57293. /**
  57294. * Disposes of the gizmo
  57295. */
  57296. dispose(): void;
  57297. }
  57298. }
  57299. declare module BABYLON {
  57300. /**
  57301. * Gizmo that enables rotating a mesh along 3 axis
  57302. */
  57303. export class RotationGizmo extends Gizmo {
  57304. /**
  57305. * Internal gizmo used for interactions on the x axis
  57306. */
  57307. xGizmo: PlaneRotationGizmo;
  57308. /**
  57309. * Internal gizmo used for interactions on the y axis
  57310. */
  57311. yGizmo: PlaneRotationGizmo;
  57312. /**
  57313. * Internal gizmo used for interactions on the z axis
  57314. */
  57315. zGizmo: PlaneRotationGizmo;
  57316. /** Fires an event when any of it's sub gizmos are dragged */
  57317. onDragStartObservable: Observable<unknown>;
  57318. /** Fires an event when any of it's sub gizmos are released from dragging */
  57319. onDragEndObservable: Observable<unknown>;
  57320. private _meshAttached;
  57321. private _nodeAttached;
  57322. private _observables;
  57323. /** Node Caching for quick lookup */
  57324. private _gizmoAxisCache;
  57325. get attachedMesh(): Nullable<AbstractMesh>;
  57326. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57327. get attachedNode(): Nullable<Node>;
  57328. set attachedNode(node: Nullable<Node>);
  57329. protected _checkBillboardTransform(): void;
  57330. /**
  57331. * True when the mouse pointer is hovering a gizmo mesh
  57332. */
  57333. get isHovered(): boolean;
  57334. /**
  57335. * Creates a RotationGizmo
  57336. * @param gizmoLayer The utility layer the gizmo will be added to
  57337. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57338. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57339. * @param thickness display gizmo axis thickness
  57340. */
  57341. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57342. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57343. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57344. /**
  57345. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57346. */
  57347. set snapDistance(value: number);
  57348. get snapDistance(): number;
  57349. /**
  57350. * Ratio for the scale of the gizmo (Default: 1)
  57351. */
  57352. set scaleRatio(value: number);
  57353. get scaleRatio(): number;
  57354. /**
  57355. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57356. * @param mesh Axis gizmo mesh
  57357. * @param cache Gizmo axis definition used for reactive gizmo UI
  57358. */
  57359. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57360. /**
  57361. * Disposes of the gizmo
  57362. */
  57363. dispose(): void;
  57364. /**
  57365. * CustomMeshes are not supported by this gizmo
  57366. * @param mesh The mesh to replace the default mesh of the gizmo
  57367. */
  57368. setCustomMesh(mesh: Mesh): void;
  57369. }
  57370. }
  57371. declare module BABYLON {
  57372. /**
  57373. * Class containing static functions to help procedurally build meshes
  57374. */
  57375. export class PolyhedronBuilder {
  57376. /**
  57377. * Creates a polyhedron mesh
  57378. * * 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
  57379. * * The parameter `size` (positive float, default 1) sets the polygon size
  57380. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57381. * * 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`
  57382. * * 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
  57383. * * 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)`)
  57384. * * 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
  57385. * * 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
  57386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57387. * * 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
  57388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57389. * @param name defines the name of the mesh
  57390. * @param options defines the options used to create the mesh
  57391. * @param scene defines the hosting scene
  57392. * @returns the polyhedron mesh
  57393. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57394. */
  57395. static CreatePolyhedron(name: string, options: {
  57396. type?: number;
  57397. size?: number;
  57398. sizeX?: number;
  57399. sizeY?: number;
  57400. sizeZ?: number;
  57401. custom?: any;
  57402. faceUV?: Vector4[];
  57403. faceColors?: Color4[];
  57404. flat?: boolean;
  57405. updatable?: boolean;
  57406. sideOrientation?: number;
  57407. frontUVs?: Vector4;
  57408. backUVs?: Vector4;
  57409. }, scene?: Nullable<Scene>): Mesh;
  57410. }
  57411. }
  57412. declare module BABYLON {
  57413. /**
  57414. * Class containing static functions to help procedurally build meshes
  57415. */
  57416. export class BoxBuilder {
  57417. /**
  57418. * Creates a box mesh
  57419. * * The parameter `size` sets the size (float) of each box side (default 1)
  57420. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57421. * * 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)
  57422. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57424. * * 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
  57425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57426. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57427. * @param name defines the name of the mesh
  57428. * @param options defines the options used to create the mesh
  57429. * @param scene defines the hosting scene
  57430. * @returns the box mesh
  57431. */
  57432. static CreateBox(name: string, options: {
  57433. size?: number;
  57434. width?: number;
  57435. height?: number;
  57436. depth?: number;
  57437. faceUV?: Vector4[];
  57438. faceColors?: Color4[];
  57439. sideOrientation?: number;
  57440. frontUVs?: Vector4;
  57441. backUVs?: Vector4;
  57442. wrap?: boolean;
  57443. topBaseAt?: number;
  57444. bottomBaseAt?: number;
  57445. updatable?: boolean;
  57446. }, scene?: Nullable<Scene>): Mesh;
  57447. }
  57448. }
  57449. declare module BABYLON {
  57450. /**
  57451. * Single axis scale gizmo
  57452. */
  57453. export class AxisScaleGizmo extends Gizmo {
  57454. /**
  57455. * Drag behavior responsible for the gizmos dragging interactions
  57456. */
  57457. dragBehavior: PointerDragBehavior;
  57458. private _pointerObserver;
  57459. /**
  57460. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57461. */
  57462. snapDistance: number;
  57463. /**
  57464. * Event that fires each time the gizmo snaps to a new location.
  57465. * * snapDistance is the the change in distance
  57466. */
  57467. onSnapObservable: Observable<{
  57468. snapDistance: number;
  57469. }>;
  57470. /**
  57471. * If the scaling operation should be done on all axis (default: false)
  57472. */
  57473. uniformScaling: boolean;
  57474. /**
  57475. * Custom sensitivity value for the drag strength
  57476. */
  57477. sensitivity: number;
  57478. private _isEnabled;
  57479. private _parent;
  57480. private _gizmoMesh;
  57481. private _coloredMaterial;
  57482. private _hoverMaterial;
  57483. private _disableMaterial;
  57484. private _dragging;
  57485. private _tmpVector;
  57486. private _tmpMatrix;
  57487. private _tmpMatrix2;
  57488. /**
  57489. * Creates an AxisScaleGizmo
  57490. * @param gizmoLayer The utility layer the gizmo will be added to
  57491. * @param dragAxis The axis which the gizmo will be able to scale on
  57492. * @param color The color of the gizmo
  57493. * @param thickness display gizmo axis thickness
  57494. */
  57495. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57496. /** Create Geometry for Gizmo */
  57497. private _createGizmoMesh;
  57498. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57499. /**
  57500. * If the gizmo is enabled
  57501. */
  57502. set isEnabled(value: boolean);
  57503. get isEnabled(): boolean;
  57504. /**
  57505. * Disposes of the gizmo
  57506. */
  57507. dispose(): void;
  57508. /**
  57509. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57510. * @param mesh The mesh to replace the default mesh of the gizmo
  57511. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57512. */
  57513. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57514. }
  57515. }
  57516. declare module BABYLON {
  57517. /**
  57518. * Gizmo that enables scaling a mesh along 3 axis
  57519. */
  57520. export class ScaleGizmo extends Gizmo {
  57521. /**
  57522. * Internal gizmo used for interactions on the x axis
  57523. */
  57524. xGizmo: AxisScaleGizmo;
  57525. /**
  57526. * Internal gizmo used for interactions on the y axis
  57527. */
  57528. yGizmo: AxisScaleGizmo;
  57529. /**
  57530. * Internal gizmo used for interactions on the z axis
  57531. */
  57532. zGizmo: AxisScaleGizmo;
  57533. /**
  57534. * Internal gizmo used to scale all axis equally
  57535. */
  57536. uniformScaleGizmo: AxisScaleGizmo;
  57537. private _meshAttached;
  57538. private _nodeAttached;
  57539. private _snapDistance;
  57540. private _uniformScalingMesh;
  57541. private _octahedron;
  57542. private _sensitivity;
  57543. private _coloredMaterial;
  57544. private _hoverMaterial;
  57545. private _disableMaterial;
  57546. private _observables;
  57547. /** Node Caching for quick lookup */
  57548. private _gizmoAxisCache;
  57549. /** Fires an event when any of it's sub gizmos are dragged */
  57550. onDragStartObservable: Observable<unknown>;
  57551. /** Fires an event when any of it's sub gizmos are released from dragging */
  57552. onDragEndObservable: Observable<unknown>;
  57553. get attachedMesh(): Nullable<AbstractMesh>;
  57554. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57555. get attachedNode(): Nullable<Node>;
  57556. set attachedNode(node: Nullable<Node>);
  57557. /**
  57558. * True when the mouse pointer is hovering a gizmo mesh
  57559. */
  57560. get isHovered(): boolean;
  57561. /**
  57562. * Creates a ScaleGizmo
  57563. * @param gizmoLayer The utility layer the gizmo will be added to
  57564. * @param thickness display gizmo axis thickness
  57565. */
  57566. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57567. /** Create Geometry for Gizmo */
  57568. private _createUniformScaleMesh;
  57569. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57570. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57571. /**
  57572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57573. */
  57574. set snapDistance(value: number);
  57575. get snapDistance(): number;
  57576. /**
  57577. * Ratio for the scale of the gizmo (Default: 1)
  57578. */
  57579. set scaleRatio(value: number);
  57580. get scaleRatio(): number;
  57581. /**
  57582. * Sensitivity factor for dragging (Default: 1)
  57583. */
  57584. set sensitivity(value: number);
  57585. get sensitivity(): number;
  57586. /**
  57587. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57588. * @param mesh Axis gizmo mesh
  57589. * @param cache Gizmo axis definition used for reactive gizmo UI
  57590. */
  57591. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57592. /**
  57593. * Disposes of the gizmo
  57594. */
  57595. dispose(): void;
  57596. }
  57597. }
  57598. declare module BABYLON {
  57599. /**
  57600. * Bounding box gizmo
  57601. */
  57602. export class BoundingBoxGizmo extends Gizmo {
  57603. private _lineBoundingBox;
  57604. private _rotateSpheresParent;
  57605. private _scaleBoxesParent;
  57606. private _boundingDimensions;
  57607. private _renderObserver;
  57608. private _pointerObserver;
  57609. private _scaleDragSpeed;
  57610. private _tmpQuaternion;
  57611. private _tmpVector;
  57612. private _tmpRotationMatrix;
  57613. /**
  57614. * 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)
  57615. */
  57616. ignoreChildren: boolean;
  57617. /**
  57618. * 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)
  57619. */
  57620. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57621. /**
  57622. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57623. */
  57624. rotationSphereSize: number;
  57625. /**
  57626. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57627. */
  57628. scaleBoxSize: number;
  57629. /**
  57630. * 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)
  57631. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57632. */
  57633. fixedDragMeshScreenSize: boolean;
  57634. /**
  57635. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57636. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57637. */
  57638. fixedDragMeshBoundsSize: boolean;
  57639. /**
  57640. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57641. */
  57642. fixedDragMeshScreenSizeDistanceFactor: number;
  57643. /**
  57644. * Fired when a rotation sphere or scale box is dragged
  57645. */
  57646. onDragStartObservable: Observable<{}>;
  57647. /**
  57648. * Fired when a scale box is dragged
  57649. */
  57650. onScaleBoxDragObservable: Observable<{}>;
  57651. /**
  57652. * Fired when a scale box drag is ended
  57653. */
  57654. onScaleBoxDragEndObservable: Observable<{}>;
  57655. /**
  57656. * Fired when a rotation sphere is dragged
  57657. */
  57658. onRotationSphereDragObservable: Observable<{}>;
  57659. /**
  57660. * Fired when a rotation sphere drag is ended
  57661. */
  57662. onRotationSphereDragEndObservable: Observable<{}>;
  57663. /**
  57664. * 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)
  57665. */
  57666. scalePivot: Nullable<Vector3>;
  57667. /**
  57668. * Mesh used as a pivot to rotate the attached node
  57669. */
  57670. private _anchorMesh;
  57671. private _existingMeshScale;
  57672. private _dragMesh;
  57673. private pointerDragBehavior;
  57674. private coloredMaterial;
  57675. private hoverColoredMaterial;
  57676. /**
  57677. * Sets the color of the bounding box gizmo
  57678. * @param color the color to set
  57679. */
  57680. setColor(color: Color3): void;
  57681. /**
  57682. * Creates an BoundingBoxGizmo
  57683. * @param gizmoLayer The utility layer the gizmo will be added to
  57684. * @param color The color of the gizmo
  57685. */
  57686. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57687. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57688. private _selectNode;
  57689. /**
  57690. * Updates the bounding box information for the Gizmo
  57691. */
  57692. updateBoundingBox(): void;
  57693. private _updateRotationSpheres;
  57694. private _updateScaleBoxes;
  57695. /**
  57696. * Enables rotation on the specified axis and disables rotation on the others
  57697. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57698. */
  57699. setEnabledRotationAxis(axis: string): void;
  57700. /**
  57701. * Enables/disables scaling
  57702. * @param enable if scaling should be enabled
  57703. * @param homogeneousScaling defines if scaling should only be homogeneous
  57704. */
  57705. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57706. private _updateDummy;
  57707. /**
  57708. * Enables a pointer drag behavior on the bounding box of the gizmo
  57709. */
  57710. enableDragBehavior(): void;
  57711. /**
  57712. * Disposes of the gizmo
  57713. */
  57714. dispose(): void;
  57715. /**
  57716. * 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)
  57717. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57718. * @returns the bounding box mesh with the passed in mesh as a child
  57719. */
  57720. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57721. /**
  57722. * CustomMeshes are not supported by this gizmo
  57723. * @param mesh The mesh to replace the default mesh of the gizmo
  57724. */
  57725. setCustomMesh(mesh: Mesh): void;
  57726. }
  57727. }
  57728. declare module BABYLON {
  57729. /**
  57730. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57731. */
  57732. export class GizmoManager implements IDisposable {
  57733. private scene;
  57734. /**
  57735. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57736. */
  57737. gizmos: {
  57738. positionGizmo: Nullable<PositionGizmo>;
  57739. rotationGizmo: Nullable<RotationGizmo>;
  57740. scaleGizmo: Nullable<ScaleGizmo>;
  57741. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57742. };
  57743. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57744. clearGizmoOnEmptyPointerEvent: boolean;
  57745. /** Fires an event when the manager is attached to a mesh */
  57746. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57747. /** Fires an event when the manager is attached to a node */
  57748. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57749. private _gizmosEnabled;
  57750. private _pointerObservers;
  57751. private _attachedMesh;
  57752. private _attachedNode;
  57753. private _boundingBoxColor;
  57754. private _defaultUtilityLayer;
  57755. private _defaultKeepDepthUtilityLayer;
  57756. private _thickness;
  57757. /** Node Caching for quick lookup */
  57758. private _gizmoAxisCache;
  57759. /**
  57760. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57761. */
  57762. boundingBoxDragBehavior: SixDofDragBehavior;
  57763. /**
  57764. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57765. */
  57766. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57767. /**
  57768. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57769. */
  57770. attachableNodes: Nullable<Array<Node>>;
  57771. /**
  57772. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57773. */
  57774. usePointerToAttachGizmos: boolean;
  57775. /**
  57776. * Utility layer that the bounding box gizmo belongs to
  57777. */
  57778. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57779. /**
  57780. * Utility layer that all gizmos besides bounding box belong to
  57781. */
  57782. get utilityLayer(): UtilityLayerRenderer;
  57783. /**
  57784. * True when the mouse pointer is hovering a gizmo mesh
  57785. */
  57786. get isHovered(): boolean;
  57787. /**
  57788. * Instatiates a gizmo manager
  57789. * @param scene the scene to overlay the gizmos on top of
  57790. * @param thickness display gizmo axis thickness
  57791. * @param utilityLayer the layer where gizmos are rendered
  57792. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57793. */
  57794. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57795. /**
  57796. * Subscribes to pointer down events, for attaching and detaching mesh
  57797. * @param scene The sceme layer the observer will be added to
  57798. */
  57799. private _attachToMeshPointerObserver;
  57800. /**
  57801. * Attaches a set of gizmos to the specified mesh
  57802. * @param mesh The mesh the gizmo's should be attached to
  57803. */
  57804. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57805. /**
  57806. * Attaches a set of gizmos to the specified node
  57807. * @param node The node the gizmo's should be attached to
  57808. */
  57809. attachToNode(node: Nullable<Node>): void;
  57810. /**
  57811. * If the position gizmo is enabled
  57812. */
  57813. set positionGizmoEnabled(value: boolean);
  57814. get positionGizmoEnabled(): boolean;
  57815. /**
  57816. * If the rotation gizmo is enabled
  57817. */
  57818. set rotationGizmoEnabled(value: boolean);
  57819. get rotationGizmoEnabled(): boolean;
  57820. /**
  57821. * If the scale gizmo is enabled
  57822. */
  57823. set scaleGizmoEnabled(value: boolean);
  57824. get scaleGizmoEnabled(): boolean;
  57825. /**
  57826. * If the boundingBox gizmo is enabled
  57827. */
  57828. set boundingBoxGizmoEnabled(value: boolean);
  57829. get boundingBoxGizmoEnabled(): boolean;
  57830. /**
  57831. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57832. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57833. */
  57834. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57835. /**
  57836. * Disposes of the gizmo manager
  57837. */
  57838. dispose(): void;
  57839. }
  57840. }
  57841. declare module BABYLON {
  57842. /**
  57843. * Gizmo that enables dragging a mesh along 3 axis
  57844. */
  57845. export class PositionGizmo extends Gizmo {
  57846. /**
  57847. * Internal gizmo used for interactions on the x axis
  57848. */
  57849. xGizmo: AxisDragGizmo;
  57850. /**
  57851. * Internal gizmo used for interactions on the y axis
  57852. */
  57853. yGizmo: AxisDragGizmo;
  57854. /**
  57855. * Internal gizmo used for interactions on the z axis
  57856. */
  57857. zGizmo: AxisDragGizmo;
  57858. /**
  57859. * Internal gizmo used for interactions on the yz plane
  57860. */
  57861. xPlaneGizmo: PlaneDragGizmo;
  57862. /**
  57863. * Internal gizmo used for interactions on the xz plane
  57864. */
  57865. yPlaneGizmo: PlaneDragGizmo;
  57866. /**
  57867. * Internal gizmo used for interactions on the xy plane
  57868. */
  57869. zPlaneGizmo: PlaneDragGizmo;
  57870. /**
  57871. * private variables
  57872. */
  57873. private _meshAttached;
  57874. private _nodeAttached;
  57875. private _snapDistance;
  57876. private _observables;
  57877. /** Node Caching for quick lookup */
  57878. private _gizmoAxisCache;
  57879. /** Fires an event when any of it's sub gizmos are dragged */
  57880. onDragStartObservable: Observable<unknown>;
  57881. /** Fires an event when any of it's sub gizmos are released from dragging */
  57882. onDragEndObservable: Observable<unknown>;
  57883. /**
  57884. * If set to true, planar drag is enabled
  57885. */
  57886. private _planarGizmoEnabled;
  57887. get attachedMesh(): Nullable<AbstractMesh>;
  57888. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57889. get attachedNode(): Nullable<Node>;
  57890. set attachedNode(node: Nullable<Node>);
  57891. /**
  57892. * True when the mouse pointer is hovering a gizmo mesh
  57893. */
  57894. get isHovered(): boolean;
  57895. /**
  57896. * Creates a PositionGizmo
  57897. * @param gizmoLayer The utility layer the gizmo will be added to
  57898. @param thickness display gizmo axis thickness
  57899. */
  57900. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57901. /**
  57902. * If the planar drag gizmo is enabled
  57903. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57904. */
  57905. set planarGizmoEnabled(value: boolean);
  57906. get planarGizmoEnabled(): boolean;
  57907. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57908. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57909. /**
  57910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57911. */
  57912. set snapDistance(value: number);
  57913. get snapDistance(): number;
  57914. /**
  57915. * Ratio for the scale of the gizmo (Default: 1)
  57916. */
  57917. set scaleRatio(value: number);
  57918. get scaleRatio(): number;
  57919. /**
  57920. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57921. * @param mesh Axis gizmo mesh
  57922. * @param cache Gizmo axis definition used for reactive gizmo UI
  57923. */
  57924. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57925. /**
  57926. * Disposes of the gizmo
  57927. */
  57928. dispose(): void;
  57929. /**
  57930. * CustomMeshes are not supported by this gizmo
  57931. * @param mesh The mesh to replace the default mesh of the gizmo
  57932. */
  57933. setCustomMesh(mesh: Mesh): void;
  57934. }
  57935. }
  57936. declare module BABYLON {
  57937. /**
  57938. * Single axis drag gizmo
  57939. */
  57940. export class AxisDragGizmo extends Gizmo {
  57941. /**
  57942. * Drag behavior responsible for the gizmos dragging interactions
  57943. */
  57944. dragBehavior: PointerDragBehavior;
  57945. private _pointerObserver;
  57946. /**
  57947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57948. */
  57949. snapDistance: number;
  57950. /**
  57951. * Event that fires each time the gizmo snaps to a new location.
  57952. * * snapDistance is the the change in distance
  57953. */
  57954. onSnapObservable: Observable<{
  57955. snapDistance: number;
  57956. }>;
  57957. private _isEnabled;
  57958. private _parent;
  57959. private _gizmoMesh;
  57960. private _coloredMaterial;
  57961. private _hoverMaterial;
  57962. private _disableMaterial;
  57963. private _dragging;
  57964. /** @hidden */
  57965. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57966. /** @hidden */
  57967. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57968. /**
  57969. * Creates an AxisDragGizmo
  57970. * @param gizmoLayer The utility layer the gizmo will be added to
  57971. * @param dragAxis The axis which the gizmo will be able to drag on
  57972. * @param color The color of the gizmo
  57973. * @param thickness display gizmo axis thickness
  57974. */
  57975. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57976. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57977. /**
  57978. * If the gizmo is enabled
  57979. */
  57980. set isEnabled(value: boolean);
  57981. get isEnabled(): boolean;
  57982. /**
  57983. * Disposes of the gizmo
  57984. */
  57985. dispose(): void;
  57986. }
  57987. }
  57988. declare module BABYLON.Debug {
  57989. /**
  57990. * The Axes viewer will show 3 axes in a specific point in space
  57991. */
  57992. export class AxesViewer {
  57993. private _xAxis;
  57994. private _yAxis;
  57995. private _zAxis;
  57996. private _scaleLinesFactor;
  57997. private _instanced;
  57998. /**
  57999. * Gets the hosting scene
  58000. */
  58001. scene: Nullable<Scene>;
  58002. /**
  58003. * Gets or sets a number used to scale line length
  58004. */
  58005. scaleLines: number;
  58006. /** Gets the node hierarchy used to render x-axis */
  58007. get xAxis(): TransformNode;
  58008. /** Gets the node hierarchy used to render y-axis */
  58009. get yAxis(): TransformNode;
  58010. /** Gets the node hierarchy used to render z-axis */
  58011. get zAxis(): TransformNode;
  58012. /**
  58013. * Creates a new AxesViewer
  58014. * @param scene defines the hosting scene
  58015. * @param scaleLines defines a number used to scale line length (1 by default)
  58016. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58017. * @param xAxis defines the node hierarchy used to render the x-axis
  58018. * @param yAxis defines the node hierarchy used to render the y-axis
  58019. * @param zAxis defines the node hierarchy used to render the z-axis
  58020. */
  58021. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58022. /**
  58023. * Force the viewer to update
  58024. * @param position defines the position of the viewer
  58025. * @param xaxis defines the x axis of the viewer
  58026. * @param yaxis defines the y axis of the viewer
  58027. * @param zaxis defines the z axis of the viewer
  58028. */
  58029. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58030. /**
  58031. * Creates an instance of this axes viewer.
  58032. * @returns a new axes viewer with instanced meshes
  58033. */
  58034. createInstance(): AxesViewer;
  58035. /** Releases resources */
  58036. dispose(): void;
  58037. private static _SetRenderingGroupId;
  58038. }
  58039. }
  58040. declare module BABYLON.Debug {
  58041. /**
  58042. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58043. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58044. */
  58045. export class BoneAxesViewer extends AxesViewer {
  58046. /**
  58047. * Gets or sets the target mesh where to display the axes viewer
  58048. */
  58049. mesh: Nullable<Mesh>;
  58050. /**
  58051. * Gets or sets the target bone where to display the axes viewer
  58052. */
  58053. bone: Nullable<Bone>;
  58054. /** Gets current position */
  58055. pos: Vector3;
  58056. /** Gets direction of X axis */
  58057. xaxis: Vector3;
  58058. /** Gets direction of Y axis */
  58059. yaxis: Vector3;
  58060. /** Gets direction of Z axis */
  58061. zaxis: Vector3;
  58062. /**
  58063. * Creates a new BoneAxesViewer
  58064. * @param scene defines the hosting scene
  58065. * @param bone defines the target bone
  58066. * @param mesh defines the target mesh
  58067. * @param scaleLines defines a scaling factor for line length (1 by default)
  58068. */
  58069. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58070. /**
  58071. * Force the viewer to update
  58072. */
  58073. update(): void;
  58074. /** Releases resources */
  58075. dispose(): void;
  58076. }
  58077. }
  58078. declare module BABYLON {
  58079. /**
  58080. * Interface used to define scene explorer extensibility option
  58081. */
  58082. export interface IExplorerExtensibilityOption {
  58083. /**
  58084. * Define the option label
  58085. */
  58086. label: string;
  58087. /**
  58088. * Defines the action to execute on click
  58089. */
  58090. action: (entity: any) => void;
  58091. }
  58092. /**
  58093. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58094. */
  58095. export interface IExplorerExtensibilityGroup {
  58096. /**
  58097. * Defines a predicate to test if a given type mut be extended
  58098. */
  58099. predicate: (entity: any) => boolean;
  58100. /**
  58101. * Gets the list of options added to a type
  58102. */
  58103. entries: IExplorerExtensibilityOption[];
  58104. }
  58105. /**
  58106. * Interface used to define the options to use to create the Inspector
  58107. */
  58108. export interface IInspectorOptions {
  58109. /**
  58110. * Display in overlay mode (default: false)
  58111. */
  58112. overlay?: boolean;
  58113. /**
  58114. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58115. */
  58116. globalRoot?: HTMLElement;
  58117. /**
  58118. * Display the Scene explorer
  58119. */
  58120. showExplorer?: boolean;
  58121. /**
  58122. * Display the property inspector
  58123. */
  58124. showInspector?: boolean;
  58125. /**
  58126. * Display in embed mode (both panes on the right)
  58127. */
  58128. embedMode?: boolean;
  58129. /**
  58130. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58131. */
  58132. handleResize?: boolean;
  58133. /**
  58134. * Allow the panes to popup (default: true)
  58135. */
  58136. enablePopup?: boolean;
  58137. /**
  58138. * Allow the panes to be closed by users (default: true)
  58139. */
  58140. enableClose?: boolean;
  58141. /**
  58142. * Optional list of extensibility entries
  58143. */
  58144. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58145. /**
  58146. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58147. */
  58148. inspectorURL?: string;
  58149. /**
  58150. * Optional initial tab (default to DebugLayerTab.Properties)
  58151. */
  58152. initialTab?: DebugLayerTab;
  58153. }
  58154. interface Scene {
  58155. /**
  58156. * @hidden
  58157. * Backing field
  58158. */
  58159. _debugLayer: DebugLayer;
  58160. /**
  58161. * Gets the debug layer (aka Inspector) associated with the scene
  58162. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58163. */
  58164. debugLayer: DebugLayer;
  58165. }
  58166. /**
  58167. * Enum of inspector action tab
  58168. */
  58169. export enum DebugLayerTab {
  58170. /**
  58171. * Properties tag (default)
  58172. */
  58173. Properties = 0,
  58174. /**
  58175. * Debug tab
  58176. */
  58177. Debug = 1,
  58178. /**
  58179. * Statistics tab
  58180. */
  58181. Statistics = 2,
  58182. /**
  58183. * Tools tab
  58184. */
  58185. Tools = 3,
  58186. /**
  58187. * Settings tab
  58188. */
  58189. Settings = 4
  58190. }
  58191. /**
  58192. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58193. * what is happening in your scene
  58194. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58195. */
  58196. export class DebugLayer {
  58197. /**
  58198. * Define the url to get the inspector script from.
  58199. * By default it uses the babylonjs CDN.
  58200. * @ignoreNaming
  58201. */
  58202. static InspectorURL: string;
  58203. private _scene;
  58204. private BJSINSPECTOR;
  58205. private _onPropertyChangedObservable?;
  58206. /**
  58207. * Observable triggered when a property is changed through the inspector.
  58208. */
  58209. get onPropertyChangedObservable(): any;
  58210. /**
  58211. * Instantiates a new debug layer.
  58212. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58213. * what is happening in your scene
  58214. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58215. * @param scene Defines the scene to inspect
  58216. */
  58217. constructor(scene: Scene);
  58218. /** Creates the inspector window. */
  58219. private _createInspector;
  58220. /**
  58221. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58222. * @param entity defines the entity to select
  58223. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58224. */
  58225. select(entity: any, lineContainerTitles?: string | string[]): void;
  58226. /** Get the inspector from bundle or global */
  58227. private _getGlobalInspector;
  58228. /**
  58229. * Get if the inspector is visible or not.
  58230. * @returns true if visible otherwise, false
  58231. */
  58232. isVisible(): boolean;
  58233. /**
  58234. * Hide the inspector and close its window.
  58235. */
  58236. hide(): void;
  58237. /**
  58238. * Update the scene in the inspector
  58239. */
  58240. setAsActiveScene(): void;
  58241. /**
  58242. * Launch the debugLayer.
  58243. * @param config Define the configuration of the inspector
  58244. * @return a promise fulfilled when the debug layer is visible
  58245. */
  58246. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58247. }
  58248. }
  58249. declare module BABYLON.Debug {
  58250. /**
  58251. * Used to show the physics impostor around the specific mesh
  58252. */
  58253. export class PhysicsViewer {
  58254. /** @hidden */
  58255. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58256. /** @hidden */
  58257. protected _meshes: Array<Nullable<AbstractMesh>>;
  58258. /** @hidden */
  58259. protected _scene: Nullable<Scene>;
  58260. /** @hidden */
  58261. protected _numMeshes: number;
  58262. /** @hidden */
  58263. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58264. private _renderFunction;
  58265. private _utilityLayer;
  58266. private _debugBoxMesh;
  58267. private _debugSphereMesh;
  58268. private _debugCylinderMesh;
  58269. private _debugMaterial;
  58270. private _debugMeshMeshes;
  58271. /**
  58272. * Creates a new PhysicsViewer
  58273. * @param scene defines the hosting scene
  58274. */
  58275. constructor(scene: Scene);
  58276. /** @hidden */
  58277. protected _updateDebugMeshes(): void;
  58278. /**
  58279. * Renders a specified physic impostor
  58280. * @param impostor defines the impostor to render
  58281. * @param targetMesh defines the mesh represented by the impostor
  58282. * @returns the new debug mesh used to render the impostor
  58283. */
  58284. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58285. /**
  58286. * Hides a specified physic impostor
  58287. * @param impostor defines the impostor to hide
  58288. */
  58289. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58290. private _getDebugMaterial;
  58291. private _getDebugBoxMesh;
  58292. private _getDebugSphereMesh;
  58293. private _getDebugCylinderMesh;
  58294. private _getDebugMeshMesh;
  58295. private _getDebugMesh;
  58296. /** Releases all resources */
  58297. dispose(): void;
  58298. }
  58299. }
  58300. declare module BABYLON {
  58301. /**
  58302. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58303. * in order to better appreciate the issue one might have.
  58304. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58305. */
  58306. export class RayHelper {
  58307. /**
  58308. * Defines the ray we are currently tryin to visualize.
  58309. */
  58310. ray: Nullable<Ray>;
  58311. private _renderPoints;
  58312. private _renderLine;
  58313. private _renderFunction;
  58314. private _scene;
  58315. private _onAfterRenderObserver;
  58316. private _onAfterStepObserver;
  58317. private _attachedToMesh;
  58318. private _meshSpaceDirection;
  58319. private _meshSpaceOrigin;
  58320. /**
  58321. * Helper function to create a colored helper in a scene in one line.
  58322. * @param ray Defines the ray we are currently tryin to visualize
  58323. * @param scene Defines the scene the ray is used in
  58324. * @param color Defines the color we want to see the ray in
  58325. * @returns The newly created ray helper.
  58326. */
  58327. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58328. /**
  58329. * Instantiate a new ray helper.
  58330. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58331. * in order to better appreciate the issue one might have.
  58332. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58333. * @param ray Defines the ray we are currently tryin to visualize
  58334. */
  58335. constructor(ray: Ray);
  58336. /**
  58337. * Shows the ray we are willing to debug.
  58338. * @param scene Defines the scene the ray needs to be rendered in
  58339. * @param color Defines the color the ray needs to be rendered in
  58340. */
  58341. show(scene: Scene, color?: Color3): void;
  58342. /**
  58343. * Hides the ray we are debugging.
  58344. */
  58345. hide(): void;
  58346. private _render;
  58347. /**
  58348. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58349. * @param mesh Defines the mesh we want the helper attached to
  58350. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58351. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58352. * @param length Defines the length of the ray
  58353. */
  58354. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58355. /**
  58356. * Detach the ray helper from the mesh it has previously been attached to.
  58357. */
  58358. detachFromMesh(): void;
  58359. private _updateToMesh;
  58360. /**
  58361. * Dispose the helper and release its associated resources.
  58362. */
  58363. dispose(): void;
  58364. }
  58365. }
  58366. declare module BABYLON {
  58367. /**
  58368. * Defines the options associated with the creation of a SkeletonViewer.
  58369. */
  58370. export interface ISkeletonViewerOptions {
  58371. /** Should the system pause animations before building the Viewer? */
  58372. pauseAnimations: boolean;
  58373. /** Should the system return the skeleton to rest before building? */
  58374. returnToRest: boolean;
  58375. /** public Display Mode of the Viewer */
  58376. displayMode: number;
  58377. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58378. displayOptions: ISkeletonViewerDisplayOptions;
  58379. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58380. computeBonesUsingShaders: boolean;
  58381. /** Flag ignore non weighted bones */
  58382. useAllBones: boolean;
  58383. }
  58384. /**
  58385. * Defines how to display the various bone meshes for the viewer.
  58386. */
  58387. export interface ISkeletonViewerDisplayOptions {
  58388. /** How far down to start tapering the bone spurs */
  58389. midStep?: number;
  58390. /** How big is the midStep? */
  58391. midStepFactor?: number;
  58392. /** Base for the Sphere Size */
  58393. sphereBaseSize?: number;
  58394. /** The ratio of the sphere to the longest bone in units */
  58395. sphereScaleUnit?: number;
  58396. /** Ratio for the Sphere Size */
  58397. sphereFactor?: number;
  58398. /** Whether a spur should attach its far end to the child bone position */
  58399. spurFollowsChild?: boolean;
  58400. /** Whether to show local axes or not */
  58401. showLocalAxes?: boolean;
  58402. /** Length of each local axis */
  58403. localAxesSize?: number;
  58404. }
  58405. /**
  58406. * Defines the constructor options for the BoneWeight Shader.
  58407. */
  58408. export interface IBoneWeightShaderOptions {
  58409. /** Skeleton to Map */
  58410. skeleton: Skeleton;
  58411. /** Colors for Uninfluenced bones */
  58412. colorBase?: Color3;
  58413. /** Colors for 0.0-0.25 Weight bones */
  58414. colorZero?: Color3;
  58415. /** Color for 0.25-0.5 Weight Influence */
  58416. colorQuarter?: Color3;
  58417. /** Color for 0.5-0.75 Weight Influence */
  58418. colorHalf?: Color3;
  58419. /** Color for 0.75-1 Weight Influence */
  58420. colorFull?: Color3;
  58421. /** Color for Zero Weight Influence */
  58422. targetBoneIndex?: number;
  58423. }
  58424. /**
  58425. * Simple structure of the gradient steps for the Color Map.
  58426. */
  58427. export interface ISkeletonMapShaderColorMapKnot {
  58428. /** Color of the Knot */
  58429. color: Color3;
  58430. /** Location of the Knot */
  58431. location: number;
  58432. }
  58433. /**
  58434. * Defines the constructor options for the SkeletonMap Shader.
  58435. */
  58436. export interface ISkeletonMapShaderOptions {
  58437. /** Skeleton to Map */
  58438. skeleton: Skeleton;
  58439. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58440. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58441. }
  58442. }
  58443. declare module BABYLON {
  58444. /**
  58445. * Class containing static functions to help procedurally build meshes
  58446. */
  58447. export class RibbonBuilder {
  58448. /**
  58449. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58450. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58451. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58452. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58453. * * 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
  58454. * * 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
  58455. * * 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
  58456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58457. * * 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
  58458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58459. * * 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
  58460. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58461. * * 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
  58462. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58464. * @param name defines the name of the mesh
  58465. * @param options defines the options used to create the mesh
  58466. * @param scene defines the hosting scene
  58467. * @returns the ribbon mesh
  58468. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58470. */
  58471. static CreateRibbon(name: string, options: {
  58472. pathArray: Vector3[][];
  58473. closeArray?: boolean;
  58474. closePath?: boolean;
  58475. offset?: number;
  58476. updatable?: boolean;
  58477. sideOrientation?: number;
  58478. frontUVs?: Vector4;
  58479. backUVs?: Vector4;
  58480. instance?: Mesh;
  58481. invertUV?: boolean;
  58482. uvs?: Vector2[];
  58483. colors?: Color4[];
  58484. }, scene?: Nullable<Scene>): Mesh;
  58485. }
  58486. }
  58487. declare module BABYLON {
  58488. /**
  58489. * Class containing static functions to help procedurally build meshes
  58490. */
  58491. export class ShapeBuilder {
  58492. /**
  58493. * 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.
  58494. * * 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.
  58495. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58496. * * 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.
  58497. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58498. * * 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
  58499. * * 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
  58500. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58502. * * 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
  58503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58505. * @param name defines the name of the mesh
  58506. * @param options defines the options used to create the mesh
  58507. * @param scene defines the hosting scene
  58508. * @returns the extruded shape mesh
  58509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58511. */
  58512. static ExtrudeShape(name: string, options: {
  58513. shape: Vector3[];
  58514. path: Vector3[];
  58515. scale?: number;
  58516. rotation?: number;
  58517. cap?: number;
  58518. updatable?: boolean;
  58519. sideOrientation?: number;
  58520. frontUVs?: Vector4;
  58521. backUVs?: Vector4;
  58522. instance?: Mesh;
  58523. invertUV?: boolean;
  58524. }, scene?: Nullable<Scene>): Mesh;
  58525. /**
  58526. * Creates an custom extruded shape mesh.
  58527. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58528. * * 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.
  58529. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58530. * * 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
  58531. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58532. * * 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
  58533. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58534. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58535. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58536. * * 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
  58537. * * 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
  58538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58540. * * 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
  58541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58543. * @param name defines the name of the mesh
  58544. * @param options defines the options used to create the mesh
  58545. * @param scene defines the hosting scene
  58546. * @returns the custom extruded shape mesh
  58547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58550. */
  58551. static ExtrudeShapeCustom(name: string, options: {
  58552. shape: Vector3[];
  58553. path: Vector3[];
  58554. scaleFunction?: any;
  58555. rotationFunction?: any;
  58556. ribbonCloseArray?: boolean;
  58557. ribbonClosePath?: boolean;
  58558. cap?: number;
  58559. updatable?: boolean;
  58560. sideOrientation?: number;
  58561. frontUVs?: Vector4;
  58562. backUVs?: Vector4;
  58563. instance?: Mesh;
  58564. invertUV?: boolean;
  58565. }, scene?: Nullable<Scene>): Mesh;
  58566. private static _ExtrudeShapeGeneric;
  58567. }
  58568. }
  58569. declare module BABYLON.Debug {
  58570. /**
  58571. * Class used to render a debug view of a given skeleton
  58572. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58573. */
  58574. export class SkeletonViewer {
  58575. /** defines the skeleton to render */
  58576. skeleton: Skeleton;
  58577. /** defines the mesh attached to the skeleton */
  58578. mesh: AbstractMesh;
  58579. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58580. autoUpdateBonesMatrices: boolean;
  58581. /** defines the rendering group id to use with the viewer */
  58582. renderingGroupId: number;
  58583. /** is the options for the viewer */
  58584. options: Partial<ISkeletonViewerOptions>;
  58585. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58586. static readonly DISPLAY_LINES: number;
  58587. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58588. static readonly DISPLAY_SPHERES: number;
  58589. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58590. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58591. /** public static method to create a BoneWeight Shader
  58592. * @param options The constructor options
  58593. * @param scene The scene that the shader is scoped to
  58594. * @returns The created ShaderMaterial
  58595. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58596. */
  58597. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58598. /** public static method to create a BoneWeight Shader
  58599. * @param options The constructor options
  58600. * @param scene The scene that the shader is scoped to
  58601. * @returns The created ShaderMaterial
  58602. */
  58603. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58604. /** private static method to create a BoneWeight Shader
  58605. * @param size The size of the buffer to create (usually the bone count)
  58606. * @param colorMap The gradient data to generate
  58607. * @param scene The scene that the shader is scoped to
  58608. * @returns an Array of floats from the color gradient values
  58609. */
  58610. private static _CreateBoneMapColorBuffer;
  58611. /** If SkeletonViewer scene scope. */
  58612. private _scene;
  58613. /** Gets or sets the color used to render the skeleton */
  58614. color: Color3;
  58615. /** Array of the points of the skeleton fo the line view. */
  58616. private _debugLines;
  58617. /** The SkeletonViewers Mesh. */
  58618. private _debugMesh;
  58619. /** The local axes Meshes. */
  58620. private _localAxes;
  58621. /** If SkeletonViewer is enabled. */
  58622. private _isEnabled;
  58623. /** If SkeletonViewer is ready. */
  58624. private _ready;
  58625. /** SkeletonViewer render observable. */
  58626. private _obs;
  58627. /** The Utility Layer to render the gizmos in. */
  58628. private _utilityLayer;
  58629. private _boneIndices;
  58630. /** Gets the Scene. */
  58631. get scene(): Scene;
  58632. /** Gets the utilityLayer. */
  58633. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58634. /** Checks Ready Status. */
  58635. get isReady(): Boolean;
  58636. /** Sets Ready Status. */
  58637. set ready(value: boolean);
  58638. /** Gets the debugMesh */
  58639. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58640. /** Sets the debugMesh */
  58641. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58642. /** Gets the displayMode */
  58643. get displayMode(): number;
  58644. /** Sets the displayMode */
  58645. set displayMode(value: number);
  58646. /**
  58647. * Creates a new SkeletonViewer
  58648. * @param skeleton defines the skeleton to render
  58649. * @param mesh defines the mesh attached to the skeleton
  58650. * @param scene defines the hosting scene
  58651. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58652. * @param renderingGroupId defines the rendering group id to use with the viewer
  58653. * @param options All of the extra constructor options for the SkeletonViewer
  58654. */
  58655. constructor(
  58656. /** defines the skeleton to render */
  58657. skeleton: Skeleton,
  58658. /** defines the mesh attached to the skeleton */
  58659. mesh: AbstractMesh,
  58660. /** The Scene scope*/
  58661. scene: Scene,
  58662. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58663. autoUpdateBonesMatrices?: boolean,
  58664. /** defines the rendering group id to use with the viewer */
  58665. renderingGroupId?: number,
  58666. /** is the options for the viewer */
  58667. options?: Partial<ISkeletonViewerOptions>);
  58668. /** The Dynamic bindings for the update functions */
  58669. private _bindObs;
  58670. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58671. update(): void;
  58672. /** Gets or sets a boolean indicating if the viewer is enabled */
  58673. set isEnabled(value: boolean);
  58674. get isEnabled(): boolean;
  58675. private _getBonePosition;
  58676. private _getLinesForBonesWithLength;
  58677. private _getLinesForBonesNoLength;
  58678. /** function to revert the mesh and scene back to the initial state. */
  58679. private _revert;
  58680. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58681. private _getAbsoluteBindPoseToRef;
  58682. /** function to build and bind sphere joint points and spur bone representations. */
  58683. private _buildSpheresAndSpurs;
  58684. private _buildLocalAxes;
  58685. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58686. private _displayLinesUpdate;
  58687. /** Changes the displayMode of the skeleton viewer
  58688. * @param mode The displayMode numerical value
  58689. */
  58690. changeDisplayMode(mode: number): void;
  58691. /** Sets a display option of the skeleton viewer
  58692. *
  58693. * | Option | Type | Default | Description |
  58694. * | ---------------- | ------- | ------- | ----------- |
  58695. * | 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`. |
  58696. * | 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`. |
  58697. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58698. * | 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`. |
  58699. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58700. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58701. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58702. *
  58703. * @param option String of the option name
  58704. * @param value The numerical option value
  58705. */
  58706. changeDisplayOptions(option: string, value: number): void;
  58707. /** Release associated resources */
  58708. dispose(): void;
  58709. }
  58710. }
  58711. declare module BABYLON {
  58712. /**
  58713. * Enum for Device Types
  58714. */
  58715. export enum DeviceType {
  58716. /** Generic */
  58717. Generic = 0,
  58718. /** Keyboard */
  58719. Keyboard = 1,
  58720. /** Mouse */
  58721. Mouse = 2,
  58722. /** Touch Pointers */
  58723. Touch = 3,
  58724. /** PS4 Dual Shock */
  58725. DualShock = 4,
  58726. /** Xbox */
  58727. Xbox = 5,
  58728. /** Switch Controller */
  58729. Switch = 6
  58730. }
  58731. /**
  58732. * Enum for All Pointers (Touch/Mouse)
  58733. */
  58734. export enum PointerInput {
  58735. /** Horizontal Axis */
  58736. Horizontal = 0,
  58737. /** Vertical Axis */
  58738. Vertical = 1,
  58739. /** Left Click or Touch */
  58740. LeftClick = 2,
  58741. /** Middle Click */
  58742. MiddleClick = 3,
  58743. /** Right Click */
  58744. RightClick = 4,
  58745. /** Browser Back */
  58746. BrowserBack = 5,
  58747. /** Browser Forward */
  58748. BrowserForward = 6
  58749. }
  58750. /**
  58751. * Enum for Dual Shock Gamepad
  58752. */
  58753. export enum DualShockInput {
  58754. /** Cross */
  58755. Cross = 0,
  58756. /** Circle */
  58757. Circle = 1,
  58758. /** Square */
  58759. Square = 2,
  58760. /** Triangle */
  58761. Triangle = 3,
  58762. /** L1 */
  58763. L1 = 4,
  58764. /** R1 */
  58765. R1 = 5,
  58766. /** L2 */
  58767. L2 = 6,
  58768. /** R2 */
  58769. R2 = 7,
  58770. /** Share */
  58771. Share = 8,
  58772. /** Options */
  58773. Options = 9,
  58774. /** L3 */
  58775. L3 = 10,
  58776. /** R3 */
  58777. R3 = 11,
  58778. /** DPadUp */
  58779. DPadUp = 12,
  58780. /** DPadDown */
  58781. DPadDown = 13,
  58782. /** DPadLeft */
  58783. DPadLeft = 14,
  58784. /** DRight */
  58785. DPadRight = 15,
  58786. /** Home */
  58787. Home = 16,
  58788. /** TouchPad */
  58789. TouchPad = 17,
  58790. /** LStickXAxis */
  58791. LStickXAxis = 18,
  58792. /** LStickYAxis */
  58793. LStickYAxis = 19,
  58794. /** RStickXAxis */
  58795. RStickXAxis = 20,
  58796. /** RStickYAxis */
  58797. RStickYAxis = 21
  58798. }
  58799. /**
  58800. * Enum for Xbox Gamepad
  58801. */
  58802. export enum XboxInput {
  58803. /** A */
  58804. A = 0,
  58805. /** B */
  58806. B = 1,
  58807. /** X */
  58808. X = 2,
  58809. /** Y */
  58810. Y = 3,
  58811. /** LB */
  58812. LB = 4,
  58813. /** RB */
  58814. RB = 5,
  58815. /** LT */
  58816. LT = 6,
  58817. /** RT */
  58818. RT = 7,
  58819. /** Back */
  58820. Back = 8,
  58821. /** Start */
  58822. Start = 9,
  58823. /** LS */
  58824. LS = 10,
  58825. /** RS */
  58826. RS = 11,
  58827. /** DPadUp */
  58828. DPadUp = 12,
  58829. /** DPadDown */
  58830. DPadDown = 13,
  58831. /** DPadLeft */
  58832. DPadLeft = 14,
  58833. /** DRight */
  58834. DPadRight = 15,
  58835. /** Home */
  58836. Home = 16,
  58837. /** LStickXAxis */
  58838. LStickXAxis = 17,
  58839. /** LStickYAxis */
  58840. LStickYAxis = 18,
  58841. /** RStickXAxis */
  58842. RStickXAxis = 19,
  58843. /** RStickYAxis */
  58844. RStickYAxis = 20
  58845. }
  58846. /**
  58847. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58848. */
  58849. export enum SwitchInput {
  58850. /** B */
  58851. B = 0,
  58852. /** A */
  58853. A = 1,
  58854. /** Y */
  58855. Y = 2,
  58856. /** X */
  58857. X = 3,
  58858. /** L */
  58859. L = 4,
  58860. /** R */
  58861. R = 5,
  58862. /** ZL */
  58863. ZL = 6,
  58864. /** ZR */
  58865. ZR = 7,
  58866. /** Minus */
  58867. Minus = 8,
  58868. /** Plus */
  58869. Plus = 9,
  58870. /** LS */
  58871. LS = 10,
  58872. /** RS */
  58873. RS = 11,
  58874. /** DPadUp */
  58875. DPadUp = 12,
  58876. /** DPadDown */
  58877. DPadDown = 13,
  58878. /** DPadLeft */
  58879. DPadLeft = 14,
  58880. /** DRight */
  58881. DPadRight = 15,
  58882. /** Home */
  58883. Home = 16,
  58884. /** Capture */
  58885. Capture = 17,
  58886. /** LStickXAxis */
  58887. LStickXAxis = 18,
  58888. /** LStickYAxis */
  58889. LStickYAxis = 19,
  58890. /** RStickXAxis */
  58891. RStickXAxis = 20,
  58892. /** RStickYAxis */
  58893. RStickYAxis = 21
  58894. }
  58895. }
  58896. declare module BABYLON {
  58897. /**
  58898. * This class will take all inputs from Keyboard, Pointer, and
  58899. * any Gamepads and provide a polling system that all devices
  58900. * will use. This class assumes that there will only be one
  58901. * pointer device and one keyboard.
  58902. */
  58903. export class DeviceInputSystem implements IDisposable {
  58904. /**
  58905. * Returns onDeviceConnected callback property
  58906. * @returns Callback with function to execute when a device is connected
  58907. */
  58908. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58909. /**
  58910. * Sets callback function when a device is connected and executes against all connected devices
  58911. * @param callback Function to execute when a device is connected
  58912. */
  58913. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58914. /**
  58915. * Callback to be triggered when a device is disconnected
  58916. */
  58917. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58918. /**
  58919. * Callback to be triggered when event driven input is updated
  58920. */
  58921. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58922. private _inputs;
  58923. private _gamepads;
  58924. private _keyboardActive;
  58925. private _pointerActive;
  58926. private _elementToAttachTo;
  58927. private _keyboardDownEvent;
  58928. private _keyboardUpEvent;
  58929. private _pointerMoveEvent;
  58930. private _pointerDownEvent;
  58931. private _pointerUpEvent;
  58932. private _gamepadConnectedEvent;
  58933. private _gamepadDisconnectedEvent;
  58934. private _onDeviceConnected;
  58935. private static _MAX_KEYCODES;
  58936. private static _MAX_POINTER_INPUTS;
  58937. private constructor();
  58938. /**
  58939. * Creates a new DeviceInputSystem instance
  58940. * @param engine Engine to pull input element from
  58941. * @returns The new instance
  58942. */
  58943. static Create(engine: Engine): DeviceInputSystem;
  58944. /**
  58945. * Checks for current device input value, given an id and input index
  58946. * @param deviceName Id of connected device
  58947. * @param inputIndex Index of device input
  58948. * @returns Current value of input
  58949. */
  58950. /**
  58951. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58952. * @param deviceType Enum specifiying device type
  58953. * @param deviceSlot "Slot" or index that device is referenced in
  58954. * @param inputIndex Id of input to be checked
  58955. * @returns Current value of input
  58956. */
  58957. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58958. /**
  58959. * Dispose of all the eventlisteners
  58960. */
  58961. dispose(): void;
  58962. /**
  58963. * Checks for existing connections to devices and register them, if necessary
  58964. * Currently handles gamepads and mouse
  58965. */
  58966. private _checkForConnectedDevices;
  58967. /**
  58968. * Add a gamepad to the DeviceInputSystem
  58969. * @param gamepad A single DOM Gamepad object
  58970. */
  58971. private _addGamePad;
  58972. /**
  58973. * Add pointer device to DeviceInputSystem
  58974. * @param deviceType Type of Pointer to add
  58975. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58976. * @param currentX Current X at point of adding
  58977. * @param currentY Current Y at point of adding
  58978. */
  58979. private _addPointerDevice;
  58980. /**
  58981. * Add device and inputs to device array
  58982. * @param deviceType Enum specifiying device type
  58983. * @param deviceSlot "Slot" or index that device is referenced in
  58984. * @param numberOfInputs Number of input entries to create for given device
  58985. */
  58986. private _registerDevice;
  58987. /**
  58988. * Given a specific device name, remove that device from the device map
  58989. * @param deviceType Enum specifiying device type
  58990. * @param deviceSlot "Slot" or index that device is referenced in
  58991. */
  58992. private _unregisterDevice;
  58993. /**
  58994. * Handle all actions that come from keyboard interaction
  58995. */
  58996. private _handleKeyActions;
  58997. /**
  58998. * Handle all actions that come from pointer interaction
  58999. */
  59000. private _handlePointerActions;
  59001. /**
  59002. * Handle all actions that come from gamepad interaction
  59003. */
  59004. private _handleGamepadActions;
  59005. /**
  59006. * Update all non-event based devices with each frame
  59007. * @param deviceType Enum specifiying device type
  59008. * @param deviceSlot "Slot" or index that device is referenced in
  59009. * @param inputIndex Id of input to be checked
  59010. */
  59011. private _updateDevice;
  59012. /**
  59013. * Gets DeviceType from the device name
  59014. * @param deviceName Name of Device from DeviceInputSystem
  59015. * @returns DeviceType enum value
  59016. */
  59017. private _getGamepadDeviceType;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Type to handle enforcement of inputs
  59023. */
  59024. 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;
  59025. }
  59026. declare module BABYLON {
  59027. /**
  59028. * Class that handles all input for a specific device
  59029. */
  59030. export class DeviceSource<T extends DeviceType> {
  59031. /** Type of device */
  59032. readonly deviceType: DeviceType;
  59033. /** "Slot" or index that device is referenced in */
  59034. readonly deviceSlot: number;
  59035. /**
  59036. * Observable to handle device input changes per device
  59037. */
  59038. readonly onInputChangedObservable: Observable<{
  59039. inputIndex: DeviceInput<T>;
  59040. previousState: Nullable<number>;
  59041. currentState: Nullable<number>;
  59042. }>;
  59043. private readonly _deviceInputSystem;
  59044. /**
  59045. * Default Constructor
  59046. * @param deviceInputSystem Reference to DeviceInputSystem
  59047. * @param deviceType Type of device
  59048. * @param deviceSlot "Slot" or index that device is referenced in
  59049. */
  59050. constructor(deviceInputSystem: DeviceInputSystem,
  59051. /** Type of device */
  59052. deviceType: DeviceType,
  59053. /** "Slot" or index that device is referenced in */
  59054. deviceSlot?: number);
  59055. /**
  59056. * Get input for specific input
  59057. * @param inputIndex index of specific input on device
  59058. * @returns Input value from DeviceInputSystem
  59059. */
  59060. getInput(inputIndex: DeviceInput<T>): number;
  59061. }
  59062. /**
  59063. * Class to keep track of devices
  59064. */
  59065. export class DeviceSourceManager implements IDisposable {
  59066. /**
  59067. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59068. */
  59069. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59070. /**
  59071. * Observable to be triggered when after a device is disconnected
  59072. */
  59073. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59074. private readonly _devices;
  59075. private readonly _firstDevice;
  59076. private readonly _deviceInputSystem;
  59077. /**
  59078. * Default Constructor
  59079. * @param engine engine to pull input element from
  59080. */
  59081. constructor(engine: Engine);
  59082. /**
  59083. * Gets a DeviceSource, given a type and slot
  59084. * @param deviceType Enum specifying device type
  59085. * @param deviceSlot "Slot" or index that device is referenced in
  59086. * @returns DeviceSource object
  59087. */
  59088. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59089. /**
  59090. * Gets an array of DeviceSource objects for a given device type
  59091. * @param deviceType Enum specifying device type
  59092. * @returns Array of DeviceSource objects
  59093. */
  59094. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59095. /**
  59096. * Returns a read-only list of all available devices
  59097. * @returns Read-only array with active devices
  59098. */
  59099. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59100. /**
  59101. * Dispose of DeviceInputSystem and other parts
  59102. */
  59103. dispose(): void;
  59104. /**
  59105. * Function to add device name to device list
  59106. * @param deviceType Enum specifying device type
  59107. * @param deviceSlot "Slot" or index that device is referenced in
  59108. */
  59109. private _addDevice;
  59110. /**
  59111. * Function to remove device name to device list
  59112. * @param deviceType Enum specifying device type
  59113. * @param deviceSlot "Slot" or index that device is referenced in
  59114. */
  59115. private _removeDevice;
  59116. /**
  59117. * Updates array storing first connected device of each type
  59118. * @param type Type of Device
  59119. */
  59120. private _updateFirstDevices;
  59121. }
  59122. }
  59123. declare module BABYLON {
  59124. /**
  59125. * Options to create the null engine
  59126. */
  59127. export class NullEngineOptions {
  59128. /**
  59129. * Render width (Default: 512)
  59130. */
  59131. renderWidth: number;
  59132. /**
  59133. * Render height (Default: 256)
  59134. */
  59135. renderHeight: number;
  59136. /**
  59137. * Texture size (Default: 512)
  59138. */
  59139. textureSize: number;
  59140. /**
  59141. * If delta time between frames should be constant
  59142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59143. */
  59144. deterministicLockstep: boolean;
  59145. /**
  59146. * Maximum about of steps between frames (Default: 4)
  59147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59148. */
  59149. lockstepMaxSteps: number;
  59150. /**
  59151. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59152. */
  59153. useHighPrecisionMatrix?: boolean;
  59154. }
  59155. /**
  59156. * The null engine class provides support for headless version of babylon.js.
  59157. * This can be used in server side scenario or for testing purposes
  59158. */
  59159. export class NullEngine extends Engine {
  59160. private _options;
  59161. /**
  59162. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59163. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59164. * @returns true if engine is in deterministic lock step mode
  59165. */
  59166. isDeterministicLockStep(): boolean;
  59167. /**
  59168. * Gets the max steps when engine is running in deterministic lock step
  59169. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59170. * @returns the max steps
  59171. */
  59172. getLockstepMaxSteps(): number;
  59173. /**
  59174. * Gets the current hardware scaling level.
  59175. * By default the hardware scaling level is computed from the window device ratio.
  59176. * 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.
  59177. * @returns a number indicating the current hardware scaling level
  59178. */
  59179. getHardwareScalingLevel(): number;
  59180. constructor(options?: NullEngineOptions);
  59181. /**
  59182. * Creates a vertex buffer
  59183. * @param vertices the data for the vertex buffer
  59184. * @returns the new WebGL static buffer
  59185. */
  59186. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59187. /**
  59188. * Creates a new index buffer
  59189. * @param indices defines the content of the index buffer
  59190. * @param updatable defines if the index buffer must be updatable
  59191. * @returns a new webGL buffer
  59192. */
  59193. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59194. /**
  59195. * Clear the current render buffer or the current render target (if any is set up)
  59196. * @param color defines the color to use
  59197. * @param backBuffer defines if the back buffer must be cleared
  59198. * @param depth defines if the depth buffer must be cleared
  59199. * @param stencil defines if the stencil buffer must be cleared
  59200. */
  59201. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59202. /**
  59203. * Gets the current render width
  59204. * @param useScreen defines if screen size must be used (or the current render target if any)
  59205. * @returns a number defining the current render width
  59206. */
  59207. getRenderWidth(useScreen?: boolean): number;
  59208. /**
  59209. * Gets the current render height
  59210. * @param useScreen defines if screen size must be used (or the current render target if any)
  59211. * @returns a number defining the current render height
  59212. */
  59213. getRenderHeight(useScreen?: boolean): number;
  59214. /**
  59215. * Set the WebGL's viewport
  59216. * @param viewport defines the viewport element to be used
  59217. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59218. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59219. */
  59220. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59221. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59222. /**
  59223. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59224. * @param pipelineContext defines the pipeline context to use
  59225. * @param uniformsNames defines the list of uniform names
  59226. * @returns an array of webGL uniform locations
  59227. */
  59228. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59229. /**
  59230. * Gets the lsit of active attributes for a given webGL program
  59231. * @param pipelineContext defines the pipeline context to use
  59232. * @param attributesNames defines the list of attribute names to get
  59233. * @returns an array of indices indicating the offset of each attribute
  59234. */
  59235. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59236. /**
  59237. * Binds an effect to the webGL context
  59238. * @param effect defines the effect to bind
  59239. */
  59240. bindSamplers(effect: Effect): void;
  59241. /**
  59242. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  59243. * @param effect defines the effect to activate
  59244. */
  59245. enableEffect(effect: Effect): void;
  59246. /**
  59247. * Set various states to the webGL context
  59248. * @param culling defines backface culling state
  59249. * @param zOffset defines the value to apply to zOffset (0 by default)
  59250. * @param force defines if states must be applied even if cache is up to date
  59251. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59252. */
  59253. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59254. /**
  59255. * Set the value of an uniform to an array of int32
  59256. * @param uniform defines the webGL uniform location where to store the value
  59257. * @param array defines the array of int32 to store
  59258. * @returns true if value was set
  59259. */
  59260. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59261. /**
  59262. * Set the value of an uniform to an array of int32 (stored as vec2)
  59263. * @param uniform defines the webGL uniform location where to store the value
  59264. * @param array defines the array of int32 to store
  59265. * @returns true if value was set
  59266. */
  59267. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59268. /**
  59269. * Set the value of an uniform to an array of int32 (stored as vec3)
  59270. * @param uniform defines the webGL uniform location where to store the value
  59271. * @param array defines the array of int32 to store
  59272. * @returns true if value was set
  59273. */
  59274. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59275. /**
  59276. * Set the value of an uniform to an array of int32 (stored as vec4)
  59277. * @param uniform defines the webGL uniform location where to store the value
  59278. * @param array defines the array of int32 to store
  59279. * @returns true if value was set
  59280. */
  59281. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59282. /**
  59283. * Set the value of an uniform to an array of float32
  59284. * @param uniform defines the webGL uniform location where to store the value
  59285. * @param array defines the array of float32 to store
  59286. * @returns true if value was set
  59287. */
  59288. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59289. /**
  59290. * Set the value of an uniform to an array of float32 (stored as vec2)
  59291. * @param uniform defines the webGL uniform location where to store the value
  59292. * @param array defines the array of float32 to store
  59293. * @returns true if value was set
  59294. */
  59295. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59296. /**
  59297. * Set the value of an uniform to an array of float32 (stored as vec3)
  59298. * @param uniform defines the webGL uniform location where to store the value
  59299. * @param array defines the array of float32 to store
  59300. * @returns true if value was set
  59301. */
  59302. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59303. /**
  59304. * Set the value of an uniform to an array of float32 (stored as vec4)
  59305. * @param uniform defines the webGL uniform location where to store the value
  59306. * @param array defines the array of float32 to store
  59307. * @returns true if value was set
  59308. */
  59309. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59310. /**
  59311. * Set the value of an uniform to an array of number
  59312. * @param uniform defines the webGL uniform location where to store the value
  59313. * @param array defines the array of number to store
  59314. * @returns true if value was set
  59315. */
  59316. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59317. /**
  59318. * Set the value of an uniform to an array of number (stored as vec2)
  59319. * @param uniform defines the webGL uniform location where to store the value
  59320. * @param array defines the array of number to store
  59321. * @returns true if value was set
  59322. */
  59323. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59324. /**
  59325. * Set the value of an uniform to an array of number (stored as vec3)
  59326. * @param uniform defines the webGL uniform location where to store the value
  59327. * @param array defines the array of number to store
  59328. * @returns true if value was set
  59329. */
  59330. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59331. /**
  59332. * Set the value of an uniform to an array of number (stored as vec4)
  59333. * @param uniform defines the webGL uniform location where to store the value
  59334. * @param array defines the array of number to store
  59335. * @returns true if value was set
  59336. */
  59337. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59338. /**
  59339. * Set the value of an uniform to an array of float32 (stored as matrices)
  59340. * @param uniform defines the webGL uniform location where to store the value
  59341. * @param matrices defines the array of float32 to store
  59342. * @returns true if value was set
  59343. */
  59344. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59345. /**
  59346. * Set the value of an uniform to a matrix (3x3)
  59347. * @param uniform defines the webGL uniform location where to store the value
  59348. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59349. * @returns true if value was set
  59350. */
  59351. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59352. /**
  59353. * Set the value of an uniform to a matrix (2x2)
  59354. * @param uniform defines the webGL uniform location where to store the value
  59355. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59356. * @returns true if value was set
  59357. */
  59358. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59359. /**
  59360. * Set the value of an uniform to a number (float)
  59361. * @param uniform defines the webGL uniform location where to store the value
  59362. * @param value defines the float number to store
  59363. * @returns true if value was set
  59364. */
  59365. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59366. /**
  59367. * Set the value of an uniform to a vec2
  59368. * @param uniform defines the webGL uniform location where to store the value
  59369. * @param x defines the 1st component of the value
  59370. * @param y defines the 2nd component of the value
  59371. * @returns true if value was set
  59372. */
  59373. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59374. /**
  59375. * Set the value of an uniform to a vec3
  59376. * @param uniform defines the webGL uniform location where to store the value
  59377. * @param x defines the 1st component of the value
  59378. * @param y defines the 2nd component of the value
  59379. * @param z defines the 3rd component of the value
  59380. * @returns true if value was set
  59381. */
  59382. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59383. /**
  59384. * Set the value of an uniform to a boolean
  59385. * @param uniform defines the webGL uniform location where to store the value
  59386. * @param bool defines the boolean to store
  59387. * @returns true if value was set
  59388. */
  59389. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59390. /**
  59391. * Set the value of an uniform to a vec4
  59392. * @param uniform defines the webGL uniform location where to store the value
  59393. * @param x defines the 1st component of the value
  59394. * @param y defines the 2nd component of the value
  59395. * @param z defines the 3rd component of the value
  59396. * @param w defines the 4th component of the value
  59397. * @returns true if value was set
  59398. */
  59399. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59400. /**
  59401. * Sets the current alpha mode
  59402. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59403. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59404. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59405. */
  59406. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59407. /**
  59408. * Bind webGl buffers directly to the webGL context
  59409. * @param vertexBuffers defines the vertex buffer to bind
  59410. * @param indexBuffer defines the index buffer to bind
  59411. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59412. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59413. * @param effect defines the effect associated with the vertex buffer
  59414. */
  59415. bindBuffers(vertexBuffers: {
  59416. [key: string]: VertexBuffer;
  59417. }, indexBuffer: DataBuffer, effect: Effect): void;
  59418. /**
  59419. * Force the entire cache to be cleared
  59420. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59421. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59422. */
  59423. wipeCaches(bruteForce?: boolean): void;
  59424. /**
  59425. * Send a draw order
  59426. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59427. * @param indexStart defines the starting index
  59428. * @param indexCount defines the number of index to draw
  59429. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59430. */
  59431. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59432. /**
  59433. * Draw a list of indexed primitives
  59434. * @param fillMode defines the primitive to use
  59435. * @param indexStart defines the starting index
  59436. * @param indexCount defines the number of index to draw
  59437. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59438. */
  59439. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59440. /**
  59441. * Draw a list of unindexed primitives
  59442. * @param fillMode defines the primitive to use
  59443. * @param verticesStart defines the index of first vertex to draw
  59444. * @param verticesCount defines the count of vertices to draw
  59445. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59446. */
  59447. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59448. /** @hidden */
  59449. protected _createTexture(): WebGLTexture;
  59450. /** @hidden */
  59451. _releaseTexture(texture: InternalTexture): void;
  59452. /**
  59453. * Usually called from Texture.ts.
  59454. * Passed information to create a WebGLTexture
  59455. * @param urlArg defines a value which contains one of the following:
  59456. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59457. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59458. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59460. * @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)
  59461. * @param scene needed for loading to the correct scene
  59462. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59463. * @param onLoad optional callback to be called upon successful completion
  59464. * @param onError optional callback to be called upon failure
  59465. * @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
  59466. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59467. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59468. * @param forcedExtension defines the extension to use to pick the right loader
  59469. * @param mimeType defines an optional mime type
  59470. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59471. */
  59472. 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;
  59473. /**
  59474. * Creates a new render target texture
  59475. * @param size defines the size of the texture
  59476. * @param options defines the options used to create the texture
  59477. * @returns a new render target texture stored in an InternalTexture
  59478. */
  59479. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59480. /**
  59481. * Update the sampling mode of a given texture
  59482. * @param samplingMode defines the required sampling mode
  59483. * @param texture defines the texture to update
  59484. */
  59485. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59486. /**
  59487. * Binds the frame buffer to the specified texture.
  59488. * @param texture The texture to render to or null for the default canvas
  59489. * @param faceIndex The face of the texture to render to in case of cube texture
  59490. * @param requiredWidth The width of the target to render to
  59491. * @param requiredHeight The height of the target to render to
  59492. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59493. * @param lodLevel defines le lod level to bind to the frame buffer
  59494. */
  59495. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59496. /**
  59497. * Unbind the current render target texture from the webGL context
  59498. * @param texture defines the render target texture to unbind
  59499. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59500. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59501. */
  59502. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59503. /**
  59504. * Creates a dynamic vertex buffer
  59505. * @param vertices the data for the dynamic vertex buffer
  59506. * @returns the new WebGL dynamic buffer
  59507. */
  59508. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59509. /**
  59510. * Update the content of a dynamic texture
  59511. * @param texture defines the texture to update
  59512. * @param canvas defines the canvas containing the source
  59513. * @param invertY defines if data must be stored with Y axis inverted
  59514. * @param premulAlpha defines if alpha is stored as premultiplied
  59515. * @param format defines the format of the data
  59516. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59517. */
  59518. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59519. /**
  59520. * Gets a boolean indicating if all created effects are ready
  59521. * @returns true if all effects are ready
  59522. */
  59523. areAllEffectsReady(): boolean;
  59524. /**
  59525. * @hidden
  59526. * Get the current error code of the webGL context
  59527. * @returns the error code
  59528. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59529. */
  59530. getError(): number;
  59531. /** @hidden */
  59532. _getUnpackAlignement(): number;
  59533. /** @hidden */
  59534. _unpackFlipY(value: boolean): void;
  59535. /**
  59536. * Update a dynamic index buffer
  59537. * @param indexBuffer defines the target index buffer
  59538. * @param indices defines the data to update
  59539. * @param offset defines the offset in the target index buffer where update should start
  59540. */
  59541. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59542. /**
  59543. * Updates a dynamic vertex buffer.
  59544. * @param vertexBuffer the vertex buffer to update
  59545. * @param vertices the data used to update the vertex buffer
  59546. * @param byteOffset the byte offset of the data (optional)
  59547. * @param byteLength the byte length of the data (optional)
  59548. */
  59549. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59550. /** @hidden */
  59551. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59552. /** @hidden */
  59553. _bindTexture(channel: number, texture: InternalTexture): void;
  59554. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59555. /**
  59556. * 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
  59557. */
  59558. releaseEffects(): void;
  59559. displayLoadingUI(): void;
  59560. hideLoadingUI(): void;
  59561. /** @hidden */
  59562. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59563. /** @hidden */
  59564. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59565. /** @hidden */
  59566. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59567. /** @hidden */
  59568. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59569. }
  59570. }
  59571. declare module BABYLON {
  59572. /** @hidden */
  59573. export class _OcclusionDataStorage {
  59574. /** @hidden */
  59575. occlusionInternalRetryCounter: number;
  59576. /** @hidden */
  59577. isOcclusionQueryInProgress: boolean;
  59578. /** @hidden */
  59579. isOccluded: boolean;
  59580. /** @hidden */
  59581. occlusionRetryCount: number;
  59582. /** @hidden */
  59583. occlusionType: number;
  59584. /** @hidden */
  59585. occlusionQueryAlgorithmType: number;
  59586. }
  59587. interface Engine {
  59588. /**
  59589. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59590. * @return the new query
  59591. */
  59592. createQuery(): WebGLQuery;
  59593. /**
  59594. * Delete and release a webGL query
  59595. * @param query defines the query to delete
  59596. * @return the current engine
  59597. */
  59598. deleteQuery(query: WebGLQuery): Engine;
  59599. /**
  59600. * Check if a given query has resolved and got its value
  59601. * @param query defines the query to check
  59602. * @returns true if the query got its value
  59603. */
  59604. isQueryResultAvailable(query: WebGLQuery): boolean;
  59605. /**
  59606. * Gets the value of a given query
  59607. * @param query defines the query to check
  59608. * @returns the value of the query
  59609. */
  59610. getQueryResult(query: WebGLQuery): number;
  59611. /**
  59612. * Initiates an occlusion query
  59613. * @param algorithmType defines the algorithm to use
  59614. * @param query defines the query to use
  59615. * @returns the current engine
  59616. * @see https://doc.babylonjs.com/features/occlusionquery
  59617. */
  59618. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59619. /**
  59620. * Ends an occlusion query
  59621. * @see https://doc.babylonjs.com/features/occlusionquery
  59622. * @param algorithmType defines the algorithm to use
  59623. * @returns the current engine
  59624. */
  59625. endOcclusionQuery(algorithmType: number): Engine;
  59626. /**
  59627. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59628. * Please note that only one query can be issued at a time
  59629. * @returns a time token used to track the time span
  59630. */
  59631. startTimeQuery(): Nullable<_TimeToken>;
  59632. /**
  59633. * Ends a time query
  59634. * @param token defines the token used to measure the time span
  59635. * @returns the time spent (in ns)
  59636. */
  59637. endTimeQuery(token: _TimeToken): int;
  59638. /** @hidden */
  59639. _currentNonTimestampToken: Nullable<_TimeToken>;
  59640. /** @hidden */
  59641. _createTimeQuery(): WebGLQuery;
  59642. /** @hidden */
  59643. _deleteTimeQuery(query: WebGLQuery): void;
  59644. /** @hidden */
  59645. _getGlAlgorithmType(algorithmType: number): number;
  59646. /** @hidden */
  59647. _getTimeQueryResult(query: WebGLQuery): any;
  59648. /** @hidden */
  59649. _getTimeQueryAvailability(query: WebGLQuery): any;
  59650. }
  59651. interface AbstractMesh {
  59652. /**
  59653. * Backing filed
  59654. * @hidden
  59655. */
  59656. __occlusionDataStorage: _OcclusionDataStorage;
  59657. /**
  59658. * Access property
  59659. * @hidden
  59660. */
  59661. _occlusionDataStorage: _OcclusionDataStorage;
  59662. /**
  59663. * 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.
  59664. * The default value is -1 which means don't break the query and wait till the result
  59665. * @see https://doc.babylonjs.com/features/occlusionquery
  59666. */
  59667. occlusionRetryCount: number;
  59668. /**
  59669. * 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:
  59670. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59671. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59672. * * 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.
  59673. * @see https://doc.babylonjs.com/features/occlusionquery
  59674. */
  59675. occlusionType: number;
  59676. /**
  59677. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59678. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59679. * * 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.
  59680. * @see https://doc.babylonjs.com/features/occlusionquery
  59681. */
  59682. occlusionQueryAlgorithmType: number;
  59683. /**
  59684. * 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
  59685. * @see https://doc.babylonjs.com/features/occlusionquery
  59686. */
  59687. isOccluded: boolean;
  59688. /**
  59689. * Flag to check the progress status of the query
  59690. * @see https://doc.babylonjs.com/features/occlusionquery
  59691. */
  59692. isOcclusionQueryInProgress: boolean;
  59693. }
  59694. }
  59695. declare module BABYLON {
  59696. /** @hidden */
  59697. export var _forceTransformFeedbackToBundle: boolean;
  59698. interface Engine {
  59699. /**
  59700. * Creates a webGL transform feedback object
  59701. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59702. * @returns the webGL transform feedback object
  59703. */
  59704. createTransformFeedback(): WebGLTransformFeedback;
  59705. /**
  59706. * Delete a webGL transform feedback object
  59707. * @param value defines the webGL transform feedback object to delete
  59708. */
  59709. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59710. /**
  59711. * Bind a webGL transform feedback object to the webgl context
  59712. * @param value defines the webGL transform feedback object to bind
  59713. */
  59714. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59715. /**
  59716. * Begins a transform feedback operation
  59717. * @param usePoints defines if points or triangles must be used
  59718. */
  59719. beginTransformFeedback(usePoints: boolean): void;
  59720. /**
  59721. * Ends a transform feedback operation
  59722. */
  59723. endTransformFeedback(): void;
  59724. /**
  59725. * Specify the varyings to use with transform feedback
  59726. * @param program defines the associated webGL program
  59727. * @param value defines the list of strings representing the varying names
  59728. */
  59729. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59730. /**
  59731. * Bind a webGL buffer for a transform feedback operation
  59732. * @param value defines the webGL buffer to bind
  59733. */
  59734. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59735. }
  59736. }
  59737. declare module BABYLON {
  59738. /**
  59739. * Class used to define an additional view for the engine
  59740. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59741. */
  59742. export class EngineView {
  59743. /** Defines the canvas where to render the view */
  59744. target: HTMLCanvasElement;
  59745. /** Defines an optional camera used to render the view (will use active camera else) */
  59746. camera?: Camera;
  59747. }
  59748. interface Engine {
  59749. /**
  59750. * Gets or sets the HTML element to use for attaching events
  59751. */
  59752. inputElement: Nullable<HTMLElement>;
  59753. /**
  59754. * Gets the current engine view
  59755. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59756. */
  59757. activeView: Nullable<EngineView>;
  59758. /** Gets or sets the list of views */
  59759. views: EngineView[];
  59760. /**
  59761. * Register a new child canvas
  59762. * @param canvas defines the canvas to register
  59763. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59764. * @returns the associated view
  59765. */
  59766. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59767. /**
  59768. * Remove a registered child canvas
  59769. * @param canvas defines the canvas to remove
  59770. * @returns the current engine
  59771. */
  59772. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59773. }
  59774. }
  59775. declare module BABYLON {
  59776. interface Engine {
  59777. /** @hidden */
  59778. _excludedCompressedTextures: string[];
  59779. /** @hidden */
  59780. _textureFormatInUse: string;
  59781. /**
  59782. * Gets the list of texture formats supported
  59783. */
  59784. readonly texturesSupported: Array<string>;
  59785. /**
  59786. * Gets the texture format in use
  59787. */
  59788. readonly textureFormatInUse: Nullable<string>;
  59789. /**
  59790. * Set the compressed texture extensions or file names to skip.
  59791. *
  59792. * @param skippedFiles defines the list of those texture files you want to skip
  59793. * Example: [".dds", ".env", "myfile.png"]
  59794. */
  59795. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59796. /**
  59797. * Set the compressed texture format to use, based on the formats you have, and the formats
  59798. * supported by the hardware / browser.
  59799. *
  59800. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59801. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59802. * to API arguments needed to compressed textures. This puts the burden on the container
  59803. * generator to house the arcane code for determining these for current & future formats.
  59804. *
  59805. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59806. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59807. *
  59808. * Note: The result of this call is not taken into account when a texture is base64.
  59809. *
  59810. * @param formatsAvailable defines the list of those format families you have created
  59811. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59812. *
  59813. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59814. * @returns The extension selected.
  59815. */
  59816. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59817. }
  59818. }
  59819. declare module BABYLON {
  59820. /** @hidden */
  59821. export var rgbdEncodePixelShader: {
  59822. name: string;
  59823. shader: string;
  59824. };
  59825. }
  59826. declare module BABYLON {
  59827. /**
  59828. * Raw texture data and descriptor sufficient for WebGL texture upload
  59829. */
  59830. export interface EnvironmentTextureInfo {
  59831. /**
  59832. * Version of the environment map
  59833. */
  59834. version: number;
  59835. /**
  59836. * Width of image
  59837. */
  59838. width: number;
  59839. /**
  59840. * Irradiance information stored in the file.
  59841. */
  59842. irradiance: any;
  59843. /**
  59844. * Specular information stored in the file.
  59845. */
  59846. specular: any;
  59847. }
  59848. /**
  59849. * Defines One Image in the file. It requires only the position in the file
  59850. * as well as the length.
  59851. */
  59852. interface BufferImageData {
  59853. /**
  59854. * Length of the image data.
  59855. */
  59856. length: number;
  59857. /**
  59858. * Position of the data from the null terminator delimiting the end of the JSON.
  59859. */
  59860. position: number;
  59861. }
  59862. /**
  59863. * Defines the specular data enclosed in the file.
  59864. * This corresponds to the version 1 of the data.
  59865. */
  59866. export interface EnvironmentTextureSpecularInfoV1 {
  59867. /**
  59868. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59869. */
  59870. specularDataPosition?: number;
  59871. /**
  59872. * This contains all the images data needed to reconstruct the cubemap.
  59873. */
  59874. mipmaps: Array<BufferImageData>;
  59875. /**
  59876. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59877. */
  59878. lodGenerationScale: number;
  59879. }
  59880. /**
  59881. * Sets of helpers addressing the serialization and deserialization of environment texture
  59882. * stored in a BabylonJS env file.
  59883. * Those files are usually stored as .env files.
  59884. */
  59885. export class EnvironmentTextureTools {
  59886. /**
  59887. * Magic number identifying the env file.
  59888. */
  59889. private static _MagicBytes;
  59890. /**
  59891. * Gets the environment info from an env file.
  59892. * @param data The array buffer containing the .env bytes.
  59893. * @returns the environment file info (the json header) if successfully parsed.
  59894. */
  59895. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59896. /**
  59897. * Creates an environment texture from a loaded cube texture.
  59898. * @param texture defines the cube texture to convert in env file
  59899. * @return a promise containing the environment data if succesfull.
  59900. */
  59901. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59902. /**
  59903. * Creates a JSON representation of the spherical data.
  59904. * @param texture defines the texture containing the polynomials
  59905. * @return the JSON representation of the spherical info
  59906. */
  59907. private static _CreateEnvTextureIrradiance;
  59908. /**
  59909. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59910. * @param data the image data
  59911. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59912. * @return the views described by info providing access to the underlying buffer
  59913. */
  59914. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59915. /**
  59916. * Uploads the texture info contained in the env file to the GPU.
  59917. * @param texture defines the internal texture to upload to
  59918. * @param data defines the data to load
  59919. * @param info defines the texture info retrieved through the GetEnvInfo method
  59920. * @returns a promise
  59921. */
  59922. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59923. private static _OnImageReadyAsync;
  59924. /**
  59925. * Uploads the levels of image data to the GPU.
  59926. * @param texture defines the internal texture to upload to
  59927. * @param imageData defines the array buffer views of image data [mipmap][face]
  59928. * @returns a promise
  59929. */
  59930. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59931. /**
  59932. * Uploads spherical polynomials information to the texture.
  59933. * @param texture defines the texture we are trying to upload the information to
  59934. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59935. */
  59936. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59937. /** @hidden */
  59938. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59939. }
  59940. }
  59941. declare module BABYLON {
  59942. /**
  59943. * Container for accessors for natively-stored mesh data buffers.
  59944. */
  59945. class NativeDataBuffer extends DataBuffer {
  59946. /**
  59947. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59948. */
  59949. nativeIndexBuffer?: any;
  59950. /**
  59951. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59952. */
  59953. nativeVertexBuffer?: any;
  59954. }
  59955. /** @hidden */
  59956. class NativeTexture extends InternalTexture {
  59957. getInternalTexture(): InternalTexture;
  59958. getViewCount(): number;
  59959. }
  59960. /** @hidden */
  59961. export class NativeEngine extends Engine {
  59962. private readonly _native;
  59963. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59964. private readonly INVALID_HANDLE;
  59965. private _boundBuffersVertexArray;
  59966. private _currentDepthTest;
  59967. getHardwareScalingLevel(): number;
  59968. constructor();
  59969. dispose(): void;
  59970. /**
  59971. * Can be used to override the current requestAnimationFrame requester.
  59972. * @hidden
  59973. */
  59974. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59975. /**
  59976. * Override default engine behavior.
  59977. * @param color
  59978. * @param backBuffer
  59979. * @param depth
  59980. * @param stencil
  59981. */
  59982. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59983. /**
  59984. * Gets host document
  59985. * @returns the host document object
  59986. */
  59987. getHostDocument(): Nullable<Document>;
  59988. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59989. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59990. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59991. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59992. [key: string]: VertexBuffer;
  59993. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59994. bindBuffers(vertexBuffers: {
  59995. [key: string]: VertexBuffer;
  59996. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59997. recordVertexArrayObject(vertexBuffers: {
  59998. [key: string]: VertexBuffer;
  59999. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60000. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60001. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60002. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60003. /**
  60004. * Draw a list of indexed primitives
  60005. * @param fillMode defines the primitive to use
  60006. * @param indexStart defines the starting index
  60007. * @param indexCount defines the number of index to draw
  60008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60009. */
  60010. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60011. /**
  60012. * Draw a list of unindexed primitives
  60013. * @param fillMode defines the primitive to use
  60014. * @param verticesStart defines the index of first vertex to draw
  60015. * @param verticesCount defines the count of vertices to draw
  60016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60017. */
  60018. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60019. createPipelineContext(): IPipelineContext;
  60020. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60021. /** @hidden */
  60022. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60023. /** @hidden */
  60024. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60025. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60026. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60027. protected _setProgram(program: WebGLProgram): void;
  60028. _releaseEffect(effect: Effect): void;
  60029. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60030. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60031. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60032. bindSamplers(effect: Effect): void;
  60033. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60034. getRenderWidth(useScreen?: boolean): number;
  60035. getRenderHeight(useScreen?: boolean): number;
  60036. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60037. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60038. /**
  60039. * Set the z offset to apply to current rendering
  60040. * @param value defines the offset to apply
  60041. */
  60042. setZOffset(value: number): void;
  60043. /**
  60044. * Gets the current value of the zOffset
  60045. * @returns the current zOffset state
  60046. */
  60047. getZOffset(): number;
  60048. /**
  60049. * Enable or disable depth buffering
  60050. * @param enable defines the state to set
  60051. */
  60052. setDepthBuffer(enable: boolean): void;
  60053. /**
  60054. * Gets a boolean indicating if depth writing is enabled
  60055. * @returns the current depth writing state
  60056. */
  60057. getDepthWrite(): boolean;
  60058. setDepthFunctionToGreater(): void;
  60059. setDepthFunctionToGreaterOrEqual(): void;
  60060. setDepthFunctionToLess(): void;
  60061. setDepthFunctionToLessOrEqual(): void;
  60062. /**
  60063. * Enable or disable depth writing
  60064. * @param enable defines the state to set
  60065. */
  60066. setDepthWrite(enable: boolean): void;
  60067. /**
  60068. * Enable or disable color writing
  60069. * @param enable defines the state to set
  60070. */
  60071. setColorWrite(enable: boolean): void;
  60072. /**
  60073. * Gets a boolean indicating if color writing is enabled
  60074. * @returns the current color writing state
  60075. */
  60076. getColorWrite(): boolean;
  60077. /**
  60078. * Sets alpha constants used by some alpha blending modes
  60079. * @param r defines the red component
  60080. * @param g defines the green component
  60081. * @param b defines the blue component
  60082. * @param a defines the alpha component
  60083. */
  60084. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60085. /**
  60086. * Sets the current alpha mode
  60087. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60088. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60089. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60090. */
  60091. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60092. /**
  60093. * Gets the current alpha mode
  60094. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60095. * @returns the current alpha mode
  60096. */
  60097. getAlphaMode(): number;
  60098. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60099. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60100. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60101. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60102. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60103. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60104. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60105. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60106. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60107. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60108. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60109. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60110. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60111. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60112. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60113. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60114. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60115. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60116. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60117. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60118. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60119. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60120. wipeCaches(bruteForce?: boolean): void;
  60121. protected _createTexture(): WebGLTexture;
  60122. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60123. /**
  60124. * Update the content of a dynamic texture
  60125. * @param texture defines the texture to update
  60126. * @param canvas defines the canvas containing the source
  60127. * @param invertY defines if data must be stored with Y axis inverted
  60128. * @param premulAlpha defines if alpha is stored as premultiplied
  60129. * @param format defines the format of the data
  60130. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60131. */
  60132. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60133. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60134. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60135. /**
  60136. * Usually called from Texture.ts.
  60137. * Passed information to create a WebGLTexture
  60138. * @param url defines a value which contains one of the following:
  60139. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60140. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60141. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60142. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60143. * @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)
  60144. * @param scene needed for loading to the correct scene
  60145. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60146. * @param onLoad optional callback to be called upon successful completion
  60147. * @param onError optional callback to be called upon failure
  60148. * @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
  60149. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60150. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60151. * @param forcedExtension defines the extension to use to pick the right loader
  60152. * @param mimeType defines an optional mime type
  60153. * @param loaderOptions options to be passed to the loader
  60154. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60155. */
  60156. 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;
  60157. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60158. _releaseFramebufferObjects(texture: InternalTexture): void;
  60159. /**
  60160. * Creates a cube texture
  60161. * @param rootUrl defines the url where the files to load is located
  60162. * @param scene defines the current scene
  60163. * @param files defines the list of files to load (1 per face)
  60164. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60165. * @param onLoad defines an optional callback raised when the texture is loaded
  60166. * @param onError defines an optional callback raised if there is an issue to load the texture
  60167. * @param format defines the format of the data
  60168. * @param forcedExtension defines the extension to use to pick the right loader
  60169. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60170. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60171. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60172. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60173. * @returns the cube texture as an InternalTexture
  60174. */
  60175. 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;
  60176. createRenderTargetTexture(size: number | {
  60177. width: number;
  60178. height: number;
  60179. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60180. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60181. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60182. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60183. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60184. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60185. /**
  60186. * Updates a dynamic vertex buffer.
  60187. * @param vertexBuffer the vertex buffer to update
  60188. * @param data the data used to update the vertex buffer
  60189. * @param byteOffset the byte offset of the data (optional)
  60190. * @param byteLength the byte length of the data (optional)
  60191. */
  60192. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60193. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60194. private _updateAnisotropicLevel;
  60195. private _getAddressMode;
  60196. /** @hidden */
  60197. _bindTexture(channel: number, texture: InternalTexture): void;
  60198. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60199. releaseEffects(): void;
  60200. /** @hidden */
  60201. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60202. /** @hidden */
  60203. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60204. /** @hidden */
  60205. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60206. /** @hidden */
  60207. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60208. private _getNativeSamplingMode;
  60209. private _getNativeTextureFormat;
  60210. private _getNativeAlphaMode;
  60211. private _getNativeAttribType;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * Helper class to create the best engine depending on the current hardware
  60217. */
  60218. export class EngineFactory {
  60219. /**
  60220. * Creates an engine based on the capabilities of the underlying hardware
  60221. * @param canvas Defines the canvas to use to display the result
  60222. * @param options Defines the options passed to the engine to create the context dependencies
  60223. * @returns a promise that resolves with the created engine
  60224. */
  60225. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60226. }
  60227. }
  60228. declare module BABYLON {
  60229. /**
  60230. * Gather the list of clipboard event types as constants.
  60231. */
  60232. export class ClipboardEventTypes {
  60233. /**
  60234. * The clipboard event is fired when a copy command is active (pressed).
  60235. */
  60236. static readonly COPY: number;
  60237. /**
  60238. * The clipboard event is fired when a cut command is active (pressed).
  60239. */
  60240. static readonly CUT: number;
  60241. /**
  60242. * The clipboard event is fired when a paste command is active (pressed).
  60243. */
  60244. static readonly PASTE: number;
  60245. }
  60246. /**
  60247. * This class is used to store clipboard related info for the onClipboardObservable event.
  60248. */
  60249. export class ClipboardInfo {
  60250. /**
  60251. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60252. */
  60253. type: number;
  60254. /**
  60255. * Defines the related dom event
  60256. */
  60257. event: ClipboardEvent;
  60258. /**
  60259. *Creates an instance of ClipboardInfo.
  60260. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60261. * @param event Defines the related dom event
  60262. */
  60263. constructor(
  60264. /**
  60265. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60266. */
  60267. type: number,
  60268. /**
  60269. * Defines the related dom event
  60270. */
  60271. event: ClipboardEvent);
  60272. /**
  60273. * Get the clipboard event's type from the keycode.
  60274. * @param keyCode Defines the keyCode for the current keyboard event.
  60275. * @return {number}
  60276. */
  60277. static GetTypeFromCharacter(keyCode: number): number;
  60278. }
  60279. }
  60280. declare module BABYLON {
  60281. /**
  60282. * Google Daydream controller
  60283. */
  60284. export class DaydreamController extends WebVRController {
  60285. /**
  60286. * Base Url for the controller model.
  60287. */
  60288. static MODEL_BASE_URL: string;
  60289. /**
  60290. * File name for the controller model.
  60291. */
  60292. static MODEL_FILENAME: string;
  60293. /**
  60294. * Gamepad Id prefix used to identify Daydream Controller.
  60295. */
  60296. static readonly GAMEPAD_ID_PREFIX: string;
  60297. /**
  60298. * Creates a new DaydreamController from a gamepad
  60299. * @param vrGamepad the gamepad that the controller should be created from
  60300. */
  60301. constructor(vrGamepad: any);
  60302. /**
  60303. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60304. * @param scene scene in which to add meshes
  60305. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60306. */
  60307. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60308. /**
  60309. * Called once for each button that changed state since the last frame
  60310. * @param buttonIdx Which button index changed
  60311. * @param state New state of the button
  60312. * @param changes Which properties on the state changed since last frame
  60313. */
  60314. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60315. }
  60316. }
  60317. declare module BABYLON {
  60318. /**
  60319. * Gear VR Controller
  60320. */
  60321. export class GearVRController extends WebVRController {
  60322. /**
  60323. * Base Url for the controller model.
  60324. */
  60325. static MODEL_BASE_URL: string;
  60326. /**
  60327. * File name for the controller model.
  60328. */
  60329. static MODEL_FILENAME: string;
  60330. /**
  60331. * Gamepad Id prefix used to identify this controller.
  60332. */
  60333. static readonly GAMEPAD_ID_PREFIX: string;
  60334. private readonly _buttonIndexToObservableNameMap;
  60335. /**
  60336. * Creates a new GearVRController from a gamepad
  60337. * @param vrGamepad the gamepad that the controller should be created from
  60338. */
  60339. constructor(vrGamepad: any);
  60340. /**
  60341. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60342. * @param scene scene in which to add meshes
  60343. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60344. */
  60345. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60346. /**
  60347. * Called once for each button that changed state since the last frame
  60348. * @param buttonIdx Which button index changed
  60349. * @param state New state of the button
  60350. * @param changes Which properties on the state changed since last frame
  60351. */
  60352. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60353. }
  60354. }
  60355. declare module BABYLON {
  60356. /**
  60357. * Generic Controller
  60358. */
  60359. export class GenericController extends WebVRController {
  60360. /**
  60361. * Base Url for the controller model.
  60362. */
  60363. static readonly MODEL_BASE_URL: string;
  60364. /**
  60365. * File name for the controller model.
  60366. */
  60367. static readonly MODEL_FILENAME: string;
  60368. /**
  60369. * Creates a new GenericController from a gamepad
  60370. * @param vrGamepad the gamepad that the controller should be created from
  60371. */
  60372. constructor(vrGamepad: any);
  60373. /**
  60374. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60375. * @param scene scene in which to add meshes
  60376. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60377. */
  60378. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60379. /**
  60380. * Called once for each button that changed state since the last frame
  60381. * @param buttonIdx Which button index changed
  60382. * @param state New state of the button
  60383. * @param changes Which properties on the state changed since last frame
  60384. */
  60385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60386. }
  60387. }
  60388. declare module BABYLON {
  60389. /**
  60390. * Oculus Touch Controller
  60391. */
  60392. export class OculusTouchController extends WebVRController {
  60393. /**
  60394. * Base Url for the controller model.
  60395. */
  60396. static MODEL_BASE_URL: string;
  60397. /**
  60398. * File name for the left controller model.
  60399. */
  60400. static MODEL_LEFT_FILENAME: string;
  60401. /**
  60402. * File name for the right controller model.
  60403. */
  60404. static MODEL_RIGHT_FILENAME: string;
  60405. /**
  60406. * Base Url for the Quest controller model.
  60407. */
  60408. static QUEST_MODEL_BASE_URL: string;
  60409. /**
  60410. * @hidden
  60411. * If the controllers are running on a device that needs the updated Quest controller models
  60412. */
  60413. static _IsQuest: boolean;
  60414. /**
  60415. * Fired when the secondary trigger on this controller is modified
  60416. */
  60417. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60418. /**
  60419. * Fired when the thumb rest on this controller is modified
  60420. */
  60421. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60422. /**
  60423. * Creates a new OculusTouchController from a gamepad
  60424. * @param vrGamepad the gamepad that the controller should be created from
  60425. */
  60426. constructor(vrGamepad: any);
  60427. /**
  60428. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60429. * @param scene scene in which to add meshes
  60430. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60431. */
  60432. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60433. /**
  60434. * Fired when the A button on this controller is modified
  60435. */
  60436. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60437. /**
  60438. * Fired when the B button on this controller is modified
  60439. */
  60440. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60441. /**
  60442. * Fired when the X button on this controller is modified
  60443. */
  60444. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60445. /**
  60446. * Fired when the Y button on this controller is modified
  60447. */
  60448. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60449. /**
  60450. * Called once for each button that changed state since the last frame
  60451. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60452. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60453. * 2) secondary trigger (same)
  60454. * 3) A (right) X (left), touch, pressed = value
  60455. * 4) B / Y
  60456. * 5) thumb rest
  60457. * @param buttonIdx Which button index changed
  60458. * @param state New state of the button
  60459. * @param changes Which properties on the state changed since last frame
  60460. */
  60461. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60462. }
  60463. }
  60464. declare module BABYLON {
  60465. /**
  60466. * Vive Controller
  60467. */
  60468. export class ViveController extends WebVRController {
  60469. /**
  60470. * Base Url for the controller model.
  60471. */
  60472. static MODEL_BASE_URL: string;
  60473. /**
  60474. * File name for the controller model.
  60475. */
  60476. static MODEL_FILENAME: string;
  60477. /**
  60478. * Creates a new ViveController from a gamepad
  60479. * @param vrGamepad the gamepad that the controller should be created from
  60480. */
  60481. constructor(vrGamepad: any);
  60482. /**
  60483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60484. * @param scene scene in which to add meshes
  60485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60486. */
  60487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60488. /**
  60489. * Fired when the left button on this controller is modified
  60490. */
  60491. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60492. /**
  60493. * Fired when the right button on this controller is modified
  60494. */
  60495. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60496. /**
  60497. * Fired when the menu button on this controller is modified
  60498. */
  60499. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60500. /**
  60501. * Called once for each button that changed state since the last frame
  60502. * Vive mapping:
  60503. * 0: touchpad
  60504. * 1: trigger
  60505. * 2: left AND right buttons
  60506. * 3: menu button
  60507. * @param buttonIdx Which button index changed
  60508. * @param state New state of the button
  60509. * @param changes Which properties on the state changed since last frame
  60510. */
  60511. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60512. }
  60513. }
  60514. declare module BABYLON {
  60515. /**
  60516. * Defines the WindowsMotionController object that the state of the windows motion controller
  60517. */
  60518. export class WindowsMotionController extends WebVRController {
  60519. /**
  60520. * The base url used to load the left and right controller models
  60521. */
  60522. static MODEL_BASE_URL: string;
  60523. /**
  60524. * The name of the left controller model file
  60525. */
  60526. static MODEL_LEFT_FILENAME: string;
  60527. /**
  60528. * The name of the right controller model file
  60529. */
  60530. static MODEL_RIGHT_FILENAME: string;
  60531. /**
  60532. * The controller name prefix for this controller type
  60533. */
  60534. static readonly GAMEPAD_ID_PREFIX: string;
  60535. /**
  60536. * The controller id pattern for this controller type
  60537. */
  60538. private static readonly GAMEPAD_ID_PATTERN;
  60539. private _loadedMeshInfo;
  60540. protected readonly _mapping: {
  60541. buttons: string[];
  60542. buttonMeshNames: {
  60543. trigger: string;
  60544. menu: string;
  60545. grip: string;
  60546. thumbstick: string;
  60547. trackpad: string;
  60548. };
  60549. buttonObservableNames: {
  60550. trigger: string;
  60551. menu: string;
  60552. grip: string;
  60553. thumbstick: string;
  60554. trackpad: string;
  60555. };
  60556. axisMeshNames: string[];
  60557. pointingPoseMeshName: string;
  60558. };
  60559. /**
  60560. * Fired when the trackpad on this controller is clicked
  60561. */
  60562. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60563. /**
  60564. * Fired when the trackpad on this controller is modified
  60565. */
  60566. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60567. /**
  60568. * The current x and y values of this controller's trackpad
  60569. */
  60570. trackpad: StickValues;
  60571. /**
  60572. * Creates a new WindowsMotionController from a gamepad
  60573. * @param vrGamepad the gamepad that the controller should be created from
  60574. */
  60575. constructor(vrGamepad: any);
  60576. /**
  60577. * Fired when the trigger on this controller is modified
  60578. */
  60579. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60580. /**
  60581. * Fired when the menu button on this controller is modified
  60582. */
  60583. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60584. /**
  60585. * Fired when the grip button on this controller is modified
  60586. */
  60587. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60588. /**
  60589. * Fired when the thumbstick button on this controller is modified
  60590. */
  60591. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60592. /**
  60593. * Fired when the touchpad button on this controller is modified
  60594. */
  60595. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60596. /**
  60597. * Fired when the touchpad values on this controller are modified
  60598. */
  60599. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60600. protected _updateTrackpad(): void;
  60601. /**
  60602. * Called once per frame by the engine.
  60603. */
  60604. update(): void;
  60605. /**
  60606. * Called once for each button that changed state since the last frame
  60607. * @param buttonIdx Which button index changed
  60608. * @param state New state of the button
  60609. * @param changes Which properties on the state changed since last frame
  60610. */
  60611. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60612. /**
  60613. * Moves the buttons on the controller mesh based on their current state
  60614. * @param buttonName the name of the button to move
  60615. * @param buttonValue the value of the button which determines the buttons new position
  60616. */
  60617. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60618. /**
  60619. * Moves the axis on the controller mesh based on its current state
  60620. * @param axis the index of the axis
  60621. * @param axisValue the value of the axis which determines the meshes new position
  60622. * @hidden
  60623. */
  60624. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60625. /**
  60626. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60627. * @param scene scene in which to add meshes
  60628. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60629. */
  60630. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60631. /**
  60632. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60633. * can be transformed by button presses and axes values, based on this._mapping.
  60634. *
  60635. * @param scene scene in which the meshes exist
  60636. * @param meshes list of meshes that make up the controller model to process
  60637. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60638. */
  60639. private processModel;
  60640. private createMeshInfo;
  60641. /**
  60642. * Gets the ray of the controller in the direction the controller is pointing
  60643. * @param length the length the resulting ray should be
  60644. * @returns a ray in the direction the controller is pointing
  60645. */
  60646. getForwardRay(length?: number): Ray;
  60647. /**
  60648. * Disposes of the controller
  60649. */
  60650. dispose(): void;
  60651. }
  60652. /**
  60653. * This class represents a new windows motion controller in XR.
  60654. */
  60655. export class XRWindowsMotionController extends WindowsMotionController {
  60656. /**
  60657. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60658. */
  60659. protected readonly _mapping: {
  60660. buttons: string[];
  60661. buttonMeshNames: {
  60662. trigger: string;
  60663. menu: string;
  60664. grip: string;
  60665. thumbstick: string;
  60666. trackpad: string;
  60667. };
  60668. buttonObservableNames: {
  60669. trigger: string;
  60670. menu: string;
  60671. grip: string;
  60672. thumbstick: string;
  60673. trackpad: string;
  60674. };
  60675. axisMeshNames: string[];
  60676. pointingPoseMeshName: string;
  60677. };
  60678. /**
  60679. * Construct a new XR-Based windows motion controller
  60680. *
  60681. * @param gamepadInfo the gamepad object from the browser
  60682. */
  60683. constructor(gamepadInfo: any);
  60684. /**
  60685. * holds the thumbstick values (X,Y)
  60686. */
  60687. thumbstickValues: StickValues;
  60688. /**
  60689. * Fired when the thumbstick on this controller is clicked
  60690. */
  60691. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60692. /**
  60693. * Fired when the thumbstick on this controller is modified
  60694. */
  60695. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60696. /**
  60697. * Fired when the touchpad button on this controller is modified
  60698. */
  60699. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60700. /**
  60701. * Fired when the touchpad values on this controller are modified
  60702. */
  60703. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60704. /**
  60705. * Fired when the thumbstick button on this controller is modified
  60706. * here to prevent breaking changes
  60707. */
  60708. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60709. /**
  60710. * updating the thumbstick(!) and not the trackpad.
  60711. * This is named this way due to the difference between WebVR and XR and to avoid
  60712. * changing the parent class.
  60713. */
  60714. protected _updateTrackpad(): void;
  60715. /**
  60716. * Disposes the class with joy
  60717. */
  60718. dispose(): void;
  60719. }
  60720. }
  60721. declare module BABYLON {
  60722. /**
  60723. * A directional light is defined by a direction (what a surprise!).
  60724. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60725. * 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.
  60726. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60727. */
  60728. export class DirectionalLight extends ShadowLight {
  60729. private _shadowFrustumSize;
  60730. /**
  60731. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60732. */
  60733. get shadowFrustumSize(): number;
  60734. /**
  60735. * Specifies a fix frustum size for the shadow generation.
  60736. */
  60737. set shadowFrustumSize(value: number);
  60738. private _shadowOrthoScale;
  60739. /**
  60740. * Gets the shadow projection scale against the optimal computed one.
  60741. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60742. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60743. */
  60744. get shadowOrthoScale(): number;
  60745. /**
  60746. * Sets the shadow projection scale against the optimal computed one.
  60747. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60748. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60749. */
  60750. set shadowOrthoScale(value: number);
  60751. /**
  60752. * Automatically compute the projection matrix to best fit (including all the casters)
  60753. * on each frame.
  60754. */
  60755. autoUpdateExtends: boolean;
  60756. /**
  60757. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60758. * on each frame. autoUpdateExtends must be set to true for this to work
  60759. */
  60760. autoCalcShadowZBounds: boolean;
  60761. private _orthoLeft;
  60762. private _orthoRight;
  60763. private _orthoTop;
  60764. private _orthoBottom;
  60765. /**
  60766. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60767. * The directional light is emitted from everywhere in the given direction.
  60768. * It can cast shadows.
  60769. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60770. * @param name The friendly name of the light
  60771. * @param direction The direction of the light
  60772. * @param scene The scene the light belongs to
  60773. */
  60774. constructor(name: string, direction: Vector3, scene: Scene);
  60775. /**
  60776. * Returns the string "DirectionalLight".
  60777. * @return The class name
  60778. */
  60779. getClassName(): string;
  60780. /**
  60781. * Returns the integer 1.
  60782. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60783. */
  60784. getTypeID(): number;
  60785. /**
  60786. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60787. * Returns the DirectionalLight Shadow projection matrix.
  60788. */
  60789. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60790. /**
  60791. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60792. * Returns the DirectionalLight Shadow projection matrix.
  60793. */
  60794. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60795. /**
  60796. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60797. * Returns the DirectionalLight Shadow projection matrix.
  60798. */
  60799. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60800. protected _buildUniformLayout(): void;
  60801. /**
  60802. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60803. * @param effect The effect to update
  60804. * @param lightIndex The index of the light in the effect to update
  60805. * @returns The directional light
  60806. */
  60807. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60809. /**
  60810. * Gets the minZ used for shadow according to both the scene and the light.
  60811. *
  60812. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60813. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60814. * @param activeCamera The camera we are returning the min for
  60815. * @returns the depth min z
  60816. */
  60817. getDepthMinZ(activeCamera: Camera): number;
  60818. /**
  60819. * Gets the maxZ used for shadow according to both the scene and the light.
  60820. *
  60821. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60822. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60823. * @param activeCamera The camera we are returning the max for
  60824. * @returns the depth max z
  60825. */
  60826. getDepthMaxZ(activeCamera: Camera): number;
  60827. /**
  60828. * Prepares the list of defines specific to the light type.
  60829. * @param defines the list of defines
  60830. * @param lightIndex defines the index of the light for the effect
  60831. */
  60832. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60833. }
  60834. }
  60835. declare module BABYLON {
  60836. /**
  60837. * Class containing static functions to help procedurally build meshes
  60838. */
  60839. export class HemisphereBuilder {
  60840. /**
  60841. * Creates a hemisphere mesh
  60842. * @param name defines the name of the mesh
  60843. * @param options defines the options used to create the mesh
  60844. * @param scene defines the hosting scene
  60845. * @returns the hemisphere mesh
  60846. */
  60847. static CreateHemisphere(name: string, options: {
  60848. segments?: number;
  60849. diameter?: number;
  60850. sideOrientation?: number;
  60851. }, scene: any): Mesh;
  60852. }
  60853. }
  60854. declare module BABYLON {
  60855. /**
  60856. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60857. * These values define a cone of light starting from the position, emitting toward the direction.
  60858. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60859. * and the exponent defines the speed of the decay of the light with distance (reach).
  60860. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60861. */
  60862. export class SpotLight extends ShadowLight {
  60863. private _angle;
  60864. private _innerAngle;
  60865. private _cosHalfAngle;
  60866. private _lightAngleScale;
  60867. private _lightAngleOffset;
  60868. /**
  60869. * Gets the cone angle of the spot light in Radians.
  60870. */
  60871. get angle(): number;
  60872. /**
  60873. * Sets the cone angle of the spot light in Radians.
  60874. */
  60875. set angle(value: number);
  60876. /**
  60877. * Only used in gltf falloff mode, this defines the angle where
  60878. * the directional falloff will start before cutting at angle which could be seen
  60879. * as outer angle.
  60880. */
  60881. get innerAngle(): number;
  60882. /**
  60883. * Only used in gltf falloff mode, this defines the angle where
  60884. * the directional falloff will start before cutting at angle which could be seen
  60885. * as outer angle.
  60886. */
  60887. set innerAngle(value: number);
  60888. private _shadowAngleScale;
  60889. /**
  60890. * Allows scaling the angle of the light for shadow generation only.
  60891. */
  60892. get shadowAngleScale(): number;
  60893. /**
  60894. * Allows scaling the angle of the light for shadow generation only.
  60895. */
  60896. set shadowAngleScale(value: number);
  60897. /**
  60898. * The light decay speed with the distance from the emission spot.
  60899. */
  60900. exponent: number;
  60901. private _projectionTextureMatrix;
  60902. /**
  60903. * Allows reading the projecton texture
  60904. */
  60905. get projectionTextureMatrix(): Matrix;
  60906. protected _projectionTextureLightNear: number;
  60907. /**
  60908. * Gets the near clip of the Spotlight for texture projection.
  60909. */
  60910. get projectionTextureLightNear(): number;
  60911. /**
  60912. * Sets the near clip of the Spotlight for texture projection.
  60913. */
  60914. set projectionTextureLightNear(value: number);
  60915. protected _projectionTextureLightFar: number;
  60916. /**
  60917. * Gets the far clip of the Spotlight for texture projection.
  60918. */
  60919. get projectionTextureLightFar(): number;
  60920. /**
  60921. * Sets the far clip of the Spotlight for texture projection.
  60922. */
  60923. set projectionTextureLightFar(value: number);
  60924. protected _projectionTextureUpDirection: Vector3;
  60925. /**
  60926. * Gets the Up vector of the Spotlight for texture projection.
  60927. */
  60928. get projectionTextureUpDirection(): Vector3;
  60929. /**
  60930. * Sets the Up vector of the Spotlight for texture projection.
  60931. */
  60932. set projectionTextureUpDirection(value: Vector3);
  60933. private _projectionTexture;
  60934. /**
  60935. * Gets the projection texture of the light.
  60936. */
  60937. get projectionTexture(): Nullable<BaseTexture>;
  60938. /**
  60939. * Sets the projection texture of the light.
  60940. */
  60941. set projectionTexture(value: Nullable<BaseTexture>);
  60942. private static _IsProceduralTexture;
  60943. private static _IsTexture;
  60944. private _projectionTextureViewLightDirty;
  60945. private _projectionTextureProjectionLightDirty;
  60946. private _projectionTextureDirty;
  60947. private _projectionTextureViewTargetVector;
  60948. private _projectionTextureViewLightMatrix;
  60949. private _projectionTextureProjectionLightMatrix;
  60950. private _projectionTextureScalingMatrix;
  60951. /**
  60952. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60953. * It can cast shadows.
  60954. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60955. * @param name The light friendly name
  60956. * @param position The position of the spot light in the scene
  60957. * @param direction The direction of the light in the scene
  60958. * @param angle The cone angle of the light in Radians
  60959. * @param exponent The light decay speed with the distance from the emission spot
  60960. * @param scene The scene the lights belongs to
  60961. */
  60962. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60963. /**
  60964. * Returns the string "SpotLight".
  60965. * @returns the class name
  60966. */
  60967. getClassName(): string;
  60968. /**
  60969. * Returns the integer 2.
  60970. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60971. */
  60972. getTypeID(): number;
  60973. /**
  60974. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60975. */
  60976. protected _setDirection(value: Vector3): void;
  60977. /**
  60978. * Overrides the position setter to recompute the projection texture view light Matrix.
  60979. */
  60980. protected _setPosition(value: Vector3): void;
  60981. /**
  60982. * 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.
  60983. * Returns the SpotLight.
  60984. */
  60985. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60986. protected _computeProjectionTextureViewLightMatrix(): void;
  60987. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60988. /**
  60989. * Main function for light texture projection matrix computing.
  60990. */
  60991. protected _computeProjectionTextureMatrix(): void;
  60992. protected _buildUniformLayout(): void;
  60993. private _computeAngleValues;
  60994. /**
  60995. * Sets the passed Effect "effect" with the Light textures.
  60996. * @param effect The effect to update
  60997. * @param lightIndex The index of the light in the effect to update
  60998. * @returns The light
  60999. */
  61000. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61001. /**
  61002. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  61003. * @param effect The effect to update
  61004. * @param lightIndex The index of the light in the effect to update
  61005. * @returns The spot light
  61006. */
  61007. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61008. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61009. /**
  61010. * Disposes the light and the associated resources.
  61011. */
  61012. dispose(): void;
  61013. /**
  61014. * Prepares the list of defines specific to the light type.
  61015. * @param defines the list of defines
  61016. * @param lightIndex defines the index of the light for the effect
  61017. */
  61018. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61019. }
  61020. }
  61021. declare module BABYLON {
  61022. /**
  61023. * Gizmo that enables viewing a light
  61024. */
  61025. export class LightGizmo extends Gizmo {
  61026. private _lightMesh;
  61027. private _material;
  61028. private _cachedPosition;
  61029. private _cachedForward;
  61030. private _attachedMeshParent;
  61031. private _pointerObserver;
  61032. /**
  61033. * Event that fires each time the gizmo is clicked
  61034. */
  61035. onClickedObservable: Observable<Light>;
  61036. /**
  61037. * Creates a LightGizmo
  61038. * @param gizmoLayer The utility layer the gizmo will be added to
  61039. */
  61040. constructor(gizmoLayer?: UtilityLayerRenderer);
  61041. private _light;
  61042. /**
  61043. * The light that the gizmo is attached to
  61044. */
  61045. set light(light: Nullable<Light>);
  61046. get light(): Nullable<Light>;
  61047. /**
  61048. * Gets the material used to render the light gizmo
  61049. */
  61050. get material(): StandardMaterial;
  61051. /**
  61052. * @hidden
  61053. * Updates the gizmo to match the attached mesh's position/rotation
  61054. */
  61055. protected _update(): void;
  61056. private static _Scale;
  61057. /**
  61058. * Creates the lines for a light mesh
  61059. */
  61060. private static _CreateLightLines;
  61061. /**
  61062. * Disposes of the light gizmo
  61063. */
  61064. dispose(): void;
  61065. private static _CreateHemisphericLightMesh;
  61066. private static _CreatePointLightMesh;
  61067. private static _CreateSpotLightMesh;
  61068. private static _CreateDirectionalLightMesh;
  61069. }
  61070. }
  61071. declare module BABYLON {
  61072. /**
  61073. * Gizmo that enables viewing a camera
  61074. */
  61075. export class CameraGizmo extends Gizmo {
  61076. private _cameraMesh;
  61077. private _cameraLinesMesh;
  61078. private _material;
  61079. private _pointerObserver;
  61080. /**
  61081. * Event that fires each time the gizmo is clicked
  61082. */
  61083. onClickedObservable: Observable<Camera>;
  61084. /**
  61085. * Creates a CameraGizmo
  61086. * @param gizmoLayer The utility layer the gizmo will be added to
  61087. */
  61088. constructor(gizmoLayer?: UtilityLayerRenderer);
  61089. private _camera;
  61090. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61091. get displayFrustum(): boolean;
  61092. set displayFrustum(value: boolean);
  61093. /**
  61094. * The camera that the gizmo is attached to
  61095. */
  61096. set camera(camera: Nullable<Camera>);
  61097. get camera(): Nullable<Camera>;
  61098. /**
  61099. * Gets the material used to render the camera gizmo
  61100. */
  61101. get material(): StandardMaterial;
  61102. /**
  61103. * @hidden
  61104. * Updates the gizmo to match the attached mesh's position/rotation
  61105. */
  61106. protected _update(): void;
  61107. private static _Scale;
  61108. private _invProjection;
  61109. /**
  61110. * Disposes of the camera gizmo
  61111. */
  61112. dispose(): void;
  61113. private static _CreateCameraMesh;
  61114. private static _CreateCameraFrustum;
  61115. }
  61116. }
  61117. declare module BABYLON {
  61118. /** @hidden */
  61119. export var backgroundFragmentDeclaration: {
  61120. name: string;
  61121. shader: string;
  61122. };
  61123. }
  61124. declare module BABYLON {
  61125. /** @hidden */
  61126. export var backgroundUboDeclaration: {
  61127. name: string;
  61128. shader: string;
  61129. };
  61130. }
  61131. declare module BABYLON {
  61132. /** @hidden */
  61133. export var backgroundPixelShader: {
  61134. name: string;
  61135. shader: string;
  61136. };
  61137. }
  61138. declare module BABYLON {
  61139. /** @hidden */
  61140. export var backgroundVertexDeclaration: {
  61141. name: string;
  61142. shader: string;
  61143. };
  61144. }
  61145. declare module BABYLON {
  61146. /** @hidden */
  61147. export var backgroundVertexShader: {
  61148. name: string;
  61149. shader: string;
  61150. };
  61151. }
  61152. declare module BABYLON {
  61153. /**
  61154. * Background material used to create an efficient environement around your scene.
  61155. */
  61156. export class BackgroundMaterial extends PushMaterial {
  61157. /**
  61158. * Standard reflectance value at parallel view angle.
  61159. */
  61160. static StandardReflectance0: number;
  61161. /**
  61162. * Standard reflectance value at grazing angle.
  61163. */
  61164. static StandardReflectance90: number;
  61165. protected _primaryColor: Color3;
  61166. /**
  61167. * Key light Color (multiply against the environement texture)
  61168. */
  61169. primaryColor: Color3;
  61170. protected __perceptualColor: Nullable<Color3>;
  61171. /**
  61172. * Experimental Internal Use Only.
  61173. *
  61174. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61175. * This acts as a helper to set the primary color to a more "human friendly" value.
  61176. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61177. * output color as close as possible from the chosen value.
  61178. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61179. * part of lighting setup.)
  61180. */
  61181. get _perceptualColor(): Nullable<Color3>;
  61182. set _perceptualColor(value: Nullable<Color3>);
  61183. protected _primaryColorShadowLevel: float;
  61184. /**
  61185. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61186. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61187. */
  61188. get primaryColorShadowLevel(): float;
  61189. set primaryColorShadowLevel(value: float);
  61190. protected _primaryColorHighlightLevel: float;
  61191. /**
  61192. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  61193. * The primary color is used at the level chosen to define what the white area would look.
  61194. */
  61195. get primaryColorHighlightLevel(): float;
  61196. set primaryColorHighlightLevel(value: float);
  61197. protected _reflectionTexture: Nullable<BaseTexture>;
  61198. /**
  61199. * Reflection Texture used in the material.
  61200. * Should be author in a specific way for the best result (refer to the documentation).
  61201. */
  61202. reflectionTexture: Nullable<BaseTexture>;
  61203. protected _reflectionBlur: float;
  61204. /**
  61205. * Reflection Texture level of blur.
  61206. *
  61207. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61208. * texture twice.
  61209. */
  61210. reflectionBlur: float;
  61211. protected _diffuseTexture: Nullable<BaseTexture>;
  61212. /**
  61213. * Diffuse Texture used in the material.
  61214. * Should be author in a specific way for the best result (refer to the documentation).
  61215. */
  61216. diffuseTexture: Nullable<BaseTexture>;
  61217. protected _shadowLights: Nullable<IShadowLight[]>;
  61218. /**
  61219. * Specify the list of lights casting shadow on the material.
  61220. * All scene shadow lights will be included if null.
  61221. */
  61222. shadowLights: Nullable<IShadowLight[]>;
  61223. protected _shadowLevel: float;
  61224. /**
  61225. * Helps adjusting the shadow to a softer level if required.
  61226. * 0 means black shadows and 1 means no shadows.
  61227. */
  61228. shadowLevel: float;
  61229. protected _sceneCenter: Vector3;
  61230. /**
  61231. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61232. * It is usually zero but might be interesting to modify according to your setup.
  61233. */
  61234. sceneCenter: Vector3;
  61235. protected _opacityFresnel: boolean;
  61236. /**
  61237. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61238. * This helps ensuring a nice transition when the camera goes under the ground.
  61239. */
  61240. opacityFresnel: boolean;
  61241. protected _reflectionFresnel: boolean;
  61242. /**
  61243. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61244. * This helps adding a mirror texture on the ground.
  61245. */
  61246. reflectionFresnel: boolean;
  61247. protected _reflectionFalloffDistance: number;
  61248. /**
  61249. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61250. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61251. */
  61252. reflectionFalloffDistance: number;
  61253. protected _reflectionAmount: number;
  61254. /**
  61255. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61256. */
  61257. reflectionAmount: number;
  61258. protected _reflectionReflectance0: number;
  61259. /**
  61260. * This specifies the weight of the reflection at grazing angle.
  61261. */
  61262. reflectionReflectance0: number;
  61263. protected _reflectionReflectance90: number;
  61264. /**
  61265. * This specifies the weight of the reflection at a perpendicular point of view.
  61266. */
  61267. reflectionReflectance90: number;
  61268. /**
  61269. * Sets the reflection reflectance fresnel values according to the default standard
  61270. * empirically know to work well :-)
  61271. */
  61272. set reflectionStandardFresnelWeight(value: number);
  61273. protected _useRGBColor: boolean;
  61274. /**
  61275. * Helps to directly use the maps channels instead of their level.
  61276. */
  61277. useRGBColor: boolean;
  61278. protected _enableNoise: boolean;
  61279. /**
  61280. * This helps reducing the banding effect that could occur on the background.
  61281. */
  61282. enableNoise: boolean;
  61283. /**
  61284. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61285. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61286. * Recommended to be keep at 1.0 except for special cases.
  61287. */
  61288. get fovMultiplier(): number;
  61289. set fovMultiplier(value: number);
  61290. private _fovMultiplier;
  61291. /**
  61292. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61293. */
  61294. useEquirectangularFOV: boolean;
  61295. private _maxSimultaneousLights;
  61296. /**
  61297. * Number of Simultaneous lights allowed on the material.
  61298. */
  61299. maxSimultaneousLights: int;
  61300. private _shadowOnly;
  61301. /**
  61302. * Make the material only render shadows
  61303. */
  61304. shadowOnly: boolean;
  61305. /**
  61306. * Default configuration related to image processing available in the Background Material.
  61307. */
  61308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61309. /**
  61310. * Keep track of the image processing observer to allow dispose and replace.
  61311. */
  61312. private _imageProcessingObserver;
  61313. /**
  61314. * Attaches a new image processing configuration to the PBR Material.
  61315. * @param configuration (if null the scene configuration will be use)
  61316. */
  61317. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61318. /**
  61319. * Gets the image processing configuration used either in this material.
  61320. */
  61321. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61322. /**
  61323. * Sets the Default image processing configuration used either in the this material.
  61324. *
  61325. * If sets to null, the scene one is in use.
  61326. */
  61327. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61328. /**
  61329. * Gets wether the color curves effect is enabled.
  61330. */
  61331. get cameraColorCurvesEnabled(): boolean;
  61332. /**
  61333. * Sets wether the color curves effect is enabled.
  61334. */
  61335. set cameraColorCurvesEnabled(value: boolean);
  61336. /**
  61337. * Gets wether the color grading effect is enabled.
  61338. */
  61339. get cameraColorGradingEnabled(): boolean;
  61340. /**
  61341. * Gets wether the color grading effect is enabled.
  61342. */
  61343. set cameraColorGradingEnabled(value: boolean);
  61344. /**
  61345. * Gets wether tonemapping is enabled or not.
  61346. */
  61347. get cameraToneMappingEnabled(): boolean;
  61348. /**
  61349. * Sets wether tonemapping is enabled or not
  61350. */
  61351. set cameraToneMappingEnabled(value: boolean);
  61352. /**
  61353. * The camera exposure used on this material.
  61354. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61355. * This corresponds to a photographic exposure.
  61356. */
  61357. get cameraExposure(): float;
  61358. /**
  61359. * The camera exposure used on this material.
  61360. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61361. * This corresponds to a photographic exposure.
  61362. */
  61363. set cameraExposure(value: float);
  61364. /**
  61365. * Gets The camera contrast used on this material.
  61366. */
  61367. get cameraContrast(): float;
  61368. /**
  61369. * Sets The camera contrast used on this material.
  61370. */
  61371. set cameraContrast(value: float);
  61372. /**
  61373. * Gets the Color Grading 2D Lookup Texture.
  61374. */
  61375. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61376. /**
  61377. * Sets the Color Grading 2D Lookup Texture.
  61378. */
  61379. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61380. /**
  61381. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61382. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61383. * 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;
  61384. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61385. */
  61386. get cameraColorCurves(): Nullable<ColorCurves>;
  61387. /**
  61388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61390. * 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;
  61391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61392. */
  61393. set cameraColorCurves(value: Nullable<ColorCurves>);
  61394. /**
  61395. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61396. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61397. */
  61398. switchToBGR: boolean;
  61399. private _renderTargets;
  61400. private _reflectionControls;
  61401. private _white;
  61402. private _primaryShadowColor;
  61403. private _primaryHighlightColor;
  61404. /**
  61405. * Instantiates a Background Material in the given scene
  61406. * @param name The friendly name of the material
  61407. * @param scene The scene to add the material to
  61408. */
  61409. constructor(name: string, scene: Scene);
  61410. /**
  61411. * Gets a boolean indicating that current material needs to register RTT
  61412. */
  61413. get hasRenderTargetTextures(): boolean;
  61414. /**
  61415. * The entire material has been created in order to prevent overdraw.
  61416. * @returns false
  61417. */
  61418. needAlphaTesting(): boolean;
  61419. /**
  61420. * The entire material has been created in order to prevent overdraw.
  61421. * @returns true if blending is enable
  61422. */
  61423. needAlphaBlending(): boolean;
  61424. /**
  61425. * Checks wether the material is ready to be rendered for a given mesh.
  61426. * @param mesh The mesh to render
  61427. * @param subMesh The submesh to check against
  61428. * @param useInstances Specify wether or not the material is used with instances
  61429. * @returns true if all the dependencies are ready (Textures, Effects...)
  61430. */
  61431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61432. /**
  61433. * Compute the primary color according to the chosen perceptual color.
  61434. */
  61435. private _computePrimaryColorFromPerceptualColor;
  61436. /**
  61437. * Compute the highlights and shadow colors according to their chosen levels.
  61438. */
  61439. private _computePrimaryColors;
  61440. /**
  61441. * Build the uniform buffer used in the material.
  61442. */
  61443. buildUniformLayout(): void;
  61444. /**
  61445. * Unbind the material.
  61446. */
  61447. unbind(): void;
  61448. /**
  61449. * Bind only the world matrix to the material.
  61450. * @param world The world matrix to bind.
  61451. */
  61452. bindOnlyWorldMatrix(world: Matrix): void;
  61453. /**
  61454. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61455. * @param world The world matrix to bind.
  61456. * @param subMesh The submesh to bind for.
  61457. */
  61458. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61459. /**
  61460. * Checks to see if a texture is used in the material.
  61461. * @param texture - Base texture to use.
  61462. * @returns - Boolean specifying if a texture is used in the material.
  61463. */
  61464. hasTexture(texture: BaseTexture): boolean;
  61465. /**
  61466. * Dispose the material.
  61467. * @param forceDisposeEffect Force disposal of the associated effect.
  61468. * @param forceDisposeTextures Force disposal of the associated textures.
  61469. */
  61470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61471. /**
  61472. * Clones the material.
  61473. * @param name The cloned name.
  61474. * @returns The cloned material.
  61475. */
  61476. clone(name: string): BackgroundMaterial;
  61477. /**
  61478. * Serializes the current material to its JSON representation.
  61479. * @returns The JSON representation.
  61480. */
  61481. serialize(): any;
  61482. /**
  61483. * Gets the class name of the material
  61484. * @returns "BackgroundMaterial"
  61485. */
  61486. getClassName(): string;
  61487. /**
  61488. * Parse a JSON input to create back a background material.
  61489. * @param source The JSON data to parse
  61490. * @param scene The scene to create the parsed material in
  61491. * @param rootUrl The root url of the assets the material depends upon
  61492. * @returns the instantiated BackgroundMaterial.
  61493. */
  61494. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61495. }
  61496. }
  61497. declare module BABYLON {
  61498. /**
  61499. * Represents the different options available during the creation of
  61500. * a Environment helper.
  61501. *
  61502. * This can control the default ground, skybox and image processing setup of your scene.
  61503. */
  61504. export interface IEnvironmentHelperOptions {
  61505. /**
  61506. * Specifies whether or not to create a ground.
  61507. * True by default.
  61508. */
  61509. createGround: boolean;
  61510. /**
  61511. * Specifies the ground size.
  61512. * 15 by default.
  61513. */
  61514. groundSize: number;
  61515. /**
  61516. * The texture used on the ground for the main color.
  61517. * Comes from the BabylonJS CDN by default.
  61518. *
  61519. * Remarks: Can be either a texture or a url.
  61520. */
  61521. groundTexture: string | BaseTexture;
  61522. /**
  61523. * The color mixed in the ground texture by default.
  61524. * BabylonJS clearColor by default.
  61525. */
  61526. groundColor: Color3;
  61527. /**
  61528. * Specifies the ground opacity.
  61529. * 1 by default.
  61530. */
  61531. groundOpacity: number;
  61532. /**
  61533. * Enables the ground to receive shadows.
  61534. * True by default.
  61535. */
  61536. enableGroundShadow: boolean;
  61537. /**
  61538. * Helps preventing the shadow to be fully black on the ground.
  61539. * 0.5 by default.
  61540. */
  61541. groundShadowLevel: number;
  61542. /**
  61543. * Creates a mirror texture attach to the ground.
  61544. * false by default.
  61545. */
  61546. enableGroundMirror: boolean;
  61547. /**
  61548. * Specifies the ground mirror size ratio.
  61549. * 0.3 by default as the default kernel is 64.
  61550. */
  61551. groundMirrorSizeRatio: number;
  61552. /**
  61553. * Specifies the ground mirror blur kernel size.
  61554. * 64 by default.
  61555. */
  61556. groundMirrorBlurKernel: number;
  61557. /**
  61558. * Specifies the ground mirror visibility amount.
  61559. * 1 by default
  61560. */
  61561. groundMirrorAmount: number;
  61562. /**
  61563. * Specifies the ground mirror reflectance weight.
  61564. * This uses the standard weight of the background material to setup the fresnel effect
  61565. * of the mirror.
  61566. * 1 by default.
  61567. */
  61568. groundMirrorFresnelWeight: number;
  61569. /**
  61570. * Specifies the ground mirror Falloff distance.
  61571. * This can helps reducing the size of the reflection.
  61572. * 0 by Default.
  61573. */
  61574. groundMirrorFallOffDistance: number;
  61575. /**
  61576. * Specifies the ground mirror texture type.
  61577. * Unsigned Int by Default.
  61578. */
  61579. groundMirrorTextureType: number;
  61580. /**
  61581. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61582. * the shown objects.
  61583. */
  61584. groundYBias: number;
  61585. /**
  61586. * Specifies whether or not to create a skybox.
  61587. * True by default.
  61588. */
  61589. createSkybox: boolean;
  61590. /**
  61591. * Specifies the skybox size.
  61592. * 20 by default.
  61593. */
  61594. skyboxSize: number;
  61595. /**
  61596. * The texture used on the skybox for the main color.
  61597. * Comes from the BabylonJS CDN by default.
  61598. *
  61599. * Remarks: Can be either a texture or a url.
  61600. */
  61601. skyboxTexture: string | BaseTexture;
  61602. /**
  61603. * The color mixed in the skybox texture by default.
  61604. * BabylonJS clearColor by default.
  61605. */
  61606. skyboxColor: Color3;
  61607. /**
  61608. * The background rotation around the Y axis of the scene.
  61609. * This helps aligning the key lights of your scene with the background.
  61610. * 0 by default.
  61611. */
  61612. backgroundYRotation: number;
  61613. /**
  61614. * Compute automatically the size of the elements to best fit with the scene.
  61615. */
  61616. sizeAuto: boolean;
  61617. /**
  61618. * Default position of the rootMesh if autoSize is not true.
  61619. */
  61620. rootPosition: Vector3;
  61621. /**
  61622. * Sets up the image processing in the scene.
  61623. * true by default.
  61624. */
  61625. setupImageProcessing: boolean;
  61626. /**
  61627. * The texture used as your environment texture in the scene.
  61628. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61629. *
  61630. * Remarks: Can be either a texture or a url.
  61631. */
  61632. environmentTexture: string | BaseTexture;
  61633. /**
  61634. * The value of the exposure to apply to the scene.
  61635. * 0.6 by default if setupImageProcessing is true.
  61636. */
  61637. cameraExposure: number;
  61638. /**
  61639. * The value of the contrast to apply to the scene.
  61640. * 1.6 by default if setupImageProcessing is true.
  61641. */
  61642. cameraContrast: number;
  61643. /**
  61644. * Specifies whether or not tonemapping should be enabled in the scene.
  61645. * true by default if setupImageProcessing is true.
  61646. */
  61647. toneMappingEnabled: boolean;
  61648. }
  61649. /**
  61650. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61651. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61652. * It also helps with the default setup of your imageProcessing configuration.
  61653. */
  61654. export class EnvironmentHelper {
  61655. /**
  61656. * Default ground texture URL.
  61657. */
  61658. private static _groundTextureCDNUrl;
  61659. /**
  61660. * Default skybox texture URL.
  61661. */
  61662. private static _skyboxTextureCDNUrl;
  61663. /**
  61664. * Default environment texture URL.
  61665. */
  61666. private static _environmentTextureCDNUrl;
  61667. /**
  61668. * Creates the default options for the helper.
  61669. */
  61670. private static _getDefaultOptions;
  61671. private _rootMesh;
  61672. /**
  61673. * Gets the root mesh created by the helper.
  61674. */
  61675. get rootMesh(): Mesh;
  61676. private _skybox;
  61677. /**
  61678. * Gets the skybox created by the helper.
  61679. */
  61680. get skybox(): Nullable<Mesh>;
  61681. private _skyboxTexture;
  61682. /**
  61683. * Gets the skybox texture created by the helper.
  61684. */
  61685. get skyboxTexture(): Nullable<BaseTexture>;
  61686. private _skyboxMaterial;
  61687. /**
  61688. * Gets the skybox material created by the helper.
  61689. */
  61690. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61691. private _ground;
  61692. /**
  61693. * Gets the ground mesh created by the helper.
  61694. */
  61695. get ground(): Nullable<Mesh>;
  61696. private _groundTexture;
  61697. /**
  61698. * Gets the ground texture created by the helper.
  61699. */
  61700. get groundTexture(): Nullable<BaseTexture>;
  61701. private _groundMirror;
  61702. /**
  61703. * Gets the ground mirror created by the helper.
  61704. */
  61705. get groundMirror(): Nullable<MirrorTexture>;
  61706. /**
  61707. * Gets the ground mirror render list to helps pushing the meshes
  61708. * you wish in the ground reflection.
  61709. */
  61710. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61711. private _groundMaterial;
  61712. /**
  61713. * Gets the ground material created by the helper.
  61714. */
  61715. get groundMaterial(): Nullable<BackgroundMaterial>;
  61716. /**
  61717. * Stores the creation options.
  61718. */
  61719. private readonly _scene;
  61720. private _options;
  61721. /**
  61722. * This observable will be notified with any error during the creation of the environment,
  61723. * mainly texture creation errors.
  61724. */
  61725. onErrorObservable: Observable<{
  61726. message?: string;
  61727. exception?: any;
  61728. }>;
  61729. /**
  61730. * constructor
  61731. * @param options Defines the options we want to customize the helper
  61732. * @param scene The scene to add the material to
  61733. */
  61734. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61735. /**
  61736. * Updates the background according to the new options
  61737. * @param options
  61738. */
  61739. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61740. /**
  61741. * Sets the primary color of all the available elements.
  61742. * @param color the main color to affect to the ground and the background
  61743. */
  61744. setMainColor(color: Color3): void;
  61745. /**
  61746. * Setup the image processing according to the specified options.
  61747. */
  61748. private _setupImageProcessing;
  61749. /**
  61750. * Setup the environment texture according to the specified options.
  61751. */
  61752. private _setupEnvironmentTexture;
  61753. /**
  61754. * Setup the background according to the specified options.
  61755. */
  61756. private _setupBackground;
  61757. /**
  61758. * Get the scene sizes according to the setup.
  61759. */
  61760. private _getSceneSize;
  61761. /**
  61762. * Setup the ground according to the specified options.
  61763. */
  61764. private _setupGround;
  61765. /**
  61766. * Setup the ground material according to the specified options.
  61767. */
  61768. private _setupGroundMaterial;
  61769. /**
  61770. * Setup the ground diffuse texture according to the specified options.
  61771. */
  61772. private _setupGroundDiffuseTexture;
  61773. /**
  61774. * Setup the ground mirror texture according to the specified options.
  61775. */
  61776. private _setupGroundMirrorTexture;
  61777. /**
  61778. * Setup the ground to receive the mirror texture.
  61779. */
  61780. private _setupMirrorInGroundMaterial;
  61781. /**
  61782. * Setup the skybox according to the specified options.
  61783. */
  61784. private _setupSkybox;
  61785. /**
  61786. * Setup the skybox material according to the specified options.
  61787. */
  61788. private _setupSkyboxMaterial;
  61789. /**
  61790. * Setup the skybox reflection texture according to the specified options.
  61791. */
  61792. private _setupSkyboxReflectionTexture;
  61793. private _errorHandler;
  61794. /**
  61795. * Dispose all the elements created by the Helper.
  61796. */
  61797. dispose(): void;
  61798. }
  61799. }
  61800. declare module BABYLON {
  61801. /**
  61802. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61803. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61804. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61805. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61806. */
  61807. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61808. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61809. /**
  61810. * Define the source as a Monoscopic panoramic 360/180.
  61811. */
  61812. static readonly MODE_MONOSCOPIC: number;
  61813. /**
  61814. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61815. */
  61816. static readonly MODE_TOPBOTTOM: number;
  61817. /**
  61818. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61819. */
  61820. static readonly MODE_SIDEBYSIDE: number;
  61821. private _halfDome;
  61822. private _crossEye;
  61823. protected _useDirectMapping: boolean;
  61824. /**
  61825. * The texture being displayed on the sphere
  61826. */
  61827. protected _texture: T;
  61828. /**
  61829. * Gets the texture being displayed on the sphere
  61830. */
  61831. get texture(): T;
  61832. /**
  61833. * Sets the texture being displayed on the sphere
  61834. */
  61835. set texture(newTexture: T);
  61836. /**
  61837. * The skybox material
  61838. */
  61839. protected _material: BackgroundMaterial;
  61840. /**
  61841. * The surface used for the dome
  61842. */
  61843. protected _mesh: Mesh;
  61844. /**
  61845. * Gets the mesh used for the dome.
  61846. */
  61847. get mesh(): Mesh;
  61848. /**
  61849. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61850. */
  61851. private _halfDomeMask;
  61852. /**
  61853. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61854. * Also see the options.resolution property.
  61855. */
  61856. get fovMultiplier(): number;
  61857. set fovMultiplier(value: number);
  61858. protected _textureMode: number;
  61859. /**
  61860. * Gets or set the current texture mode for the texture. It can be:
  61861. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61862. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61863. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61864. */
  61865. get textureMode(): number;
  61866. /**
  61867. * Sets the current texture mode for the texture. It can be:
  61868. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61869. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61870. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61871. */
  61872. set textureMode(value: number);
  61873. /**
  61874. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61875. */
  61876. get halfDome(): boolean;
  61877. /**
  61878. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61879. */
  61880. set halfDome(enabled: boolean);
  61881. /**
  61882. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61883. */
  61884. set crossEye(enabled: boolean);
  61885. /**
  61886. * Is it a cross-eye texture?
  61887. */
  61888. get crossEye(): boolean;
  61889. /**
  61890. * The background material of this dome.
  61891. */
  61892. get material(): BackgroundMaterial;
  61893. /**
  61894. * Oberserver used in Stereoscopic VR Mode.
  61895. */
  61896. private _onBeforeCameraRenderObserver;
  61897. /**
  61898. * Observable raised when an error occured while loading the 360 image
  61899. */
  61900. onLoadErrorObservable: Observable<string>;
  61901. /**
  61902. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61903. * @param name Element's name, child elements will append suffixes for their own names.
  61904. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61905. * @param options An object containing optional or exposed sub element properties
  61906. */
  61907. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61908. resolution?: number;
  61909. clickToPlay?: boolean;
  61910. autoPlay?: boolean;
  61911. loop?: boolean;
  61912. size?: number;
  61913. poster?: string;
  61914. faceForward?: boolean;
  61915. useDirectMapping?: boolean;
  61916. halfDomeMode?: boolean;
  61917. crossEyeMode?: boolean;
  61918. generateMipMaps?: boolean;
  61919. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61920. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61921. protected _changeTextureMode(value: number): void;
  61922. /**
  61923. * Releases resources associated with this node.
  61924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61926. */
  61927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61928. }
  61929. }
  61930. declare module BABYLON {
  61931. /**
  61932. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61933. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61934. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61935. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61936. */
  61937. export class PhotoDome extends TextureDome<Texture> {
  61938. /**
  61939. * Define the image as a Monoscopic panoramic 360 image.
  61940. */
  61941. static readonly MODE_MONOSCOPIC: number;
  61942. /**
  61943. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61944. */
  61945. static readonly MODE_TOPBOTTOM: number;
  61946. /**
  61947. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61948. */
  61949. static readonly MODE_SIDEBYSIDE: number;
  61950. /**
  61951. * Gets or sets the texture being displayed on the sphere
  61952. */
  61953. get photoTexture(): Texture;
  61954. /**
  61955. * sets the texture being displayed on the sphere
  61956. */
  61957. set photoTexture(value: Texture);
  61958. /**
  61959. * Gets the current video mode for the video. It can be:
  61960. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61961. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61962. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61963. */
  61964. get imageMode(): number;
  61965. /**
  61966. * Sets the current video mode for the video. It can be:
  61967. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61968. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61969. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61970. */
  61971. set imageMode(value: number);
  61972. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61973. }
  61974. }
  61975. declare module BABYLON {
  61976. /**
  61977. * Direct draw surface info
  61978. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61979. */
  61980. export interface DDSInfo {
  61981. /**
  61982. * Width of the texture
  61983. */
  61984. width: number;
  61985. /**
  61986. * Width of the texture
  61987. */
  61988. height: number;
  61989. /**
  61990. * Number of Mipmaps for the texture
  61991. * @see https://en.wikipedia.org/wiki/Mipmap
  61992. */
  61993. mipmapCount: number;
  61994. /**
  61995. * If the textures format is a known fourCC format
  61996. * @see https://www.fourcc.org/
  61997. */
  61998. isFourCC: boolean;
  61999. /**
  62000. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62001. */
  62002. isRGB: boolean;
  62003. /**
  62004. * If the texture is a lumincance format
  62005. */
  62006. isLuminance: boolean;
  62007. /**
  62008. * If this is a cube texture
  62009. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62010. */
  62011. isCube: boolean;
  62012. /**
  62013. * If the texture is a compressed format eg. FOURCC_DXT1
  62014. */
  62015. isCompressed: boolean;
  62016. /**
  62017. * The dxgiFormat of the texture
  62018. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62019. */
  62020. dxgiFormat: number;
  62021. /**
  62022. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62023. */
  62024. textureType: number;
  62025. /**
  62026. * Sphericle polynomial created for the dds texture
  62027. */
  62028. sphericalPolynomial?: SphericalPolynomial;
  62029. }
  62030. /**
  62031. * Class used to provide DDS decompression tools
  62032. */
  62033. export class DDSTools {
  62034. /**
  62035. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62036. */
  62037. static StoreLODInAlphaChannel: boolean;
  62038. /**
  62039. * Gets DDS information from an array buffer
  62040. * @param data defines the array buffer view to read data from
  62041. * @returns the DDS information
  62042. */
  62043. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62044. private static _FloatView;
  62045. private static _Int32View;
  62046. private static _ToHalfFloat;
  62047. private static _FromHalfFloat;
  62048. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62049. private static _GetHalfFloatRGBAArrayBuffer;
  62050. private static _GetFloatRGBAArrayBuffer;
  62051. private static _GetFloatAsUIntRGBAArrayBuffer;
  62052. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62053. private static _GetRGBAArrayBuffer;
  62054. private static _ExtractLongWordOrder;
  62055. private static _GetRGBArrayBuffer;
  62056. private static _GetLuminanceArrayBuffer;
  62057. /**
  62058. * Uploads DDS Levels to a Babylon Texture
  62059. * @hidden
  62060. */
  62061. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62062. }
  62063. interface ThinEngine {
  62064. /**
  62065. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62066. * @param rootUrl defines the url where the file to load is located
  62067. * @param scene defines the current scene
  62068. * @param lodScale defines scale to apply to the mip map selection
  62069. * @param lodOffset defines offset to apply to the mip map selection
  62070. * @param onLoad defines an optional callback raised when the texture is loaded
  62071. * @param onError defines an optional callback raised if there is an issue to load the texture
  62072. * @param format defines the format of the data
  62073. * @param forcedExtension defines the extension to use to pick the right loader
  62074. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62075. * @returns the cube texture as an InternalTexture
  62076. */
  62077. 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;
  62078. }
  62079. }
  62080. declare module BABYLON {
  62081. /**
  62082. * Implementation of the DDS Texture Loader.
  62083. * @hidden
  62084. */
  62085. export class _DDSTextureLoader implements IInternalTextureLoader {
  62086. /**
  62087. * Defines wether the loader supports cascade loading the different faces.
  62088. */
  62089. readonly supportCascades: boolean;
  62090. /**
  62091. * This returns if the loader support the current file information.
  62092. * @param extension defines the file extension of the file being loaded
  62093. * @returns true if the loader can load the specified file
  62094. */
  62095. canLoad(extension: string): boolean;
  62096. /**
  62097. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62098. * @param data contains the texture data
  62099. * @param texture defines the BabylonJS internal texture
  62100. * @param createPolynomials will be true if polynomials have been requested
  62101. * @param onLoad defines the callback to trigger once the texture is ready
  62102. * @param onError defines the callback to trigger in case of error
  62103. */
  62104. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62105. /**
  62106. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62107. * @param data contains the texture data
  62108. * @param texture defines the BabylonJS internal texture
  62109. * @param callback defines the method to call once ready to upload
  62110. */
  62111. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62112. }
  62113. }
  62114. declare module BABYLON {
  62115. /**
  62116. * Implementation of the ENV Texture Loader.
  62117. * @hidden
  62118. */
  62119. export class _ENVTextureLoader implements IInternalTextureLoader {
  62120. /**
  62121. * Defines wether the loader supports cascade loading the different faces.
  62122. */
  62123. readonly supportCascades: boolean;
  62124. /**
  62125. * This returns if the loader support the current file information.
  62126. * @param extension defines the file extension of the file being loaded
  62127. * @returns true if the loader can load the specified file
  62128. */
  62129. canLoad(extension: string): boolean;
  62130. /**
  62131. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62132. * @param data contains the texture data
  62133. * @param texture defines the BabylonJS internal texture
  62134. * @param createPolynomials will be true if polynomials have been requested
  62135. * @param onLoad defines the callback to trigger once the texture is ready
  62136. * @param onError defines the callback to trigger in case of error
  62137. */
  62138. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62139. /**
  62140. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62141. * @param data contains the texture data
  62142. * @param texture defines the BabylonJS internal texture
  62143. * @param callback defines the method to call once ready to upload
  62144. */
  62145. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62146. }
  62147. }
  62148. declare module BABYLON {
  62149. /**
  62150. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62151. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62152. */
  62153. export class KhronosTextureContainer {
  62154. /** contents of the KTX container file */
  62155. data: ArrayBufferView;
  62156. private static HEADER_LEN;
  62157. private static COMPRESSED_2D;
  62158. private static COMPRESSED_3D;
  62159. private static TEX_2D;
  62160. private static TEX_3D;
  62161. /**
  62162. * Gets the openGL type
  62163. */
  62164. glType: number;
  62165. /**
  62166. * Gets the openGL type size
  62167. */
  62168. glTypeSize: number;
  62169. /**
  62170. * Gets the openGL format
  62171. */
  62172. glFormat: number;
  62173. /**
  62174. * Gets the openGL internal format
  62175. */
  62176. glInternalFormat: number;
  62177. /**
  62178. * Gets the base internal format
  62179. */
  62180. glBaseInternalFormat: number;
  62181. /**
  62182. * Gets image width in pixel
  62183. */
  62184. pixelWidth: number;
  62185. /**
  62186. * Gets image height in pixel
  62187. */
  62188. pixelHeight: number;
  62189. /**
  62190. * Gets image depth in pixels
  62191. */
  62192. pixelDepth: number;
  62193. /**
  62194. * Gets the number of array elements
  62195. */
  62196. numberOfArrayElements: number;
  62197. /**
  62198. * Gets the number of faces
  62199. */
  62200. numberOfFaces: number;
  62201. /**
  62202. * Gets the number of mipmap levels
  62203. */
  62204. numberOfMipmapLevels: number;
  62205. /**
  62206. * Gets the bytes of key value data
  62207. */
  62208. bytesOfKeyValueData: number;
  62209. /**
  62210. * Gets the load type
  62211. */
  62212. loadType: number;
  62213. /**
  62214. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62215. */
  62216. isInvalid: boolean;
  62217. /**
  62218. * Creates a new KhronosTextureContainer
  62219. * @param data contents of the KTX container file
  62220. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62221. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62222. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62223. */
  62224. constructor(
  62225. /** contents of the KTX container file */
  62226. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62227. /**
  62228. * Uploads KTX content to a Babylon Texture.
  62229. * It is assumed that the texture has already been created & is currently bound
  62230. * @hidden
  62231. */
  62232. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62233. private _upload2DCompressedLevels;
  62234. /**
  62235. * Checks if the given data starts with a KTX file identifier.
  62236. * @param data the data to check
  62237. * @returns true if the data is a KTX file or false otherwise
  62238. */
  62239. static IsValid(data: ArrayBufferView): boolean;
  62240. }
  62241. }
  62242. declare module BABYLON {
  62243. /**
  62244. * Helper class to push actions to a pool of workers.
  62245. */
  62246. export class WorkerPool implements IDisposable {
  62247. private _workerInfos;
  62248. private _pendingActions;
  62249. /**
  62250. * Constructor
  62251. * @param workers Array of workers to use for actions
  62252. */
  62253. constructor(workers: Array<Worker>);
  62254. /**
  62255. * Terminates all workers and clears any pending actions.
  62256. */
  62257. dispose(): void;
  62258. /**
  62259. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62260. * pended until a worker has completed its action.
  62261. * @param action The action to perform. Call onComplete when the action is complete.
  62262. */
  62263. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62264. private _execute;
  62265. }
  62266. }
  62267. declare module BABYLON {
  62268. /**
  62269. * Class for loading KTX2 files
  62270. */
  62271. export class KhronosTextureContainer2 {
  62272. private static _WorkerPoolPromise?;
  62273. private static _Initialized;
  62274. private static _Ktx2Decoder;
  62275. /**
  62276. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62277. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62278. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62279. * Urls you can change:
  62280. * URLConfig.jsDecoderModule
  62281. * URLConfig.wasmUASTCToASTC
  62282. * URLConfig.wasmUASTCToBC7
  62283. * URLConfig.wasmUASTCToRGBA_UNORM
  62284. * URLConfig.wasmUASTCToRGBA_SRGB
  62285. * URLConfig.jsMSCTranscoder
  62286. * URLConfig.wasmMSCTranscoder
  62287. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62288. */
  62289. static URLConfig: {
  62290. jsDecoderModule: string;
  62291. wasmUASTCToASTC: null;
  62292. wasmUASTCToBC7: null;
  62293. wasmUASTCToRGBA_UNORM: null;
  62294. wasmUASTCToRGBA_SRGB: null;
  62295. jsMSCTranscoder: null;
  62296. wasmMSCTranscoder: null;
  62297. };
  62298. /**
  62299. * Default number of workers used to handle data decoding
  62300. */
  62301. static DefaultNumWorkers: number;
  62302. private static GetDefaultNumWorkers;
  62303. private _engine;
  62304. private static _CreateWorkerPool;
  62305. /**
  62306. * Constructor
  62307. * @param engine The engine to use
  62308. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62309. */
  62310. constructor(engine: ThinEngine, numWorkers?: number);
  62311. /** @hidden */
  62312. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62313. /**
  62314. * Stop all async operations and release resources.
  62315. */
  62316. dispose(): void;
  62317. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62318. /**
  62319. * Checks if the given data starts with a KTX2 file identifier.
  62320. * @param data the data to check
  62321. * @returns true if the data is a KTX2 file or false otherwise
  62322. */
  62323. static IsValid(data: ArrayBufferView): boolean;
  62324. }
  62325. }
  62326. declare module BABYLON {
  62327. /**
  62328. * Implementation of the KTX Texture Loader.
  62329. * @hidden
  62330. */
  62331. export class _KTXTextureLoader implements IInternalTextureLoader {
  62332. /**
  62333. * Defines wether the loader supports cascade loading the different faces.
  62334. */
  62335. readonly supportCascades: boolean;
  62336. /**
  62337. * This returns if the loader support the current file information.
  62338. * @param extension defines the file extension of the file being loaded
  62339. * @param mimeType defines the optional mime type of the file being loaded
  62340. * @returns true if the loader can load the specified file
  62341. */
  62342. canLoad(extension: string, mimeType?: string): boolean;
  62343. /**
  62344. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62345. * @param data contains the texture data
  62346. * @param texture defines the BabylonJS internal texture
  62347. * @param createPolynomials will be true if polynomials have been requested
  62348. * @param onLoad defines the callback to trigger once the texture is ready
  62349. * @param onError defines the callback to trigger in case of error
  62350. */
  62351. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62352. /**
  62353. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62354. * @param data contains the texture data
  62355. * @param texture defines the BabylonJS internal texture
  62356. * @param callback defines the method to call once ready to upload
  62357. */
  62358. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62359. }
  62360. }
  62361. declare module BABYLON {
  62362. /** @hidden */
  62363. export var _forceSceneHelpersToBundle: boolean;
  62364. interface Scene {
  62365. /**
  62366. * Creates a default light for the scene.
  62367. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62368. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62369. */
  62370. createDefaultLight(replace?: boolean): void;
  62371. /**
  62372. * Creates a default camera for the scene.
  62373. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62374. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62375. * @param replace has default false, when true replaces the active camera in the scene
  62376. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62377. */
  62378. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62379. /**
  62380. * Creates a default camera and a default light.
  62381. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62382. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62383. * @param replace has the default false, when true replaces the active camera/light in the scene
  62384. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62385. */
  62386. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62387. /**
  62388. * Creates a new sky box
  62389. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62390. * @param environmentTexture defines the texture to use as environment texture
  62391. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62392. * @param scale defines the overall scale of the skybox
  62393. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62394. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62395. * @returns a new mesh holding the sky box
  62396. */
  62397. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62398. /**
  62399. * Creates a new environment
  62400. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62401. * @param options defines the options you can use to configure the environment
  62402. * @returns the new EnvironmentHelper
  62403. */
  62404. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62405. /**
  62406. * Creates a new VREXperienceHelper
  62407. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62408. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62409. * @returns a new VREXperienceHelper
  62410. */
  62411. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62412. /**
  62413. * Creates a new WebXRDefaultExperience
  62414. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62415. * @param options experience options
  62416. * @returns a promise for a new WebXRDefaultExperience
  62417. */
  62418. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62419. }
  62420. }
  62421. declare module BABYLON {
  62422. /**
  62423. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62424. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62425. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62426. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62427. */
  62428. export class VideoDome extends TextureDome<VideoTexture> {
  62429. /**
  62430. * Define the video source as a Monoscopic panoramic 360 video.
  62431. */
  62432. static readonly MODE_MONOSCOPIC: number;
  62433. /**
  62434. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62435. */
  62436. static readonly MODE_TOPBOTTOM: number;
  62437. /**
  62438. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62439. */
  62440. static readonly MODE_SIDEBYSIDE: number;
  62441. /**
  62442. * Get the video texture associated with this video dome
  62443. */
  62444. get videoTexture(): VideoTexture;
  62445. /**
  62446. * Get the video mode of this dome
  62447. */
  62448. get videoMode(): number;
  62449. /**
  62450. * Set the video mode of this dome.
  62451. * @see textureMode
  62452. */
  62453. set videoMode(value: number);
  62454. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62455. }
  62456. }
  62457. declare module BABYLON {
  62458. /**
  62459. * This class can be used to get instrumentation data from a Babylon engine
  62460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62461. */
  62462. export class EngineInstrumentation implements IDisposable {
  62463. /**
  62464. * Define the instrumented engine.
  62465. */
  62466. engine: Engine;
  62467. private _captureGPUFrameTime;
  62468. private _gpuFrameTimeToken;
  62469. private _gpuFrameTime;
  62470. private _captureShaderCompilationTime;
  62471. private _shaderCompilationTime;
  62472. private _onBeginFrameObserver;
  62473. private _onEndFrameObserver;
  62474. private _onBeforeShaderCompilationObserver;
  62475. private _onAfterShaderCompilationObserver;
  62476. /**
  62477. * Gets the perf counter used for GPU frame time
  62478. */
  62479. get gpuFrameTimeCounter(): PerfCounter;
  62480. /**
  62481. * Gets the GPU frame time capture status
  62482. */
  62483. get captureGPUFrameTime(): boolean;
  62484. /**
  62485. * Enable or disable the GPU frame time capture
  62486. */
  62487. set captureGPUFrameTime(value: boolean);
  62488. /**
  62489. * Gets the perf counter used for shader compilation time
  62490. */
  62491. get shaderCompilationTimeCounter(): PerfCounter;
  62492. /**
  62493. * Gets the shader compilation time capture status
  62494. */
  62495. get captureShaderCompilationTime(): boolean;
  62496. /**
  62497. * Enable or disable the shader compilation time capture
  62498. */
  62499. set captureShaderCompilationTime(value: boolean);
  62500. /**
  62501. * Instantiates a new engine instrumentation.
  62502. * This class can be used to get instrumentation data from a Babylon engine
  62503. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62504. * @param engine Defines the engine to instrument
  62505. */
  62506. constructor(
  62507. /**
  62508. * Define the instrumented engine.
  62509. */
  62510. engine: Engine);
  62511. /**
  62512. * Dispose and release associated resources.
  62513. */
  62514. dispose(): void;
  62515. }
  62516. }
  62517. declare module BABYLON {
  62518. /**
  62519. * This class can be used to get instrumentation data from a Babylon engine
  62520. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62521. */
  62522. export class SceneInstrumentation implements IDisposable {
  62523. /**
  62524. * Defines the scene to instrument
  62525. */
  62526. scene: Scene;
  62527. private _captureActiveMeshesEvaluationTime;
  62528. private _activeMeshesEvaluationTime;
  62529. private _captureRenderTargetsRenderTime;
  62530. private _renderTargetsRenderTime;
  62531. private _captureFrameTime;
  62532. private _frameTime;
  62533. private _captureRenderTime;
  62534. private _renderTime;
  62535. private _captureInterFrameTime;
  62536. private _interFrameTime;
  62537. private _captureParticlesRenderTime;
  62538. private _particlesRenderTime;
  62539. private _captureSpritesRenderTime;
  62540. private _spritesRenderTime;
  62541. private _capturePhysicsTime;
  62542. private _physicsTime;
  62543. private _captureAnimationsTime;
  62544. private _animationsTime;
  62545. private _captureCameraRenderTime;
  62546. private _cameraRenderTime;
  62547. private _onBeforeActiveMeshesEvaluationObserver;
  62548. private _onAfterActiveMeshesEvaluationObserver;
  62549. private _onBeforeRenderTargetsRenderObserver;
  62550. private _onAfterRenderTargetsRenderObserver;
  62551. private _onAfterRenderObserver;
  62552. private _onBeforeDrawPhaseObserver;
  62553. private _onAfterDrawPhaseObserver;
  62554. private _onBeforeAnimationsObserver;
  62555. private _onBeforeParticlesRenderingObserver;
  62556. private _onAfterParticlesRenderingObserver;
  62557. private _onBeforeSpritesRenderingObserver;
  62558. private _onAfterSpritesRenderingObserver;
  62559. private _onBeforePhysicsObserver;
  62560. private _onAfterPhysicsObserver;
  62561. private _onAfterAnimationsObserver;
  62562. private _onBeforeCameraRenderObserver;
  62563. private _onAfterCameraRenderObserver;
  62564. /**
  62565. * Gets the perf counter used for active meshes evaluation time
  62566. */
  62567. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62568. /**
  62569. * Gets the active meshes evaluation time capture status
  62570. */
  62571. get captureActiveMeshesEvaluationTime(): boolean;
  62572. /**
  62573. * Enable or disable the active meshes evaluation time capture
  62574. */
  62575. set captureActiveMeshesEvaluationTime(value: boolean);
  62576. /**
  62577. * Gets the perf counter used for render targets render time
  62578. */
  62579. get renderTargetsRenderTimeCounter(): PerfCounter;
  62580. /**
  62581. * Gets the render targets render time capture status
  62582. */
  62583. get captureRenderTargetsRenderTime(): boolean;
  62584. /**
  62585. * Enable or disable the render targets render time capture
  62586. */
  62587. set captureRenderTargetsRenderTime(value: boolean);
  62588. /**
  62589. * Gets the perf counter used for particles render time
  62590. */
  62591. get particlesRenderTimeCounter(): PerfCounter;
  62592. /**
  62593. * Gets the particles render time capture status
  62594. */
  62595. get captureParticlesRenderTime(): boolean;
  62596. /**
  62597. * Enable or disable the particles render time capture
  62598. */
  62599. set captureParticlesRenderTime(value: boolean);
  62600. /**
  62601. * Gets the perf counter used for sprites render time
  62602. */
  62603. get spritesRenderTimeCounter(): PerfCounter;
  62604. /**
  62605. * Gets the sprites render time capture status
  62606. */
  62607. get captureSpritesRenderTime(): boolean;
  62608. /**
  62609. * Enable or disable the sprites render time capture
  62610. */
  62611. set captureSpritesRenderTime(value: boolean);
  62612. /**
  62613. * Gets the perf counter used for physics time
  62614. */
  62615. get physicsTimeCounter(): PerfCounter;
  62616. /**
  62617. * Gets the physics time capture status
  62618. */
  62619. get capturePhysicsTime(): boolean;
  62620. /**
  62621. * Enable or disable the physics time capture
  62622. */
  62623. set capturePhysicsTime(value: boolean);
  62624. /**
  62625. * Gets the perf counter used for animations time
  62626. */
  62627. get animationsTimeCounter(): PerfCounter;
  62628. /**
  62629. * Gets the animations time capture status
  62630. */
  62631. get captureAnimationsTime(): boolean;
  62632. /**
  62633. * Enable or disable the animations time capture
  62634. */
  62635. set captureAnimationsTime(value: boolean);
  62636. /**
  62637. * Gets the perf counter used for frame time capture
  62638. */
  62639. get frameTimeCounter(): PerfCounter;
  62640. /**
  62641. * Gets the frame time capture status
  62642. */
  62643. get captureFrameTime(): boolean;
  62644. /**
  62645. * Enable or disable the frame time capture
  62646. */
  62647. set captureFrameTime(value: boolean);
  62648. /**
  62649. * Gets the perf counter used for inter-frames time capture
  62650. */
  62651. get interFrameTimeCounter(): PerfCounter;
  62652. /**
  62653. * Gets the inter-frames time capture status
  62654. */
  62655. get captureInterFrameTime(): boolean;
  62656. /**
  62657. * Enable or disable the inter-frames time capture
  62658. */
  62659. set captureInterFrameTime(value: boolean);
  62660. /**
  62661. * Gets the perf counter used for render time capture
  62662. */
  62663. get renderTimeCounter(): PerfCounter;
  62664. /**
  62665. * Gets the render time capture status
  62666. */
  62667. get captureRenderTime(): boolean;
  62668. /**
  62669. * Enable or disable the render time capture
  62670. */
  62671. set captureRenderTime(value: boolean);
  62672. /**
  62673. * Gets the perf counter used for camera render time capture
  62674. */
  62675. get cameraRenderTimeCounter(): PerfCounter;
  62676. /**
  62677. * Gets the camera render time capture status
  62678. */
  62679. get captureCameraRenderTime(): boolean;
  62680. /**
  62681. * Enable or disable the camera render time capture
  62682. */
  62683. set captureCameraRenderTime(value: boolean);
  62684. /**
  62685. * Gets the perf counter used for draw calls
  62686. */
  62687. get drawCallsCounter(): PerfCounter;
  62688. /**
  62689. * Instantiates a new scene instrumentation.
  62690. * This class can be used to get instrumentation data from a Babylon engine
  62691. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62692. * @param scene Defines the scene to instrument
  62693. */
  62694. constructor(
  62695. /**
  62696. * Defines the scene to instrument
  62697. */
  62698. scene: Scene);
  62699. /**
  62700. * Dispose and release associated resources.
  62701. */
  62702. dispose(): void;
  62703. }
  62704. }
  62705. declare module BABYLON {
  62706. /** @hidden */
  62707. export var glowMapGenerationPixelShader: {
  62708. name: string;
  62709. shader: string;
  62710. };
  62711. }
  62712. declare module BABYLON {
  62713. /** @hidden */
  62714. export var glowMapGenerationVertexShader: {
  62715. name: string;
  62716. shader: string;
  62717. };
  62718. }
  62719. declare module BABYLON {
  62720. /**
  62721. * Effect layer options. This helps customizing the behaviour
  62722. * of the effect layer.
  62723. */
  62724. export interface IEffectLayerOptions {
  62725. /**
  62726. * Multiplication factor apply to the canvas size to compute the render target size
  62727. * used to generated the objects (the smaller the faster).
  62728. */
  62729. mainTextureRatio: number;
  62730. /**
  62731. * Enforces a fixed size texture to ensure effect stability across devices.
  62732. */
  62733. mainTextureFixedSize?: number;
  62734. /**
  62735. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62736. */
  62737. alphaBlendingMode: number;
  62738. /**
  62739. * The camera attached to the layer.
  62740. */
  62741. camera: Nullable<Camera>;
  62742. /**
  62743. * The rendering group to draw the layer in.
  62744. */
  62745. renderingGroupId: number;
  62746. }
  62747. /**
  62748. * The effect layer Helps adding post process effect blended with the main pass.
  62749. *
  62750. * This can be for instance use to generate glow or higlight effects on the scene.
  62751. *
  62752. * The effect layer class can not be used directly and is intented to inherited from to be
  62753. * customized per effects.
  62754. */
  62755. export abstract class EffectLayer {
  62756. private _vertexBuffers;
  62757. private _indexBuffer;
  62758. private _cachedDefines;
  62759. private _effectLayerMapGenerationEffect;
  62760. private _effectLayerOptions;
  62761. private _mergeEffect;
  62762. protected _scene: Scene;
  62763. protected _engine: Engine;
  62764. protected _maxSize: number;
  62765. protected _mainTextureDesiredSize: ISize;
  62766. protected _mainTexture: RenderTargetTexture;
  62767. protected _shouldRender: boolean;
  62768. protected _postProcesses: PostProcess[];
  62769. protected _textures: BaseTexture[];
  62770. protected _emissiveTextureAndColor: {
  62771. texture: Nullable<BaseTexture>;
  62772. color: Color4;
  62773. };
  62774. /**
  62775. * The name of the layer
  62776. */
  62777. name: string;
  62778. /**
  62779. * The clear color of the texture used to generate the glow map.
  62780. */
  62781. neutralColor: Color4;
  62782. /**
  62783. * Specifies whether the highlight layer is enabled or not.
  62784. */
  62785. isEnabled: boolean;
  62786. /**
  62787. * Gets the camera attached to the layer.
  62788. */
  62789. get camera(): Nullable<Camera>;
  62790. /**
  62791. * Gets the rendering group id the layer should render in.
  62792. */
  62793. get renderingGroupId(): number;
  62794. set renderingGroupId(renderingGroupId: number);
  62795. /**
  62796. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62797. */
  62798. disableBoundingBoxesFromEffectLayer: boolean;
  62799. /**
  62800. * An event triggered when the effect layer has been disposed.
  62801. */
  62802. onDisposeObservable: Observable<EffectLayer>;
  62803. /**
  62804. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62805. */
  62806. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62807. /**
  62808. * An event triggered when the generated texture is being merged in the scene.
  62809. */
  62810. onBeforeComposeObservable: Observable<EffectLayer>;
  62811. /**
  62812. * An event triggered when the mesh is rendered into the effect render target.
  62813. */
  62814. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62815. /**
  62816. * An event triggered after the mesh has been rendered into the effect render target.
  62817. */
  62818. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62819. /**
  62820. * An event triggered when the generated texture has been merged in the scene.
  62821. */
  62822. onAfterComposeObservable: Observable<EffectLayer>;
  62823. /**
  62824. * An event triggered when the efffect layer changes its size.
  62825. */
  62826. onSizeChangedObservable: Observable<EffectLayer>;
  62827. /** @hidden */
  62828. static _SceneComponentInitialization: (scene: Scene) => void;
  62829. /**
  62830. * Instantiates a new effect Layer and references it in the scene.
  62831. * @param name The name of the layer
  62832. * @param scene The scene to use the layer in
  62833. */
  62834. constructor(
  62835. /** The Friendly of the effect in the scene */
  62836. name: string, scene: Scene);
  62837. /**
  62838. * Get the effect name of the layer.
  62839. * @return The effect name
  62840. */
  62841. abstract getEffectName(): string;
  62842. /**
  62843. * Checks for the readiness of the element composing the layer.
  62844. * @param subMesh the mesh to check for
  62845. * @param useInstances specify whether or not to use instances to render the mesh
  62846. * @return true if ready otherwise, false
  62847. */
  62848. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62849. /**
  62850. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62851. * @returns true if the effect requires stencil during the main canvas render pass.
  62852. */
  62853. abstract needStencil(): boolean;
  62854. /**
  62855. * Create the merge effect. This is the shader use to blit the information back
  62856. * to the main canvas at the end of the scene rendering.
  62857. * @returns The effect containing the shader used to merge the effect on the main canvas
  62858. */
  62859. protected abstract _createMergeEffect(): Effect;
  62860. /**
  62861. * Creates the render target textures and post processes used in the effect layer.
  62862. */
  62863. protected abstract _createTextureAndPostProcesses(): void;
  62864. /**
  62865. * Implementation specific of rendering the generating effect on the main canvas.
  62866. * @param effect The effect used to render through
  62867. */
  62868. protected abstract _internalRender(effect: Effect): void;
  62869. /**
  62870. * Sets the required values for both the emissive texture and and the main color.
  62871. */
  62872. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62873. /**
  62874. * Free any resources and references associated to a mesh.
  62875. * Internal use
  62876. * @param mesh The mesh to free.
  62877. */
  62878. abstract _disposeMesh(mesh: Mesh): void;
  62879. /**
  62880. * Serializes this layer (Glow or Highlight for example)
  62881. * @returns a serialized layer object
  62882. */
  62883. abstract serialize?(): any;
  62884. /**
  62885. * Initializes the effect layer with the required options.
  62886. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62887. */
  62888. protected _init(options: Partial<IEffectLayerOptions>): void;
  62889. /**
  62890. * Generates the index buffer of the full screen quad blending to the main canvas.
  62891. */
  62892. private _generateIndexBuffer;
  62893. /**
  62894. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62895. */
  62896. private _generateVertexBuffer;
  62897. /**
  62898. * Sets the main texture desired size which is the closest power of two
  62899. * of the engine canvas size.
  62900. */
  62901. private _setMainTextureSize;
  62902. /**
  62903. * Creates the main texture for the effect layer.
  62904. */
  62905. protected _createMainTexture(): void;
  62906. /**
  62907. * Adds specific effects defines.
  62908. * @param defines The defines to add specifics to.
  62909. */
  62910. protected _addCustomEffectDefines(defines: string[]): void;
  62911. /**
  62912. * Checks for the readiness of the element composing the layer.
  62913. * @param subMesh the mesh to check for
  62914. * @param useInstances specify whether or not to use instances to render the mesh
  62915. * @param emissiveTexture the associated emissive texture used to generate the glow
  62916. * @return true if ready otherwise, false
  62917. */
  62918. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62919. /**
  62920. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62921. */
  62922. render(): void;
  62923. /**
  62924. * Determine if a given mesh will be used in the current effect.
  62925. * @param mesh mesh to test
  62926. * @returns true if the mesh will be used
  62927. */
  62928. hasMesh(mesh: AbstractMesh): boolean;
  62929. /**
  62930. * Returns true if the layer contains information to display, otherwise false.
  62931. * @returns true if the glow layer should be rendered
  62932. */
  62933. shouldRender(): boolean;
  62934. /**
  62935. * Returns true if the mesh should render, otherwise false.
  62936. * @param mesh The mesh to render
  62937. * @returns true if it should render otherwise false
  62938. */
  62939. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62940. /**
  62941. * Returns true if the mesh can be rendered, otherwise false.
  62942. * @param mesh The mesh to render
  62943. * @param material The material used on the mesh
  62944. * @returns true if it can be rendered otherwise false
  62945. */
  62946. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62947. /**
  62948. * Returns true if the mesh should render, otherwise false.
  62949. * @param mesh The mesh to render
  62950. * @returns true if it should render otherwise false
  62951. */
  62952. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62953. /**
  62954. * Renders the submesh passed in parameter to the generation map.
  62955. */
  62956. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62957. /**
  62958. * Defines whether the current material of the mesh should be use to render the effect.
  62959. * @param mesh defines the current mesh to render
  62960. */
  62961. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62962. /**
  62963. * Rebuild the required buffers.
  62964. * @hidden Internal use only.
  62965. */
  62966. _rebuild(): void;
  62967. /**
  62968. * Dispose only the render target textures and post process.
  62969. */
  62970. private _disposeTextureAndPostProcesses;
  62971. /**
  62972. * Dispose the highlight layer and free resources.
  62973. */
  62974. dispose(): void;
  62975. /**
  62976. * Gets the class name of the effect layer
  62977. * @returns the string with the class name of the effect layer
  62978. */
  62979. getClassName(): string;
  62980. /**
  62981. * Creates an effect layer from parsed effect layer data
  62982. * @param parsedEffectLayer defines effect layer data
  62983. * @param scene defines the current scene
  62984. * @param rootUrl defines the root URL containing the effect layer information
  62985. * @returns a parsed effect Layer
  62986. */
  62987. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62988. }
  62989. }
  62990. declare module BABYLON {
  62991. interface AbstractScene {
  62992. /**
  62993. * The list of effect layers (highlights/glow) added to the scene
  62994. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62995. * @see https://doc.babylonjs.com/how_to/glow_layer
  62996. */
  62997. effectLayers: Array<EffectLayer>;
  62998. /**
  62999. * Removes the given effect layer from this scene.
  63000. * @param toRemove defines the effect layer to remove
  63001. * @returns the index of the removed effect layer
  63002. */
  63003. removeEffectLayer(toRemove: EffectLayer): number;
  63004. /**
  63005. * Adds the given effect layer to this scene
  63006. * @param newEffectLayer defines the effect layer to add
  63007. */
  63008. addEffectLayer(newEffectLayer: EffectLayer): void;
  63009. }
  63010. /**
  63011. * Defines the layer scene component responsible to manage any effect layers
  63012. * in a given scene.
  63013. */
  63014. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63015. /**
  63016. * The component name helpfull to identify the component in the list of scene components.
  63017. */
  63018. readonly name: string;
  63019. /**
  63020. * The scene the component belongs to.
  63021. */
  63022. scene: Scene;
  63023. private _engine;
  63024. private _renderEffects;
  63025. private _needStencil;
  63026. private _previousStencilState;
  63027. /**
  63028. * Creates a new instance of the component for the given scene
  63029. * @param scene Defines the scene to register the component in
  63030. */
  63031. constructor(scene: Scene);
  63032. /**
  63033. * Registers the component in a given scene
  63034. */
  63035. register(): void;
  63036. /**
  63037. * Rebuilds the elements related to this component in case of
  63038. * context lost for instance.
  63039. */
  63040. rebuild(): void;
  63041. /**
  63042. * Serializes the component data to the specified json object
  63043. * @param serializationObject The object to serialize to
  63044. */
  63045. serialize(serializationObject: any): void;
  63046. /**
  63047. * Adds all the elements from the container to the scene
  63048. * @param container the container holding the elements
  63049. */
  63050. addFromContainer(container: AbstractScene): void;
  63051. /**
  63052. * Removes all the elements in the container from the scene
  63053. * @param container contains the elements to remove
  63054. * @param dispose if the removed element should be disposed (default: false)
  63055. */
  63056. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63057. /**
  63058. * Disposes the component and the associated ressources.
  63059. */
  63060. dispose(): void;
  63061. private _isReadyForMesh;
  63062. private _renderMainTexture;
  63063. private _setStencil;
  63064. private _setStencilBack;
  63065. private _draw;
  63066. private _drawCamera;
  63067. private _drawRenderingGroup;
  63068. }
  63069. }
  63070. declare module BABYLON {
  63071. /** @hidden */
  63072. export var glowMapMergePixelShader: {
  63073. name: string;
  63074. shader: string;
  63075. };
  63076. }
  63077. declare module BABYLON {
  63078. /** @hidden */
  63079. export var glowMapMergeVertexShader: {
  63080. name: string;
  63081. shader: string;
  63082. };
  63083. }
  63084. declare module BABYLON {
  63085. interface AbstractScene {
  63086. /**
  63087. * Return a the first highlight layer of the scene with a given name.
  63088. * @param name The name of the highlight layer to look for.
  63089. * @return The highlight layer if found otherwise null.
  63090. */
  63091. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63092. }
  63093. /**
  63094. * Glow layer options. This helps customizing the behaviour
  63095. * of the glow layer.
  63096. */
  63097. export interface IGlowLayerOptions {
  63098. /**
  63099. * Multiplication factor apply to the canvas size to compute the render target size
  63100. * used to generated the glowing objects (the smaller the faster).
  63101. */
  63102. mainTextureRatio: number;
  63103. /**
  63104. * Enforces a fixed size texture to ensure resize independant blur.
  63105. */
  63106. mainTextureFixedSize?: number;
  63107. /**
  63108. * How big is the kernel of the blur texture.
  63109. */
  63110. blurKernelSize: number;
  63111. /**
  63112. * The camera attached to the layer.
  63113. */
  63114. camera: Nullable<Camera>;
  63115. /**
  63116. * Enable MSAA by chosing the number of samples.
  63117. */
  63118. mainTextureSamples?: number;
  63119. /**
  63120. * The rendering group to draw the layer in.
  63121. */
  63122. renderingGroupId: number;
  63123. }
  63124. /**
  63125. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63126. *
  63127. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63128. *
  63129. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63130. */
  63131. export class GlowLayer extends EffectLayer {
  63132. /**
  63133. * Effect Name of the layer.
  63134. */
  63135. static readonly EffectName: string;
  63136. /**
  63137. * The default blur kernel size used for the glow.
  63138. */
  63139. static DefaultBlurKernelSize: number;
  63140. /**
  63141. * The default texture size ratio used for the glow.
  63142. */
  63143. static DefaultTextureRatio: number;
  63144. /**
  63145. * Sets the kernel size of the blur.
  63146. */
  63147. set blurKernelSize(value: number);
  63148. /**
  63149. * Gets the kernel size of the blur.
  63150. */
  63151. get blurKernelSize(): number;
  63152. /**
  63153. * Sets the glow intensity.
  63154. */
  63155. set intensity(value: number);
  63156. /**
  63157. * Gets the glow intensity.
  63158. */
  63159. get intensity(): number;
  63160. private _options;
  63161. private _intensity;
  63162. private _horizontalBlurPostprocess1;
  63163. private _verticalBlurPostprocess1;
  63164. private _horizontalBlurPostprocess2;
  63165. private _verticalBlurPostprocess2;
  63166. private _blurTexture1;
  63167. private _blurTexture2;
  63168. private _postProcesses1;
  63169. private _postProcesses2;
  63170. private _includedOnlyMeshes;
  63171. private _excludedMeshes;
  63172. private _meshesUsingTheirOwnMaterials;
  63173. /**
  63174. * Callback used to let the user override the color selection on a per mesh basis
  63175. */
  63176. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63177. /**
  63178. * Callback used to let the user override the texture selection on a per mesh basis
  63179. */
  63180. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63181. /**
  63182. * Instantiates a new glow Layer and references it to the scene.
  63183. * @param name The name of the layer
  63184. * @param scene The scene to use the layer in
  63185. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63186. */
  63187. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63188. /**
  63189. * Get the effect name of the layer.
  63190. * @return The effect name
  63191. */
  63192. getEffectName(): string;
  63193. /**
  63194. * Create the merge effect. This is the shader use to blit the information back
  63195. * to the main canvas at the end of the scene rendering.
  63196. */
  63197. protected _createMergeEffect(): Effect;
  63198. /**
  63199. * Creates the render target textures and post processes used in the glow layer.
  63200. */
  63201. protected _createTextureAndPostProcesses(): void;
  63202. /**
  63203. * Checks for the readiness of the element composing the layer.
  63204. * @param subMesh the mesh to check for
  63205. * @param useInstances specify wether or not to use instances to render the mesh
  63206. * @param emissiveTexture the associated emissive texture used to generate the glow
  63207. * @return true if ready otherwise, false
  63208. */
  63209. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63210. /**
  63211. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63212. */
  63213. needStencil(): boolean;
  63214. /**
  63215. * Returns true if the mesh can be rendered, otherwise false.
  63216. * @param mesh The mesh to render
  63217. * @param material The material used on the mesh
  63218. * @returns true if it can be rendered otherwise false
  63219. */
  63220. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63221. /**
  63222. * Implementation specific of rendering the generating effect on the main canvas.
  63223. * @param effect The effect used to render through
  63224. */
  63225. protected _internalRender(effect: Effect): void;
  63226. /**
  63227. * Sets the required values for both the emissive texture and and the main color.
  63228. */
  63229. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63230. /**
  63231. * Returns true if the mesh should render, otherwise false.
  63232. * @param mesh The mesh to render
  63233. * @returns true if it should render otherwise false
  63234. */
  63235. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63236. /**
  63237. * Adds specific effects defines.
  63238. * @param defines The defines to add specifics to.
  63239. */
  63240. protected _addCustomEffectDefines(defines: string[]): void;
  63241. /**
  63242. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63243. * @param mesh The mesh to exclude from the glow layer
  63244. */
  63245. addExcludedMesh(mesh: Mesh): void;
  63246. /**
  63247. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63248. * @param mesh The mesh to remove
  63249. */
  63250. removeExcludedMesh(mesh: Mesh): void;
  63251. /**
  63252. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63253. * @param mesh The mesh to include in the glow layer
  63254. */
  63255. addIncludedOnlyMesh(mesh: Mesh): void;
  63256. /**
  63257. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63258. * @param mesh The mesh to remove
  63259. */
  63260. removeIncludedOnlyMesh(mesh: Mesh): void;
  63261. /**
  63262. * Determine if a given mesh will be used in the glow layer
  63263. * @param mesh The mesh to test
  63264. * @returns true if the mesh will be highlighted by the current glow layer
  63265. */
  63266. hasMesh(mesh: AbstractMesh): boolean;
  63267. /**
  63268. * Defines whether the current material of the mesh should be use to render the effect.
  63269. * @param mesh defines the current mesh to render
  63270. */
  63271. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63272. /**
  63273. * Add a mesh to be rendered through its own material and not with emissive only.
  63274. * @param mesh The mesh for which we need to use its material
  63275. */
  63276. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63277. /**
  63278. * Remove a mesh from being rendered through its own material and not with emissive only.
  63279. * @param mesh The mesh for which we need to not use its material
  63280. */
  63281. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63282. /**
  63283. * Free any resources and references associated to a mesh.
  63284. * Internal use
  63285. * @param mesh The mesh to free.
  63286. * @hidden
  63287. */
  63288. _disposeMesh(mesh: Mesh): void;
  63289. /**
  63290. * Gets the class name of the effect layer
  63291. * @returns the string with the class name of the effect layer
  63292. */
  63293. getClassName(): string;
  63294. /**
  63295. * Serializes this glow layer
  63296. * @returns a serialized glow layer object
  63297. */
  63298. serialize(): any;
  63299. /**
  63300. * Creates a Glow Layer from parsed glow layer data
  63301. * @param parsedGlowLayer defines glow layer data
  63302. * @param scene defines the current scene
  63303. * @param rootUrl defines the root URL containing the glow layer information
  63304. * @returns a parsed Glow Layer
  63305. */
  63306. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63307. }
  63308. }
  63309. declare module BABYLON {
  63310. /** @hidden */
  63311. export var glowBlurPostProcessPixelShader: {
  63312. name: string;
  63313. shader: string;
  63314. };
  63315. }
  63316. declare module BABYLON {
  63317. interface AbstractScene {
  63318. /**
  63319. * Return a the first highlight layer of the scene with a given name.
  63320. * @param name The name of the highlight layer to look for.
  63321. * @return The highlight layer if found otherwise null.
  63322. */
  63323. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63324. }
  63325. /**
  63326. * Highlight layer options. This helps customizing the behaviour
  63327. * of the highlight layer.
  63328. */
  63329. export interface IHighlightLayerOptions {
  63330. /**
  63331. * Multiplication factor apply to the canvas size to compute the render target size
  63332. * used to generated the glowing objects (the smaller the faster).
  63333. */
  63334. mainTextureRatio: number;
  63335. /**
  63336. * Enforces a fixed size texture to ensure resize independant blur.
  63337. */
  63338. mainTextureFixedSize?: number;
  63339. /**
  63340. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63341. * of the picture to blur (the smaller the faster).
  63342. */
  63343. blurTextureSizeRatio: number;
  63344. /**
  63345. * How big in texel of the blur texture is the vertical blur.
  63346. */
  63347. blurVerticalSize: number;
  63348. /**
  63349. * How big in texel of the blur texture is the horizontal blur.
  63350. */
  63351. blurHorizontalSize: number;
  63352. /**
  63353. * Alpha blending mode used to apply the blur. Default is combine.
  63354. */
  63355. alphaBlendingMode: number;
  63356. /**
  63357. * The camera attached to the layer.
  63358. */
  63359. camera: Nullable<Camera>;
  63360. /**
  63361. * Should we display highlight as a solid stroke?
  63362. */
  63363. isStroke?: boolean;
  63364. /**
  63365. * The rendering group to draw the layer in.
  63366. */
  63367. renderingGroupId: number;
  63368. }
  63369. /**
  63370. * The highlight layer Helps adding a glow effect around a mesh.
  63371. *
  63372. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63373. * glowy meshes to your scene.
  63374. *
  63375. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63376. */
  63377. export class HighlightLayer extends EffectLayer {
  63378. name: string;
  63379. /**
  63380. * Effect Name of the highlight layer.
  63381. */
  63382. static readonly EffectName: string;
  63383. /**
  63384. * The neutral color used during the preparation of the glow effect.
  63385. * This is black by default as the blend operation is a blend operation.
  63386. */
  63387. static NeutralColor: Color4;
  63388. /**
  63389. * Stencil value used for glowing meshes.
  63390. */
  63391. static GlowingMeshStencilReference: number;
  63392. /**
  63393. * Stencil value used for the other meshes in the scene.
  63394. */
  63395. static NormalMeshStencilReference: number;
  63396. /**
  63397. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63398. */
  63399. innerGlow: boolean;
  63400. /**
  63401. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63402. */
  63403. outerGlow: boolean;
  63404. /**
  63405. * Specifies the horizontal size of the blur.
  63406. */
  63407. set blurHorizontalSize(value: number);
  63408. /**
  63409. * Specifies the vertical size of the blur.
  63410. */
  63411. set blurVerticalSize(value: number);
  63412. /**
  63413. * Gets the horizontal size of the blur.
  63414. */
  63415. get blurHorizontalSize(): number;
  63416. /**
  63417. * Gets the vertical size of the blur.
  63418. */
  63419. get blurVerticalSize(): number;
  63420. /**
  63421. * An event triggered when the highlight layer is being blurred.
  63422. */
  63423. onBeforeBlurObservable: Observable<HighlightLayer>;
  63424. /**
  63425. * An event triggered when the highlight layer has been blurred.
  63426. */
  63427. onAfterBlurObservable: Observable<HighlightLayer>;
  63428. private _instanceGlowingMeshStencilReference;
  63429. private _options;
  63430. private _downSamplePostprocess;
  63431. private _horizontalBlurPostprocess;
  63432. private _verticalBlurPostprocess;
  63433. private _blurTexture;
  63434. private _meshes;
  63435. private _excludedMeshes;
  63436. /**
  63437. * Instantiates a new highlight Layer and references it to the scene..
  63438. * @param name The name of the layer
  63439. * @param scene The scene to use the layer in
  63440. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63441. */
  63442. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63443. /**
  63444. * Get the effect name of the layer.
  63445. * @return The effect name
  63446. */
  63447. getEffectName(): string;
  63448. /**
  63449. * Create the merge effect. This is the shader use to blit the information back
  63450. * to the main canvas at the end of the scene rendering.
  63451. */
  63452. protected _createMergeEffect(): Effect;
  63453. /**
  63454. * Creates the render target textures and post processes used in the highlight layer.
  63455. */
  63456. protected _createTextureAndPostProcesses(): void;
  63457. /**
  63458. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63459. */
  63460. needStencil(): boolean;
  63461. /**
  63462. * Checks for the readiness of the element composing the layer.
  63463. * @param subMesh the mesh to check for
  63464. * @param useInstances specify wether or not to use instances to render the mesh
  63465. * @param emissiveTexture the associated emissive texture used to generate the glow
  63466. * @return true if ready otherwise, false
  63467. */
  63468. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63469. /**
  63470. * Implementation specific of rendering the generating effect on the main canvas.
  63471. * @param effect The effect used to render through
  63472. */
  63473. protected _internalRender(effect: Effect): void;
  63474. /**
  63475. * Returns true if the layer contains information to display, otherwise false.
  63476. */
  63477. shouldRender(): boolean;
  63478. /**
  63479. * Returns true if the mesh should render, otherwise false.
  63480. * @param mesh The mesh to render
  63481. * @returns true if it should render otherwise false
  63482. */
  63483. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63484. /**
  63485. * Returns true if the mesh can be rendered, otherwise false.
  63486. * @param mesh The mesh to render
  63487. * @param material The material used on the mesh
  63488. * @returns true if it can be rendered otherwise false
  63489. */
  63490. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63491. /**
  63492. * Adds specific effects defines.
  63493. * @param defines The defines to add specifics to.
  63494. */
  63495. protected _addCustomEffectDefines(defines: string[]): void;
  63496. /**
  63497. * Sets the required values for both the emissive texture and and the main color.
  63498. */
  63499. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63500. /**
  63501. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63502. * @param mesh The mesh to exclude from the highlight layer
  63503. */
  63504. addExcludedMesh(mesh: Mesh): void;
  63505. /**
  63506. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63507. * @param mesh The mesh to highlight
  63508. */
  63509. removeExcludedMesh(mesh: Mesh): void;
  63510. /**
  63511. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63512. * @param mesh mesh to test
  63513. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63514. */
  63515. hasMesh(mesh: AbstractMesh): boolean;
  63516. /**
  63517. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63518. * @param mesh The mesh to highlight
  63519. * @param color The color of the highlight
  63520. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63521. */
  63522. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63523. /**
  63524. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63525. * @param mesh The mesh to highlight
  63526. */
  63527. removeMesh(mesh: Mesh): void;
  63528. /**
  63529. * Remove all the meshes currently referenced in the highlight layer
  63530. */
  63531. removeAllMeshes(): void;
  63532. /**
  63533. * Force the stencil to the normal expected value for none glowing parts
  63534. */
  63535. private _defaultStencilReference;
  63536. /**
  63537. * Free any resources and references associated to a mesh.
  63538. * Internal use
  63539. * @param mesh The mesh to free.
  63540. * @hidden
  63541. */
  63542. _disposeMesh(mesh: Mesh): void;
  63543. /**
  63544. * Dispose the highlight layer and free resources.
  63545. */
  63546. dispose(): void;
  63547. /**
  63548. * Gets the class name of the effect layer
  63549. * @returns the string with the class name of the effect layer
  63550. */
  63551. getClassName(): string;
  63552. /**
  63553. * Serializes this Highlight layer
  63554. * @returns a serialized Highlight layer object
  63555. */
  63556. serialize(): any;
  63557. /**
  63558. * Creates a Highlight layer from parsed Highlight layer data
  63559. * @param parsedHightlightLayer defines the Highlight layer data
  63560. * @param scene defines the current scene
  63561. * @param rootUrl defines the root URL containing the Highlight layer information
  63562. * @returns a parsed Highlight layer
  63563. */
  63564. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63565. }
  63566. }
  63567. declare module BABYLON {
  63568. interface AbstractScene {
  63569. /**
  63570. * The list of layers (background and foreground) of the scene
  63571. */
  63572. layers: Array<Layer>;
  63573. }
  63574. /**
  63575. * Defines the layer scene component responsible to manage any layers
  63576. * in a given scene.
  63577. */
  63578. export class LayerSceneComponent implements ISceneComponent {
  63579. /**
  63580. * The component name helpfull to identify the component in the list of scene components.
  63581. */
  63582. readonly name: string;
  63583. /**
  63584. * The scene the component belongs to.
  63585. */
  63586. scene: Scene;
  63587. private _engine;
  63588. /**
  63589. * Creates a new instance of the component for the given scene
  63590. * @param scene Defines the scene to register the component in
  63591. */
  63592. constructor(scene: Scene);
  63593. /**
  63594. * Registers the component in a given scene
  63595. */
  63596. register(): void;
  63597. /**
  63598. * Rebuilds the elements related to this component in case of
  63599. * context lost for instance.
  63600. */
  63601. rebuild(): void;
  63602. /**
  63603. * Disposes the component and the associated ressources.
  63604. */
  63605. dispose(): void;
  63606. private _draw;
  63607. private _drawCameraPredicate;
  63608. private _drawCameraBackground;
  63609. private _drawCameraForeground;
  63610. private _drawRenderTargetPredicate;
  63611. private _drawRenderTargetBackground;
  63612. private _drawRenderTargetForeground;
  63613. /**
  63614. * Adds all the elements from the container to the scene
  63615. * @param container the container holding the elements
  63616. */
  63617. addFromContainer(container: AbstractScene): void;
  63618. /**
  63619. * Removes all the elements in the container from the scene
  63620. * @param container contains the elements to remove
  63621. * @param dispose if the removed element should be disposed (default: false)
  63622. */
  63623. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63624. }
  63625. }
  63626. declare module BABYLON {
  63627. /** @hidden */
  63628. export var layerPixelShader: {
  63629. name: string;
  63630. shader: string;
  63631. };
  63632. }
  63633. declare module BABYLON {
  63634. /** @hidden */
  63635. export var layerVertexShader: {
  63636. name: string;
  63637. shader: string;
  63638. };
  63639. }
  63640. declare module BABYLON {
  63641. /**
  63642. * This represents a full screen 2d layer.
  63643. * This can be useful to display a picture in the background of your scene for instance.
  63644. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63645. */
  63646. export class Layer {
  63647. /**
  63648. * Define the name of the layer.
  63649. */
  63650. name: string;
  63651. /**
  63652. * Define the texture the layer should display.
  63653. */
  63654. texture: Nullable<Texture>;
  63655. /**
  63656. * Is the layer in background or foreground.
  63657. */
  63658. isBackground: boolean;
  63659. /**
  63660. * Define the color of the layer (instead of texture).
  63661. */
  63662. color: Color4;
  63663. /**
  63664. * Define the scale of the layer in order to zoom in out of the texture.
  63665. */
  63666. scale: Vector2;
  63667. /**
  63668. * Define an offset for the layer in order to shift the texture.
  63669. */
  63670. offset: Vector2;
  63671. /**
  63672. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63673. */
  63674. alphaBlendingMode: number;
  63675. /**
  63676. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63677. * Alpha test will not mix with the background color in case of transparency.
  63678. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63679. */
  63680. alphaTest: boolean;
  63681. /**
  63682. * Define a mask to restrict the layer to only some of the scene cameras.
  63683. */
  63684. layerMask: number;
  63685. /**
  63686. * Define the list of render target the layer is visible into.
  63687. */
  63688. renderTargetTextures: RenderTargetTexture[];
  63689. /**
  63690. * Define if the layer is only used in renderTarget or if it also
  63691. * renders in the main frame buffer of the canvas.
  63692. */
  63693. renderOnlyInRenderTargetTextures: boolean;
  63694. private _scene;
  63695. private _vertexBuffers;
  63696. private _indexBuffer;
  63697. private _effect;
  63698. private _previousDefines;
  63699. /**
  63700. * An event triggered when the layer is disposed.
  63701. */
  63702. onDisposeObservable: Observable<Layer>;
  63703. private _onDisposeObserver;
  63704. /**
  63705. * Back compatibility with callback before the onDisposeObservable existed.
  63706. * The set callback will be triggered when the layer has been disposed.
  63707. */
  63708. set onDispose(callback: () => void);
  63709. /**
  63710. * An event triggered before rendering the scene
  63711. */
  63712. onBeforeRenderObservable: Observable<Layer>;
  63713. private _onBeforeRenderObserver;
  63714. /**
  63715. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63716. * The set callback will be triggered just before rendering the layer.
  63717. */
  63718. set onBeforeRender(callback: () => void);
  63719. /**
  63720. * An event triggered after rendering the scene
  63721. */
  63722. onAfterRenderObservable: Observable<Layer>;
  63723. private _onAfterRenderObserver;
  63724. /**
  63725. * Back compatibility with callback before the onAfterRenderObservable existed.
  63726. * The set callback will be triggered just after rendering the layer.
  63727. */
  63728. set onAfterRender(callback: () => void);
  63729. /**
  63730. * Instantiates a new layer.
  63731. * This represents a full screen 2d layer.
  63732. * This can be useful to display a picture in the background of your scene for instance.
  63733. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63734. * @param name Define the name of the layer in the scene
  63735. * @param imgUrl Define the url of the texture to display in the layer
  63736. * @param scene Define the scene the layer belongs to
  63737. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63738. * @param color Defines a color for the layer
  63739. */
  63740. constructor(
  63741. /**
  63742. * Define the name of the layer.
  63743. */
  63744. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63745. private _createIndexBuffer;
  63746. /** @hidden */
  63747. _rebuild(): void;
  63748. /**
  63749. * Renders the layer in the scene.
  63750. */
  63751. render(): void;
  63752. /**
  63753. * Disposes and releases the associated ressources.
  63754. */
  63755. dispose(): void;
  63756. }
  63757. }
  63758. declare module BABYLON {
  63759. /** @hidden */
  63760. export var lensFlarePixelShader: {
  63761. name: string;
  63762. shader: string;
  63763. };
  63764. }
  63765. declare module BABYLON {
  63766. /** @hidden */
  63767. export var lensFlareVertexShader: {
  63768. name: string;
  63769. shader: string;
  63770. };
  63771. }
  63772. declare module BABYLON {
  63773. /**
  63774. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63775. * It is usually composed of several `lensFlare`.
  63776. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63777. */
  63778. export class LensFlareSystem {
  63779. /**
  63780. * Define the name of the lens flare system
  63781. */
  63782. name: string;
  63783. /**
  63784. * List of lens flares used in this system.
  63785. */
  63786. lensFlares: LensFlare[];
  63787. /**
  63788. * Define a limit from the border the lens flare can be visible.
  63789. */
  63790. borderLimit: number;
  63791. /**
  63792. * Define a viewport border we do not want to see the lens flare in.
  63793. */
  63794. viewportBorder: number;
  63795. /**
  63796. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63797. */
  63798. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63799. /**
  63800. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63801. */
  63802. layerMask: number;
  63803. /**
  63804. * Define the id of the lens flare system in the scene.
  63805. * (equal to name by default)
  63806. */
  63807. id: string;
  63808. private _scene;
  63809. private _emitter;
  63810. private _vertexBuffers;
  63811. private _indexBuffer;
  63812. private _effect;
  63813. private _positionX;
  63814. private _positionY;
  63815. private _isEnabled;
  63816. /** @hidden */
  63817. static _SceneComponentInitialization: (scene: Scene) => void;
  63818. /**
  63819. * Instantiates a lens flare system.
  63820. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63821. * It is usually composed of several `lensFlare`.
  63822. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63823. * @param name Define the name of the lens flare system in the scene
  63824. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63825. * @param scene Define the scene the lens flare system belongs to
  63826. */
  63827. constructor(
  63828. /**
  63829. * Define the name of the lens flare system
  63830. */
  63831. name: string, emitter: any, scene: Scene);
  63832. /**
  63833. * Define if the lens flare system is enabled.
  63834. */
  63835. get isEnabled(): boolean;
  63836. set isEnabled(value: boolean);
  63837. /**
  63838. * Get the scene the effects belongs to.
  63839. * @returns the scene holding the lens flare system
  63840. */
  63841. getScene(): Scene;
  63842. /**
  63843. * Get the emitter of the lens flare system.
  63844. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63845. * @returns the emitter of the lens flare system
  63846. */
  63847. getEmitter(): any;
  63848. /**
  63849. * Set the emitter of the lens flare system.
  63850. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63851. * @param newEmitter Define the new emitter of the system
  63852. */
  63853. setEmitter(newEmitter: any): void;
  63854. /**
  63855. * Get the lens flare system emitter position.
  63856. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63857. * @returns the position
  63858. */
  63859. getEmitterPosition(): Vector3;
  63860. /**
  63861. * @hidden
  63862. */
  63863. computeEffectivePosition(globalViewport: Viewport): boolean;
  63864. /** @hidden */
  63865. _isVisible(): boolean;
  63866. /**
  63867. * @hidden
  63868. */
  63869. render(): boolean;
  63870. /**
  63871. * Dispose and release the lens flare with its associated resources.
  63872. */
  63873. dispose(): void;
  63874. /**
  63875. * Parse a lens flare system from a JSON repressentation
  63876. * @param parsedLensFlareSystem Define the JSON to parse
  63877. * @param scene Define the scene the parsed system should be instantiated in
  63878. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63879. * @returns the parsed system
  63880. */
  63881. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63882. /**
  63883. * Serialize the current Lens Flare System into a JSON representation.
  63884. * @returns the serialized JSON
  63885. */
  63886. serialize(): any;
  63887. }
  63888. }
  63889. declare module BABYLON {
  63890. /**
  63891. * This represents one of the lens effect in a `lensFlareSystem`.
  63892. * It controls one of the indiviual texture used in the effect.
  63893. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63894. */
  63895. export class LensFlare {
  63896. /**
  63897. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63898. */
  63899. size: number;
  63900. /**
  63901. * 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.
  63902. */
  63903. position: number;
  63904. /**
  63905. * Define the lens color.
  63906. */
  63907. color: Color3;
  63908. /**
  63909. * Define the lens texture.
  63910. */
  63911. texture: Nullable<Texture>;
  63912. /**
  63913. * Define the alpha mode to render this particular lens.
  63914. */
  63915. alphaMode: number;
  63916. private _system;
  63917. /**
  63918. * Creates a new Lens Flare.
  63919. * This represents one of the lens effect in a `lensFlareSystem`.
  63920. * It controls one of the indiviual texture used in the effect.
  63921. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63922. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63923. * @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.
  63924. * @param color Define the lens color
  63925. * @param imgUrl Define the lens texture url
  63926. * @param system Define the `lensFlareSystem` this flare is part of
  63927. * @returns The newly created Lens Flare
  63928. */
  63929. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63930. /**
  63931. * Instantiates a new Lens Flare.
  63932. * This represents one of the lens effect in a `lensFlareSystem`.
  63933. * It controls one of the indiviual texture used in the effect.
  63934. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63935. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63936. * @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.
  63937. * @param color Define the lens color
  63938. * @param imgUrl Define the lens texture url
  63939. * @param system Define the `lensFlareSystem` this flare is part of
  63940. */
  63941. constructor(
  63942. /**
  63943. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63944. */
  63945. size: number,
  63946. /**
  63947. * 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.
  63948. */
  63949. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63950. /**
  63951. * Dispose and release the lens flare with its associated resources.
  63952. */
  63953. dispose(): void;
  63954. }
  63955. }
  63956. declare module BABYLON {
  63957. interface AbstractScene {
  63958. /**
  63959. * The list of lens flare system added to the scene
  63960. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63961. */
  63962. lensFlareSystems: Array<LensFlareSystem>;
  63963. /**
  63964. * Removes the given lens flare system from this scene.
  63965. * @param toRemove The lens flare system to remove
  63966. * @returns The index of the removed lens flare system
  63967. */
  63968. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63969. /**
  63970. * Adds the given lens flare system to this scene
  63971. * @param newLensFlareSystem The lens flare system to add
  63972. */
  63973. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63974. /**
  63975. * Gets a lens flare system using its name
  63976. * @param name defines the name to look for
  63977. * @returns the lens flare system or null if not found
  63978. */
  63979. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63980. /**
  63981. * Gets a lens flare system using its id
  63982. * @param id defines the id to look for
  63983. * @returns the lens flare system or null if not found
  63984. */
  63985. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63986. }
  63987. /**
  63988. * Defines the lens flare scene component responsible to manage any lens flares
  63989. * in a given scene.
  63990. */
  63991. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63992. /**
  63993. * The component name helpfull to identify the component in the list of scene components.
  63994. */
  63995. readonly name: string;
  63996. /**
  63997. * The scene the component belongs to.
  63998. */
  63999. scene: Scene;
  64000. /**
  64001. * Creates a new instance of the component for the given scene
  64002. * @param scene Defines the scene to register the component in
  64003. */
  64004. constructor(scene: Scene);
  64005. /**
  64006. * Registers the component in a given scene
  64007. */
  64008. register(): void;
  64009. /**
  64010. * Rebuilds the elements related to this component in case of
  64011. * context lost for instance.
  64012. */
  64013. rebuild(): void;
  64014. /**
  64015. * Adds all the elements from the container to the scene
  64016. * @param container the container holding the elements
  64017. */
  64018. addFromContainer(container: AbstractScene): void;
  64019. /**
  64020. * Removes all the elements in the container from the scene
  64021. * @param container contains the elements to remove
  64022. * @param dispose if the removed element should be disposed (default: false)
  64023. */
  64024. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64025. /**
  64026. * Serializes the component data to the specified json object
  64027. * @param serializationObject The object to serialize to
  64028. */
  64029. serialize(serializationObject: any): void;
  64030. /**
  64031. * Disposes the component and the associated ressources.
  64032. */
  64033. dispose(): void;
  64034. private _draw;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /** @hidden */
  64039. export var depthPixelShader: {
  64040. name: string;
  64041. shader: string;
  64042. };
  64043. }
  64044. declare module BABYLON {
  64045. /** @hidden */
  64046. export var depthVertexShader: {
  64047. name: string;
  64048. shader: string;
  64049. };
  64050. }
  64051. declare module BABYLON {
  64052. /**
  64053. * This represents a depth renderer in Babylon.
  64054. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64055. */
  64056. export class DepthRenderer {
  64057. private _scene;
  64058. private _depthMap;
  64059. private _effect;
  64060. private readonly _storeNonLinearDepth;
  64061. private readonly _clearColor;
  64062. /** Get if the depth renderer is using packed depth or not */
  64063. readonly isPacked: boolean;
  64064. private _cachedDefines;
  64065. private _camera;
  64066. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64067. enabled: boolean;
  64068. /**
  64069. * Specifiess that the depth renderer will only be used within
  64070. * the camera it is created for.
  64071. * This can help forcing its rendering during the camera processing.
  64072. */
  64073. useOnlyInActiveCamera: boolean;
  64074. /** @hidden */
  64075. static _SceneComponentInitialization: (scene: Scene) => void;
  64076. /**
  64077. * Instantiates a depth renderer
  64078. * @param scene The scene the renderer belongs to
  64079. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64080. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64081. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64082. */
  64083. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64084. /**
  64085. * Creates the depth rendering effect and checks if the effect is ready.
  64086. * @param subMesh The submesh to be used to render the depth map of
  64087. * @param useInstances If multiple world instances should be used
  64088. * @returns if the depth renderer is ready to render the depth map
  64089. */
  64090. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64091. /**
  64092. * Gets the texture which the depth map will be written to.
  64093. * @returns The depth map texture
  64094. */
  64095. getDepthMap(): RenderTargetTexture;
  64096. /**
  64097. * Disposes of the depth renderer.
  64098. */
  64099. dispose(): void;
  64100. }
  64101. }
  64102. declare module BABYLON {
  64103. /** @hidden */
  64104. export var minmaxReduxPixelShader: {
  64105. name: string;
  64106. shader: string;
  64107. };
  64108. }
  64109. declare module BABYLON {
  64110. /**
  64111. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64112. * and maximum values from all values of the texture.
  64113. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64114. * The source values are read from the red channel of the texture.
  64115. */
  64116. export class MinMaxReducer {
  64117. /**
  64118. * Observable triggered when the computation has been performed
  64119. */
  64120. onAfterReductionPerformed: Observable<{
  64121. min: number;
  64122. max: number;
  64123. }>;
  64124. protected _camera: Camera;
  64125. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64126. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64127. protected _postProcessManager: PostProcessManager;
  64128. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64129. protected _forceFullscreenViewport: boolean;
  64130. /**
  64131. * Creates a min/max reducer
  64132. * @param camera The camera to use for the post processes
  64133. */
  64134. constructor(camera: Camera);
  64135. /**
  64136. * Gets the texture used to read the values from.
  64137. */
  64138. get sourceTexture(): Nullable<RenderTargetTexture>;
  64139. /**
  64140. * Sets the source texture to read the values from.
  64141. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64142. * because in such textures '1' value must not be taken into account to compute the maximum
  64143. * as this value is used to clear the texture.
  64144. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64145. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64146. * @param depthRedux Indicates if the texture is a depth texture or not
  64147. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64148. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64149. */
  64150. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64151. /**
  64152. * Defines the refresh rate of the computation.
  64153. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64154. */
  64155. get refreshRate(): number;
  64156. set refreshRate(value: number);
  64157. protected _activated: boolean;
  64158. /**
  64159. * Gets the activation status of the reducer
  64160. */
  64161. get activated(): boolean;
  64162. /**
  64163. * Activates the reduction computation.
  64164. * When activated, the observers registered in onAfterReductionPerformed are
  64165. * called after the compuation is performed
  64166. */
  64167. activate(): void;
  64168. /**
  64169. * Deactivates the reduction computation.
  64170. */
  64171. deactivate(): void;
  64172. /**
  64173. * Disposes the min/max reducer
  64174. * @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.
  64175. */
  64176. dispose(disposeAll?: boolean): void;
  64177. }
  64178. }
  64179. declare module BABYLON {
  64180. /**
  64181. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64182. */
  64183. export class DepthReducer extends MinMaxReducer {
  64184. private _depthRenderer;
  64185. private _depthRendererId;
  64186. /**
  64187. * Gets the depth renderer used for the computation.
  64188. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64189. */
  64190. get depthRenderer(): Nullable<DepthRenderer>;
  64191. /**
  64192. * Creates a depth reducer
  64193. * @param camera The camera used to render the depth texture
  64194. */
  64195. constructor(camera: Camera);
  64196. /**
  64197. * Sets the depth renderer to use to generate the depth map
  64198. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64199. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64200. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64201. */
  64202. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64203. /** @hidden */
  64204. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64205. /**
  64206. * Activates the reduction computation.
  64207. * When activated, the observers registered in onAfterReductionPerformed are
  64208. * called after the compuation is performed
  64209. */
  64210. activate(): void;
  64211. /**
  64212. * Deactivates the reduction computation.
  64213. */
  64214. deactivate(): void;
  64215. /**
  64216. * Disposes the depth reducer
  64217. * @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.
  64218. */
  64219. dispose(disposeAll?: boolean): void;
  64220. }
  64221. }
  64222. declare module BABYLON {
  64223. /**
  64224. * A CSM implementation allowing casting shadows on large scenes.
  64225. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64226. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64227. */
  64228. export class CascadedShadowGenerator extends ShadowGenerator {
  64229. private static readonly frustumCornersNDCSpace;
  64230. /**
  64231. * Name of the CSM class
  64232. */
  64233. static CLASSNAME: string;
  64234. /**
  64235. * Defines the default number of cascades used by the CSM.
  64236. */
  64237. static readonly DEFAULT_CASCADES_COUNT: number;
  64238. /**
  64239. * Defines the minimum number of cascades used by the CSM.
  64240. */
  64241. static readonly MIN_CASCADES_COUNT: number;
  64242. /**
  64243. * Defines the maximum number of cascades used by the CSM.
  64244. */
  64245. static readonly MAX_CASCADES_COUNT: number;
  64246. protected _validateFilter(filter: number): number;
  64247. /**
  64248. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64249. */
  64250. penumbraDarkness: number;
  64251. private _numCascades;
  64252. /**
  64253. * Gets or set the number of cascades used by the CSM.
  64254. */
  64255. get numCascades(): number;
  64256. set numCascades(value: number);
  64257. /**
  64258. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64259. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64260. */
  64261. stabilizeCascades: boolean;
  64262. private _freezeShadowCastersBoundingInfo;
  64263. private _freezeShadowCastersBoundingInfoObservable;
  64264. /**
  64265. * Enables or disables the shadow casters bounding info computation.
  64266. * If your shadow casters don't move, you can disable this feature.
  64267. * If it is enabled, the bounding box computation is done every frame.
  64268. */
  64269. get freezeShadowCastersBoundingInfo(): boolean;
  64270. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64271. private _scbiMin;
  64272. private _scbiMax;
  64273. protected _computeShadowCastersBoundingInfo(): void;
  64274. protected _shadowCastersBoundingInfo: BoundingInfo;
  64275. /**
  64276. * Gets or sets the shadow casters bounding info.
  64277. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64278. * so that the system won't overwrite the bounds you provide
  64279. */
  64280. get shadowCastersBoundingInfo(): BoundingInfo;
  64281. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64282. protected _breaksAreDirty: boolean;
  64283. protected _minDistance: number;
  64284. protected _maxDistance: number;
  64285. /**
  64286. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64287. *
  64288. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64289. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64290. * @param min minimal distance for the breaks (default to 0.)
  64291. * @param max maximal distance for the breaks (default to 1.)
  64292. */
  64293. setMinMaxDistance(min: number, max: number): void;
  64294. /** Gets the minimal distance used in the cascade break computation */
  64295. get minDistance(): number;
  64296. /** Gets the maximal distance used in the cascade break computation */
  64297. get maxDistance(): number;
  64298. /**
  64299. * Gets the class name of that object
  64300. * @returns "CascadedShadowGenerator"
  64301. */
  64302. getClassName(): string;
  64303. private _cascadeMinExtents;
  64304. private _cascadeMaxExtents;
  64305. /**
  64306. * Gets a cascade minimum extents
  64307. * @param cascadeIndex index of the cascade
  64308. * @returns the minimum cascade extents
  64309. */
  64310. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64311. /**
  64312. * Gets a cascade maximum extents
  64313. * @param cascadeIndex index of the cascade
  64314. * @returns the maximum cascade extents
  64315. */
  64316. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64317. private _cascades;
  64318. private _currentLayer;
  64319. private _viewSpaceFrustumsZ;
  64320. private _viewMatrices;
  64321. private _projectionMatrices;
  64322. private _transformMatrices;
  64323. private _transformMatricesAsArray;
  64324. private _frustumLengths;
  64325. private _lightSizeUVCorrection;
  64326. private _depthCorrection;
  64327. private _frustumCornersWorldSpace;
  64328. private _frustumCenter;
  64329. private _shadowCameraPos;
  64330. private _shadowMaxZ;
  64331. /**
  64332. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64333. * It defaults to camera.maxZ
  64334. */
  64335. get shadowMaxZ(): number;
  64336. /**
  64337. * Sets the shadow max z distance.
  64338. */
  64339. set shadowMaxZ(value: number);
  64340. protected _debug: boolean;
  64341. /**
  64342. * Gets or sets the debug flag.
  64343. * When enabled, the cascades are materialized by different colors on the screen.
  64344. */
  64345. get debug(): boolean;
  64346. set debug(dbg: boolean);
  64347. private _depthClamp;
  64348. /**
  64349. * Gets or sets the depth clamping value.
  64350. *
  64351. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64352. * to account for the shadow casters far away.
  64353. *
  64354. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64355. */
  64356. get depthClamp(): boolean;
  64357. set depthClamp(value: boolean);
  64358. private _cascadeBlendPercentage;
  64359. /**
  64360. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64361. * It defaults to 0.1 (10% blending).
  64362. */
  64363. get cascadeBlendPercentage(): number;
  64364. set cascadeBlendPercentage(value: number);
  64365. private _lambda;
  64366. /**
  64367. * Gets or set the lambda parameter.
  64368. * This parameter is used to split the camera frustum and create the cascades.
  64369. * 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.
  64370. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64371. */
  64372. get lambda(): number;
  64373. set lambda(value: number);
  64374. /**
  64375. * Gets the view matrix corresponding to a given cascade
  64376. * @param cascadeNum cascade to retrieve the view matrix from
  64377. * @returns the cascade view matrix
  64378. */
  64379. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64380. /**
  64381. * Gets the projection matrix corresponding to a given cascade
  64382. * @param cascadeNum cascade to retrieve the projection matrix from
  64383. * @returns the cascade projection matrix
  64384. */
  64385. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64386. /**
  64387. * Gets the transformation matrix corresponding to a given cascade
  64388. * @param cascadeNum cascade to retrieve the transformation matrix from
  64389. * @returns the cascade transformation matrix
  64390. */
  64391. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64392. private _depthRenderer;
  64393. /**
  64394. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64395. *
  64396. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64397. *
  64398. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64399. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64400. * @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
  64401. */
  64402. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64403. private _depthReducer;
  64404. private _autoCalcDepthBounds;
  64405. /**
  64406. * Gets or sets the autoCalcDepthBounds property.
  64407. *
  64408. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64409. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64410. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64411. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64412. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64413. */
  64414. get autoCalcDepthBounds(): boolean;
  64415. set autoCalcDepthBounds(value: boolean);
  64416. /**
  64417. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64418. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64419. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64420. * for setting the refresh rate on the renderer yourself!
  64421. */
  64422. get autoCalcDepthBoundsRefreshRate(): number;
  64423. set autoCalcDepthBoundsRefreshRate(value: number);
  64424. /**
  64425. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64426. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64427. * you change the camera near/far planes!
  64428. */
  64429. splitFrustum(): void;
  64430. private _splitFrustum;
  64431. private _computeMatrices;
  64432. private _computeFrustumInWorldSpace;
  64433. private _computeCascadeFrustum;
  64434. /**
  64435. * Support test.
  64436. */
  64437. static get IsSupported(): boolean;
  64438. /** @hidden */
  64439. static _SceneComponentInitialization: (scene: Scene) => void;
  64440. /**
  64441. * Creates a Cascaded Shadow Generator object.
  64442. * A ShadowGenerator is the required tool to use the shadows.
  64443. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64444. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64445. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64446. * @param light The directional light object generating the shadows.
  64447. * @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.
  64448. */
  64449. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64450. protected _initializeGenerator(): void;
  64451. protected _createTargetRenderTexture(): void;
  64452. protected _initializeShadowMap(): void;
  64453. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64454. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64455. /**
  64456. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64457. * @param defines Defines of the material we want to update
  64458. * @param lightIndex Index of the light in the enabled light list of the material
  64459. */
  64460. prepareDefines(defines: any, lightIndex: number): void;
  64461. /**
  64462. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64463. * defined in the generator but impacting the effect).
  64464. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64465. * @param effect The effect we are binfing the information for
  64466. */
  64467. bindShadowLight(lightIndex: string, effect: Effect): void;
  64468. /**
  64469. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64470. * (eq to view projection * shadow projection matrices)
  64471. * @returns The transform matrix used to create the shadow map
  64472. */
  64473. getTransformMatrix(): Matrix;
  64474. /**
  64475. * Disposes the ShadowGenerator.
  64476. * Returns nothing.
  64477. */
  64478. dispose(): void;
  64479. /**
  64480. * Serializes the shadow generator setup to a json object.
  64481. * @returns The serialized JSON object
  64482. */
  64483. serialize(): any;
  64484. /**
  64485. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64486. * @param parsedShadowGenerator The JSON object to parse
  64487. * @param scene The scene to create the shadow map for
  64488. * @returns The parsed shadow generator
  64489. */
  64490. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64491. }
  64492. }
  64493. declare module BABYLON {
  64494. /**
  64495. * Defines the shadow generator component responsible to manage any shadow generators
  64496. * in a given scene.
  64497. */
  64498. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64499. /**
  64500. * The component name helpfull to identify the component in the list of scene components.
  64501. */
  64502. readonly name: string;
  64503. /**
  64504. * The scene the component belongs to.
  64505. */
  64506. scene: Scene;
  64507. /**
  64508. * Creates a new instance of the component for the given scene
  64509. * @param scene Defines the scene to register the component in
  64510. */
  64511. constructor(scene: Scene);
  64512. /**
  64513. * Registers the component in a given scene
  64514. */
  64515. register(): void;
  64516. /**
  64517. * Rebuilds the elements related to this component in case of
  64518. * context lost for instance.
  64519. */
  64520. rebuild(): void;
  64521. /**
  64522. * Serializes the component data to the specified json object
  64523. * @param serializationObject The object to serialize to
  64524. */
  64525. serialize(serializationObject: any): void;
  64526. /**
  64527. * Adds all the elements from the container to the scene
  64528. * @param container the container holding the elements
  64529. */
  64530. addFromContainer(container: AbstractScene): void;
  64531. /**
  64532. * Removes all the elements in the container from the scene
  64533. * @param container contains the elements to remove
  64534. * @param dispose if the removed element should be disposed (default: false)
  64535. */
  64536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64537. /**
  64538. * Rebuilds the elements related to this component in case of
  64539. * context lost for instance.
  64540. */
  64541. dispose(): void;
  64542. private _gatherRenderTargets;
  64543. }
  64544. }
  64545. declare module BABYLON {
  64546. /**
  64547. * A point light is a light defined by an unique point in world space.
  64548. * The light is emitted in every direction from this point.
  64549. * A good example of a point light is a standard light bulb.
  64550. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64551. */
  64552. export class PointLight extends ShadowLight {
  64553. private _shadowAngle;
  64554. /**
  64555. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64556. * This specifies what angle the shadow will use to be created.
  64557. *
  64558. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64559. */
  64560. get shadowAngle(): number;
  64561. /**
  64562. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64563. * This specifies what angle the shadow will use to be created.
  64564. *
  64565. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64566. */
  64567. set shadowAngle(value: number);
  64568. /**
  64569. * Gets the direction if it has been set.
  64570. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64571. */
  64572. get direction(): Vector3;
  64573. /**
  64574. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64575. */
  64576. set direction(value: Vector3);
  64577. /**
  64578. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64579. * A PointLight emits the light in every direction.
  64580. * It can cast shadows.
  64581. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64582. * ```javascript
  64583. * var pointLight = new PointLight("pl", camera.position, scene);
  64584. * ```
  64585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64586. * @param name The light friendly name
  64587. * @param position The position of the point light in the scene
  64588. * @param scene The scene the lights belongs to
  64589. */
  64590. constructor(name: string, position: Vector3, scene: Scene);
  64591. /**
  64592. * Returns the string "PointLight"
  64593. * @returns the class name
  64594. */
  64595. getClassName(): string;
  64596. /**
  64597. * Returns the integer 0.
  64598. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64599. */
  64600. getTypeID(): number;
  64601. /**
  64602. * Specifies wether or not the shadowmap should be a cube texture.
  64603. * @returns true if the shadowmap needs to be a cube texture.
  64604. */
  64605. needCube(): boolean;
  64606. /**
  64607. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64608. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64609. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64610. */
  64611. getShadowDirection(faceIndex?: number): Vector3;
  64612. /**
  64613. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64614. * - fov = PI / 2
  64615. * - aspect ratio : 1.0
  64616. * - z-near and far equal to the active camera minZ and maxZ.
  64617. * Returns the PointLight.
  64618. */
  64619. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64620. protected _buildUniformLayout(): void;
  64621. /**
  64622. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64623. * @param effect The effect to update
  64624. * @param lightIndex The index of the light in the effect to update
  64625. * @returns The point light
  64626. */
  64627. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64628. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64629. /**
  64630. * Prepares the list of defines specific to the light type.
  64631. * @param defines the list of defines
  64632. * @param lightIndex defines the index of the light for the effect
  64633. */
  64634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64635. }
  64636. }
  64637. declare module BABYLON {
  64638. /**
  64639. * Header information of HDR texture files.
  64640. */
  64641. export interface HDRInfo {
  64642. /**
  64643. * The height of the texture in pixels.
  64644. */
  64645. height: number;
  64646. /**
  64647. * The width of the texture in pixels.
  64648. */
  64649. width: number;
  64650. /**
  64651. * The index of the beginning of the data in the binary file.
  64652. */
  64653. dataPosition: number;
  64654. }
  64655. /**
  64656. * This groups tools to convert HDR texture to native colors array.
  64657. */
  64658. export class HDRTools {
  64659. private static Ldexp;
  64660. private static Rgbe2float;
  64661. private static readStringLine;
  64662. /**
  64663. * Reads header information from an RGBE texture stored in a native array.
  64664. * More information on this format are available here:
  64665. * https://en.wikipedia.org/wiki/RGBE_image_format
  64666. *
  64667. * @param uint8array The binary file stored in native array.
  64668. * @return The header information.
  64669. */
  64670. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64671. /**
  64672. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64673. * This RGBE texture needs to store the information as a panorama.
  64674. *
  64675. * More information on this format are available here:
  64676. * https://en.wikipedia.org/wiki/RGBE_image_format
  64677. *
  64678. * @param buffer The binary file stored in an array buffer.
  64679. * @param size The expected size of the extracted cubemap.
  64680. * @return The Cube Map information.
  64681. */
  64682. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64683. /**
  64684. * Returns the pixels data extracted from an RGBE texture.
  64685. * This pixels will be stored left to right up to down in the R G B order in one array.
  64686. *
  64687. * More information on this format are available here:
  64688. * https://en.wikipedia.org/wiki/RGBE_image_format
  64689. *
  64690. * @param uint8array The binary file stored in an array buffer.
  64691. * @param hdrInfo The header information of the file.
  64692. * @return The pixels data in RGB right to left up to down order.
  64693. */
  64694. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64695. private static RGBE_ReadPixels_RLE;
  64696. private static RGBE_ReadPixels_NOT_RLE;
  64697. }
  64698. }
  64699. declare module BABYLON {
  64700. /**
  64701. * Effect Render Options
  64702. */
  64703. export interface IEffectRendererOptions {
  64704. /**
  64705. * Defines the vertices positions.
  64706. */
  64707. positions?: number[];
  64708. /**
  64709. * Defines the indices.
  64710. */
  64711. indices?: number[];
  64712. }
  64713. /**
  64714. * Helper class to render one or more effects.
  64715. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64716. */
  64717. export class EffectRenderer {
  64718. private engine;
  64719. private static _DefaultOptions;
  64720. private _vertexBuffers;
  64721. private _indexBuffer;
  64722. private _fullscreenViewport;
  64723. /**
  64724. * Creates an effect renderer
  64725. * @param engine the engine to use for rendering
  64726. * @param options defines the options of the effect renderer
  64727. */
  64728. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64729. /**
  64730. * Sets the current viewport in normalized coordinates 0-1
  64731. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64732. */
  64733. setViewport(viewport?: Viewport): void;
  64734. /**
  64735. * Binds the embedded attributes buffer to the effect.
  64736. * @param effect Defines the effect to bind the attributes for
  64737. */
  64738. bindBuffers(effect: Effect): void;
  64739. /**
  64740. * Sets the current effect wrapper to use during draw.
  64741. * The effect needs to be ready before calling this api.
  64742. * This also sets the default full screen position attribute.
  64743. * @param effectWrapper Defines the effect to draw with
  64744. */
  64745. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64746. /**
  64747. * Restores engine states
  64748. */
  64749. restoreStates(): void;
  64750. /**
  64751. * Draws a full screen quad.
  64752. */
  64753. draw(): void;
  64754. private isRenderTargetTexture;
  64755. /**
  64756. * renders one or more effects to a specified texture
  64757. * @param effectWrapper the effect to renderer
  64758. * @param outputTexture texture to draw to, if null it will render to the screen.
  64759. */
  64760. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64761. /**
  64762. * Disposes of the effect renderer
  64763. */
  64764. dispose(): void;
  64765. }
  64766. /**
  64767. * Options to create an EffectWrapper
  64768. */
  64769. interface EffectWrapperCreationOptions {
  64770. /**
  64771. * Engine to use to create the effect
  64772. */
  64773. engine: ThinEngine;
  64774. /**
  64775. * Fragment shader for the effect
  64776. */
  64777. fragmentShader: string;
  64778. /**
  64779. * Use the shader store instead of direct source code
  64780. */
  64781. useShaderStore?: boolean;
  64782. /**
  64783. * Vertex shader for the effect
  64784. */
  64785. vertexShader?: string;
  64786. /**
  64787. * Attributes to use in the shader
  64788. */
  64789. attributeNames?: Array<string>;
  64790. /**
  64791. * Uniforms to use in the shader
  64792. */
  64793. uniformNames?: Array<string>;
  64794. /**
  64795. * Texture sampler names to use in the shader
  64796. */
  64797. samplerNames?: Array<string>;
  64798. /**
  64799. * Defines to use in the shader
  64800. */
  64801. defines?: Array<string>;
  64802. /**
  64803. * Callback when effect is compiled
  64804. */
  64805. onCompiled?: Nullable<(effect: Effect) => void>;
  64806. /**
  64807. * The friendly name of the effect displayed in Spector.
  64808. */
  64809. name?: string;
  64810. }
  64811. /**
  64812. * Wraps an effect to be used for rendering
  64813. */
  64814. export class EffectWrapper {
  64815. /**
  64816. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64817. */
  64818. onApplyObservable: Observable<{}>;
  64819. /**
  64820. * The underlying effect
  64821. */
  64822. effect: Effect;
  64823. /**
  64824. * Creates an effect to be renderer
  64825. * @param creationOptions options to create the effect
  64826. */
  64827. constructor(creationOptions: EffectWrapperCreationOptions);
  64828. /**
  64829. * Disposes of the effect wrapper
  64830. */
  64831. dispose(): void;
  64832. }
  64833. }
  64834. declare module BABYLON {
  64835. /** @hidden */
  64836. export var hdrFilteringVertexShader: {
  64837. name: string;
  64838. shader: string;
  64839. };
  64840. }
  64841. declare module BABYLON {
  64842. /** @hidden */
  64843. export var hdrFilteringPixelShader: {
  64844. name: string;
  64845. shader: string;
  64846. };
  64847. }
  64848. declare module BABYLON {
  64849. /**
  64850. * Options for texture filtering
  64851. */
  64852. interface IHDRFilteringOptions {
  64853. /**
  64854. * Scales pixel intensity for the input HDR map.
  64855. */
  64856. hdrScale?: number;
  64857. /**
  64858. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64859. */
  64860. quality?: number;
  64861. }
  64862. /**
  64863. * Filters HDR maps to get correct renderings of PBR reflections
  64864. */
  64865. export class HDRFiltering {
  64866. private _engine;
  64867. private _effectRenderer;
  64868. private _effectWrapper;
  64869. private _lodGenerationOffset;
  64870. private _lodGenerationScale;
  64871. /**
  64872. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64873. * you care about baking speed.
  64874. */
  64875. quality: number;
  64876. /**
  64877. * Scales pixel intensity for the input HDR map.
  64878. */
  64879. hdrScale: number;
  64880. /**
  64881. * Instantiates HDR filter for reflection maps
  64882. *
  64883. * @param engine Thin engine
  64884. * @param options Options
  64885. */
  64886. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64887. private _createRenderTarget;
  64888. private _prefilterInternal;
  64889. private _createEffect;
  64890. /**
  64891. * Get a value indicating if the filter is ready to be used
  64892. * @param texture Texture to filter
  64893. * @returns true if the filter is ready
  64894. */
  64895. isReady(texture: BaseTexture): boolean;
  64896. /**
  64897. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64898. * Prefiltering will be invoked at the end of next rendering pass.
  64899. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64900. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64901. * @param texture Texture to filter
  64902. * @param onFinished Callback when filtering is done
  64903. * @return Promise called when prefiltering is done
  64904. */
  64905. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64906. }
  64907. }
  64908. declare module BABYLON {
  64909. /**
  64910. * This represents a texture coming from an HDR input.
  64911. *
  64912. * The only supported format is currently panorama picture stored in RGBE format.
  64913. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64914. */
  64915. export class HDRCubeTexture extends BaseTexture {
  64916. private static _facesMapping;
  64917. private _generateHarmonics;
  64918. private _noMipmap;
  64919. private _prefilterOnLoad;
  64920. private _textureMatrix;
  64921. private _size;
  64922. private _onLoad;
  64923. private _onError;
  64924. /**
  64925. * The texture URL.
  64926. */
  64927. url: string;
  64928. protected _isBlocking: boolean;
  64929. /**
  64930. * Sets wether or not the texture is blocking during loading.
  64931. */
  64932. set isBlocking(value: boolean);
  64933. /**
  64934. * Gets wether or not the texture is blocking during loading.
  64935. */
  64936. get isBlocking(): boolean;
  64937. protected _rotationY: number;
  64938. /**
  64939. * Sets texture matrix rotation angle around Y axis in radians.
  64940. */
  64941. set rotationY(value: number);
  64942. /**
  64943. * Gets texture matrix rotation angle around Y axis radians.
  64944. */
  64945. get rotationY(): number;
  64946. /**
  64947. * Gets or sets the center of the bounding box associated with the cube texture
  64948. * It must define where the camera used to render the texture was set
  64949. */
  64950. boundingBoxPosition: Vector3;
  64951. private _boundingBoxSize;
  64952. /**
  64953. * Gets or sets the size of the bounding box associated with the cube texture
  64954. * When defined, the cubemap will switch to local mode
  64955. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64956. * @example https://www.babylonjs-playground.com/#RNASML
  64957. */
  64958. set boundingBoxSize(value: Vector3);
  64959. get boundingBoxSize(): Vector3;
  64960. /**
  64961. * Instantiates an HDRTexture from the following parameters.
  64962. *
  64963. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64964. * @param sceneOrEngine The scene or engine the texture will be used in
  64965. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64966. * @param noMipmap Forces to not generate the mipmap if true
  64967. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64968. * @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)
  64969. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64970. */
  64971. 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>);
  64972. /**
  64973. * Get the current class name of the texture useful for serialization or dynamic coding.
  64974. * @returns "HDRCubeTexture"
  64975. */
  64976. getClassName(): string;
  64977. /**
  64978. * Occurs when the file is raw .hdr file.
  64979. */
  64980. private loadTexture;
  64981. clone(): HDRCubeTexture;
  64982. delayLoad(): void;
  64983. /**
  64984. * Get the texture reflection matrix used to rotate/transform the reflection.
  64985. * @returns the reflection matrix
  64986. */
  64987. getReflectionTextureMatrix(): Matrix;
  64988. /**
  64989. * Set the texture reflection matrix used to rotate/transform the reflection.
  64990. * @param value Define the reflection matrix to set
  64991. */
  64992. setReflectionTextureMatrix(value: Matrix): void;
  64993. /**
  64994. * Parses a JSON representation of an HDR Texture in order to create the texture
  64995. * @param parsedTexture Define the JSON representation
  64996. * @param scene Define the scene the texture should be created in
  64997. * @param rootUrl Define the root url in case we need to load relative dependencies
  64998. * @returns the newly created texture after parsing
  64999. */
  65000. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65001. serialize(): any;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * Class used to control physics engine
  65007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65008. */
  65009. export class PhysicsEngine implements IPhysicsEngine {
  65010. private _physicsPlugin;
  65011. /**
  65012. * Global value used to control the smallest number supported by the simulation
  65013. */
  65014. static Epsilon: number;
  65015. private _impostors;
  65016. private _joints;
  65017. private _subTimeStep;
  65018. /**
  65019. * Gets the gravity vector used by the simulation
  65020. */
  65021. gravity: Vector3;
  65022. /**
  65023. * Factory used to create the default physics plugin.
  65024. * @returns The default physics plugin
  65025. */
  65026. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65027. /**
  65028. * Creates a new Physics Engine
  65029. * @param gravity defines the gravity vector used by the simulation
  65030. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65031. */
  65032. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65033. /**
  65034. * Sets the gravity vector used by the simulation
  65035. * @param gravity defines the gravity vector to use
  65036. */
  65037. setGravity(gravity: Vector3): void;
  65038. /**
  65039. * Set the time step of the physics engine.
  65040. * Default is 1/60.
  65041. * To slow it down, enter 1/600 for example.
  65042. * To speed it up, 1/30
  65043. * @param newTimeStep defines the new timestep to apply to this world.
  65044. */
  65045. setTimeStep(newTimeStep?: number): void;
  65046. /**
  65047. * Get the time step of the physics engine.
  65048. * @returns the current time step
  65049. */
  65050. getTimeStep(): number;
  65051. /**
  65052. * Set the sub time step of the physics engine.
  65053. * Default is 0 meaning there is no sub steps
  65054. * To increase physics resolution precision, set a small value (like 1 ms)
  65055. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65056. */
  65057. setSubTimeStep(subTimeStep?: number): void;
  65058. /**
  65059. * Get the sub time step of the physics engine.
  65060. * @returns the current sub time step
  65061. */
  65062. getSubTimeStep(): number;
  65063. /**
  65064. * Release all resources
  65065. */
  65066. dispose(): void;
  65067. /**
  65068. * Gets the name of the current physics plugin
  65069. * @returns the name of the plugin
  65070. */
  65071. getPhysicsPluginName(): string;
  65072. /**
  65073. * Adding a new impostor for the impostor tracking.
  65074. * This will be done by the impostor itself.
  65075. * @param impostor the impostor to add
  65076. */
  65077. addImpostor(impostor: PhysicsImpostor): void;
  65078. /**
  65079. * Remove an impostor from the engine.
  65080. * This impostor and its mesh will not longer be updated by the physics engine.
  65081. * @param impostor the impostor to remove
  65082. */
  65083. removeImpostor(impostor: PhysicsImpostor): void;
  65084. /**
  65085. * Add a joint to the physics engine
  65086. * @param mainImpostor defines the main impostor to which the joint is added.
  65087. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65088. * @param joint defines the joint that will connect both impostors.
  65089. */
  65090. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65091. /**
  65092. * Removes a joint from the simulation
  65093. * @param mainImpostor defines the impostor used with the joint
  65094. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65095. * @param joint defines the joint to remove
  65096. */
  65097. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65098. /**
  65099. * Called by the scene. No need to call it.
  65100. * @param delta defines the timespam between frames
  65101. */
  65102. _step(delta: number): void;
  65103. /**
  65104. * Gets the current plugin used to run the simulation
  65105. * @returns current plugin
  65106. */
  65107. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65108. /**
  65109. * Gets the list of physic impostors
  65110. * @returns an array of PhysicsImpostor
  65111. */
  65112. getImpostors(): Array<PhysicsImpostor>;
  65113. /**
  65114. * Gets the impostor for a physics enabled object
  65115. * @param object defines the object impersonated by the impostor
  65116. * @returns the PhysicsImpostor or null if not found
  65117. */
  65118. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65119. /**
  65120. * Gets the impostor for a physics body object
  65121. * @param body defines physics body used by the impostor
  65122. * @returns the PhysicsImpostor or null if not found
  65123. */
  65124. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65125. /**
  65126. * Does a raycast in the physics world
  65127. * @param from when should the ray start?
  65128. * @param to when should the ray end?
  65129. * @returns PhysicsRaycastResult
  65130. */
  65131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65132. }
  65133. }
  65134. declare module BABYLON {
  65135. /** @hidden */
  65136. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65137. private _useDeltaForWorldStep;
  65138. world: any;
  65139. name: string;
  65140. private _physicsMaterials;
  65141. private _fixedTimeStep;
  65142. private _cannonRaycastResult;
  65143. private _raycastResult;
  65144. private _physicsBodysToRemoveAfterStep;
  65145. private _firstFrame;
  65146. BJSCANNON: any;
  65147. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65148. setGravity(gravity: Vector3): void;
  65149. setTimeStep(timeStep: number): void;
  65150. getTimeStep(): number;
  65151. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65152. private _removeMarkedPhysicsBodiesFromWorld;
  65153. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65154. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65156. private _processChildMeshes;
  65157. removePhysicsBody(impostor: PhysicsImpostor): void;
  65158. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65159. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65160. private _addMaterial;
  65161. private _checkWithEpsilon;
  65162. private _createShape;
  65163. private _createHeightmap;
  65164. private _minus90X;
  65165. private _plus90X;
  65166. private _tmpPosition;
  65167. private _tmpDeltaPosition;
  65168. private _tmpUnityRotation;
  65169. private _updatePhysicsBodyTransformation;
  65170. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65171. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65172. isSupported(): boolean;
  65173. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65174. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65175. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65176. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65177. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65178. getBodyMass(impostor: PhysicsImpostor): number;
  65179. getBodyFriction(impostor: PhysicsImpostor): number;
  65180. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65181. getBodyRestitution(impostor: PhysicsImpostor): number;
  65182. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65183. sleepBody(impostor: PhysicsImpostor): void;
  65184. wakeUpBody(impostor: PhysicsImpostor): void;
  65185. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65186. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65187. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65188. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65189. getRadius(impostor: PhysicsImpostor): number;
  65190. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65191. dispose(): void;
  65192. private _extendNamespace;
  65193. /**
  65194. * Does a raycast in the physics world
  65195. * @param from when should the ray start?
  65196. * @param to when should the ray end?
  65197. * @returns PhysicsRaycastResult
  65198. */
  65199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65200. }
  65201. }
  65202. declare module BABYLON {
  65203. /** @hidden */
  65204. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65205. private _useDeltaForWorldStep;
  65206. world: any;
  65207. name: string;
  65208. BJSOIMO: any;
  65209. private _raycastResult;
  65210. private _fixedTimeStep;
  65211. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65212. setGravity(gravity: Vector3): void;
  65213. setTimeStep(timeStep: number): void;
  65214. getTimeStep(): number;
  65215. private _tmpImpostorsArray;
  65216. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65217. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65218. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65219. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65220. private _tmpPositionVector;
  65221. removePhysicsBody(impostor: PhysicsImpostor): void;
  65222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65224. isSupported(): boolean;
  65225. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65226. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65227. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65228. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65229. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65230. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65231. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65232. getBodyMass(impostor: PhysicsImpostor): number;
  65233. getBodyFriction(impostor: PhysicsImpostor): number;
  65234. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65235. getBodyRestitution(impostor: PhysicsImpostor): number;
  65236. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65237. sleepBody(impostor: PhysicsImpostor): void;
  65238. wakeUpBody(impostor: PhysicsImpostor): void;
  65239. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65240. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65241. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65242. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65243. getRadius(impostor: PhysicsImpostor): number;
  65244. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65245. dispose(): void;
  65246. /**
  65247. * Does a raycast in the physics world
  65248. * @param from when should the ray start?
  65249. * @param to when should the ray end?
  65250. * @returns PhysicsRaycastResult
  65251. */
  65252. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65253. }
  65254. }
  65255. declare module BABYLON {
  65256. /**
  65257. * AmmoJS Physics plugin
  65258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65259. * @see https://github.com/kripken/ammo.js/
  65260. */
  65261. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65262. private _useDeltaForWorldStep;
  65263. /**
  65264. * Reference to the Ammo library
  65265. */
  65266. bjsAMMO: any;
  65267. /**
  65268. * Created ammoJS world which physics bodies are added to
  65269. */
  65270. world: any;
  65271. /**
  65272. * Name of the plugin
  65273. */
  65274. name: string;
  65275. private _timeStep;
  65276. private _fixedTimeStep;
  65277. private _maxSteps;
  65278. private _tmpQuaternion;
  65279. private _tmpAmmoTransform;
  65280. private _tmpAmmoQuaternion;
  65281. private _tmpAmmoConcreteContactResultCallback;
  65282. private _collisionConfiguration;
  65283. private _dispatcher;
  65284. private _overlappingPairCache;
  65285. private _solver;
  65286. private _softBodySolver;
  65287. private _tmpAmmoVectorA;
  65288. private _tmpAmmoVectorB;
  65289. private _tmpAmmoVectorC;
  65290. private _tmpAmmoVectorD;
  65291. private _tmpContactCallbackResult;
  65292. private _tmpAmmoVectorRCA;
  65293. private _tmpAmmoVectorRCB;
  65294. private _raycastResult;
  65295. private _tmpContactPoint;
  65296. private static readonly DISABLE_COLLISION_FLAG;
  65297. private static readonly KINEMATIC_FLAG;
  65298. private static readonly DISABLE_DEACTIVATION_FLAG;
  65299. /**
  65300. * Initializes the ammoJS plugin
  65301. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65302. * @param ammoInjection can be used to inject your own ammo reference
  65303. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65304. */
  65305. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65306. /**
  65307. * Sets the gravity of the physics world (m/(s^2))
  65308. * @param gravity Gravity to set
  65309. */
  65310. setGravity(gravity: Vector3): void;
  65311. /**
  65312. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65313. * @param timeStep timestep to use in seconds
  65314. */
  65315. setTimeStep(timeStep: number): void;
  65316. /**
  65317. * 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)
  65318. * @param fixedTimeStep fixedTimeStep to use in seconds
  65319. */
  65320. setFixedTimeStep(fixedTimeStep: number): void;
  65321. /**
  65322. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65323. * @param maxSteps the maximum number of steps by the physics engine per frame
  65324. */
  65325. setMaxSteps(maxSteps: number): void;
  65326. /**
  65327. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65328. * @returns the current timestep in seconds
  65329. */
  65330. getTimeStep(): number;
  65331. /**
  65332. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65333. */
  65334. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65335. private _isImpostorInContact;
  65336. private _isImpostorPairInContact;
  65337. private _stepSimulation;
  65338. /**
  65339. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65340. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65341. * After the step the babylon meshes are set to the position of the physics imposters
  65342. * @param delta amount of time to step forward
  65343. * @param impostors array of imposters to update before/after the step
  65344. */
  65345. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65346. /**
  65347. * Update babylon mesh to match physics world object
  65348. * @param impostor imposter to match
  65349. */
  65350. private _afterSoftStep;
  65351. /**
  65352. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65353. * @param impostor imposter to match
  65354. */
  65355. private _ropeStep;
  65356. /**
  65357. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65358. * @param impostor imposter to match
  65359. */
  65360. private _softbodyOrClothStep;
  65361. private _tmpMatrix;
  65362. /**
  65363. * Applies an impulse on the imposter
  65364. * @param impostor imposter to apply impulse to
  65365. * @param force amount of force to be applied to the imposter
  65366. * @param contactPoint the location to apply the impulse on the imposter
  65367. */
  65368. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65369. /**
  65370. * Applies a force on the imposter
  65371. * @param impostor imposter to apply force
  65372. * @param force amount of force to be applied to the imposter
  65373. * @param contactPoint the location to apply the force on the imposter
  65374. */
  65375. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65376. /**
  65377. * Creates a physics body using the plugin
  65378. * @param impostor the imposter to create the physics body on
  65379. */
  65380. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65381. /**
  65382. * Removes the physics body from the imposter and disposes of the body's memory
  65383. * @param impostor imposter to remove the physics body from
  65384. */
  65385. removePhysicsBody(impostor: PhysicsImpostor): void;
  65386. /**
  65387. * Generates a joint
  65388. * @param impostorJoint the imposter joint to create the joint with
  65389. */
  65390. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65391. /**
  65392. * Removes a joint
  65393. * @param impostorJoint the imposter joint to remove the joint from
  65394. */
  65395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65396. private _addMeshVerts;
  65397. /**
  65398. * Initialise the soft body vertices to match its object's (mesh) vertices
  65399. * Softbody vertices (nodes) are in world space and to match this
  65400. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65401. * @param impostor to create the softbody for
  65402. */
  65403. private _softVertexData;
  65404. /**
  65405. * Create an impostor's soft body
  65406. * @param impostor to create the softbody for
  65407. */
  65408. private _createSoftbody;
  65409. /**
  65410. * Create cloth for an impostor
  65411. * @param impostor to create the softbody for
  65412. */
  65413. private _createCloth;
  65414. /**
  65415. * Create rope for an impostor
  65416. * @param impostor to create the softbody for
  65417. */
  65418. private _createRope;
  65419. /**
  65420. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65421. * @param impostor to create the custom physics shape for
  65422. */
  65423. private _createCustom;
  65424. private _addHullVerts;
  65425. private _createShape;
  65426. /**
  65427. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65428. * @param impostor imposter containing the physics body and babylon object
  65429. */
  65430. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65431. /**
  65432. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65433. * @param impostor imposter containing the physics body and babylon object
  65434. * @param newPosition new position
  65435. * @param newRotation new rotation
  65436. */
  65437. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65438. /**
  65439. * If this plugin is supported
  65440. * @returns true if its supported
  65441. */
  65442. isSupported(): boolean;
  65443. /**
  65444. * Sets the linear velocity of the physics body
  65445. * @param impostor imposter to set the velocity on
  65446. * @param velocity velocity to set
  65447. */
  65448. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65449. /**
  65450. * Sets the angular velocity of the physics body
  65451. * @param impostor imposter to set the velocity on
  65452. * @param velocity velocity to set
  65453. */
  65454. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65455. /**
  65456. * gets the linear velocity
  65457. * @param impostor imposter to get linear velocity from
  65458. * @returns linear velocity
  65459. */
  65460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65461. /**
  65462. * gets the angular velocity
  65463. * @param impostor imposter to get angular velocity from
  65464. * @returns angular velocity
  65465. */
  65466. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65467. /**
  65468. * Sets the mass of physics body
  65469. * @param impostor imposter to set the mass on
  65470. * @param mass mass to set
  65471. */
  65472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65473. /**
  65474. * Gets the mass of the physics body
  65475. * @param impostor imposter to get the mass from
  65476. * @returns mass
  65477. */
  65478. getBodyMass(impostor: PhysicsImpostor): number;
  65479. /**
  65480. * Gets friction of the impostor
  65481. * @param impostor impostor to get friction from
  65482. * @returns friction value
  65483. */
  65484. getBodyFriction(impostor: PhysicsImpostor): number;
  65485. /**
  65486. * Sets friction of the impostor
  65487. * @param impostor impostor to set friction on
  65488. * @param friction friction value
  65489. */
  65490. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65491. /**
  65492. * Gets restitution of the impostor
  65493. * @param impostor impostor to get restitution from
  65494. * @returns restitution value
  65495. */
  65496. getBodyRestitution(impostor: PhysicsImpostor): number;
  65497. /**
  65498. * Sets resitution of the impostor
  65499. * @param impostor impostor to set resitution on
  65500. * @param restitution resitution value
  65501. */
  65502. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65503. /**
  65504. * Gets pressure inside the impostor
  65505. * @param impostor impostor to get pressure from
  65506. * @returns pressure value
  65507. */
  65508. getBodyPressure(impostor: PhysicsImpostor): number;
  65509. /**
  65510. * Sets pressure inside a soft body impostor
  65511. * Cloth and rope must remain 0 pressure
  65512. * @param impostor impostor to set pressure on
  65513. * @param pressure pressure value
  65514. */
  65515. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65516. /**
  65517. * Gets stiffness of the impostor
  65518. * @param impostor impostor to get stiffness from
  65519. * @returns pressure value
  65520. */
  65521. getBodyStiffness(impostor: PhysicsImpostor): number;
  65522. /**
  65523. * Sets stiffness of the impostor
  65524. * @param impostor impostor to set stiffness on
  65525. * @param stiffness stiffness value from 0 to 1
  65526. */
  65527. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65528. /**
  65529. * Gets velocityIterations of the impostor
  65530. * @param impostor impostor to get velocity iterations from
  65531. * @returns velocityIterations value
  65532. */
  65533. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65534. /**
  65535. * Sets velocityIterations of the impostor
  65536. * @param impostor impostor to set velocity iterations on
  65537. * @param velocityIterations velocityIterations value
  65538. */
  65539. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65540. /**
  65541. * Gets positionIterations of the impostor
  65542. * @param impostor impostor to get position iterations from
  65543. * @returns positionIterations value
  65544. */
  65545. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65546. /**
  65547. * Sets positionIterations of the impostor
  65548. * @param impostor impostor to set position on
  65549. * @param positionIterations positionIterations value
  65550. */
  65551. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65552. /**
  65553. * Append an anchor to a cloth object
  65554. * @param impostor is the cloth impostor to add anchor to
  65555. * @param otherImpostor is the rigid impostor to anchor to
  65556. * @param width ratio across width from 0 to 1
  65557. * @param height ratio up height from 0 to 1
  65558. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65559. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65560. */
  65561. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65562. /**
  65563. * Append an hook to a rope object
  65564. * @param impostor is the rope impostor to add hook to
  65565. * @param otherImpostor is the rigid impostor to hook to
  65566. * @param length ratio along the rope from 0 to 1
  65567. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65568. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65569. */
  65570. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65571. /**
  65572. * Sleeps the physics body and stops it from being active
  65573. * @param impostor impostor to sleep
  65574. */
  65575. sleepBody(impostor: PhysicsImpostor): void;
  65576. /**
  65577. * Activates the physics body
  65578. * @param impostor impostor to activate
  65579. */
  65580. wakeUpBody(impostor: PhysicsImpostor): void;
  65581. /**
  65582. * Updates the distance parameters of the joint
  65583. * @param joint joint to update
  65584. * @param maxDistance maximum distance of the joint
  65585. * @param minDistance minimum distance of the joint
  65586. */
  65587. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65588. /**
  65589. * Sets a motor on the joint
  65590. * @param joint joint to set motor on
  65591. * @param speed speed of the motor
  65592. * @param maxForce maximum force of the motor
  65593. * @param motorIndex index of the motor
  65594. */
  65595. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65596. /**
  65597. * Sets the motors limit
  65598. * @param joint joint to set limit on
  65599. * @param upperLimit upper limit
  65600. * @param lowerLimit lower limit
  65601. */
  65602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65603. /**
  65604. * Syncs the position and rotation of a mesh with the impostor
  65605. * @param mesh mesh to sync
  65606. * @param impostor impostor to update the mesh with
  65607. */
  65608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65609. /**
  65610. * Gets the radius of the impostor
  65611. * @param impostor impostor to get radius from
  65612. * @returns the radius
  65613. */
  65614. getRadius(impostor: PhysicsImpostor): number;
  65615. /**
  65616. * Gets the box size of the impostor
  65617. * @param impostor impostor to get box size from
  65618. * @param result the resulting box size
  65619. */
  65620. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65621. /**
  65622. * Disposes of the impostor
  65623. */
  65624. dispose(): void;
  65625. /**
  65626. * Does a raycast in the physics world
  65627. * @param from when should the ray start?
  65628. * @param to when should the ray end?
  65629. * @returns PhysicsRaycastResult
  65630. */
  65631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65632. }
  65633. }
  65634. declare module BABYLON {
  65635. interface AbstractScene {
  65636. /**
  65637. * The list of reflection probes added to the scene
  65638. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65639. */
  65640. reflectionProbes: Array<ReflectionProbe>;
  65641. /**
  65642. * Removes the given reflection probe from this scene.
  65643. * @param toRemove The reflection probe to remove
  65644. * @returns The index of the removed reflection probe
  65645. */
  65646. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65647. /**
  65648. * Adds the given reflection probe to this scene.
  65649. * @param newReflectionProbe The reflection probe to add
  65650. */
  65651. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65652. }
  65653. /**
  65654. * Class used to generate realtime reflection / refraction cube textures
  65655. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65656. */
  65657. export class ReflectionProbe {
  65658. /** defines the name of the probe */
  65659. name: string;
  65660. private _scene;
  65661. private _renderTargetTexture;
  65662. private _projectionMatrix;
  65663. private _viewMatrix;
  65664. private _target;
  65665. private _add;
  65666. private _attachedMesh;
  65667. private _invertYAxis;
  65668. /** Gets or sets probe position (center of the cube map) */
  65669. position: Vector3;
  65670. /**
  65671. * Creates a new reflection probe
  65672. * @param name defines the name of the probe
  65673. * @param size defines the texture resolution (for each face)
  65674. * @param scene defines the hosting scene
  65675. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65676. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65677. */
  65678. constructor(
  65679. /** defines the name of the probe */
  65680. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65681. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65682. get samples(): number;
  65683. set samples(value: number);
  65684. /** Gets or sets the refresh rate to use (on every frame by default) */
  65685. get refreshRate(): number;
  65686. set refreshRate(value: number);
  65687. /**
  65688. * Gets the hosting scene
  65689. * @returns a Scene
  65690. */
  65691. getScene(): Scene;
  65692. /** Gets the internal CubeTexture used to render to */
  65693. get cubeTexture(): RenderTargetTexture;
  65694. /** Gets the list of meshes to render */
  65695. get renderList(): Nullable<AbstractMesh[]>;
  65696. /**
  65697. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65698. * @param mesh defines the mesh to attach to
  65699. */
  65700. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65701. /**
  65702. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65703. * @param renderingGroupId The rendering group id corresponding to its index
  65704. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65705. */
  65706. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65707. /**
  65708. * Clean all associated resources
  65709. */
  65710. dispose(): void;
  65711. /**
  65712. * Converts the reflection probe information to a readable string for debug purpose.
  65713. * @param fullDetails Supports for multiple levels of logging within scene loading
  65714. * @returns the human readable reflection probe info
  65715. */
  65716. toString(fullDetails?: boolean): string;
  65717. /**
  65718. * Get the class name of the relfection probe.
  65719. * @returns "ReflectionProbe"
  65720. */
  65721. getClassName(): string;
  65722. /**
  65723. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65724. * @returns The JSON representation of the texture
  65725. */
  65726. serialize(): any;
  65727. /**
  65728. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65729. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65730. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65731. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65732. * @returns The parsed reflection probe if successful
  65733. */
  65734. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65735. }
  65736. }
  65737. declare module BABYLON {
  65738. /** @hidden */
  65739. export var _BabylonLoaderRegistered: boolean;
  65740. /**
  65741. * Helps setting up some configuration for the babylon file loader.
  65742. */
  65743. export class BabylonFileLoaderConfiguration {
  65744. /**
  65745. * The loader does not allow injecting custom physix engine into the plugins.
  65746. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65747. * So you could set this variable to your engine import to make it work.
  65748. */
  65749. static LoaderInjectedPhysicsEngine: any;
  65750. }
  65751. }
  65752. declare module BABYLON {
  65753. /**
  65754. * A material to use for fast depth-only rendering.
  65755. */
  65756. export class OcclusionMaterial extends ShaderMaterial {
  65757. constructor(name: string, scene: Scene);
  65758. }
  65759. }
  65760. declare module BABYLON {
  65761. /**
  65762. * The Physically based simple base material of BJS.
  65763. *
  65764. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65765. * It is used as the base class for both the specGloss and metalRough conventions.
  65766. */
  65767. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65768. /**
  65769. * Number of Simultaneous lights allowed on the material.
  65770. */
  65771. maxSimultaneousLights: number;
  65772. /**
  65773. * If sets to true, disables all the lights affecting the material.
  65774. */
  65775. disableLighting: boolean;
  65776. /**
  65777. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65778. */
  65779. environmentTexture: BaseTexture;
  65780. /**
  65781. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65782. */
  65783. invertNormalMapX: boolean;
  65784. /**
  65785. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65786. */
  65787. invertNormalMapY: boolean;
  65788. /**
  65789. * Normal map used in the model.
  65790. */
  65791. normalTexture: BaseTexture;
  65792. /**
  65793. * Emissivie color used to self-illuminate the model.
  65794. */
  65795. emissiveColor: Color3;
  65796. /**
  65797. * Emissivie texture used to self-illuminate the model.
  65798. */
  65799. emissiveTexture: BaseTexture;
  65800. /**
  65801. * Occlusion Channel Strenght.
  65802. */
  65803. occlusionStrength: number;
  65804. /**
  65805. * Occlusion Texture of the material (adding extra occlusion effects).
  65806. */
  65807. occlusionTexture: BaseTexture;
  65808. /**
  65809. * Defines the alpha limits in alpha test mode.
  65810. */
  65811. alphaCutOff: number;
  65812. /**
  65813. * Gets the current double sided mode.
  65814. */
  65815. get doubleSided(): boolean;
  65816. /**
  65817. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65818. */
  65819. set doubleSided(value: boolean);
  65820. /**
  65821. * Stores the pre-calculated light information of a mesh in a texture.
  65822. */
  65823. lightmapTexture: BaseTexture;
  65824. /**
  65825. * If true, the light map contains occlusion information instead of lighting info.
  65826. */
  65827. useLightmapAsShadowmap: boolean;
  65828. /**
  65829. * Instantiates a new PBRMaterial instance.
  65830. *
  65831. * @param name The material name
  65832. * @param scene The scene the material will be use in.
  65833. */
  65834. constructor(name: string, scene: Scene);
  65835. getClassName(): string;
  65836. }
  65837. }
  65838. declare module BABYLON {
  65839. /**
  65840. * The PBR material of BJS following the metal roughness convention.
  65841. *
  65842. * This fits to the PBR convention in the GLTF definition:
  65843. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65844. */
  65845. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65846. /**
  65847. * The base color has two different interpretations depending on the value of metalness.
  65848. * When the material is a metal, the base color is the specific measured reflectance value
  65849. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65850. * of the material.
  65851. */
  65852. baseColor: Color3;
  65853. /**
  65854. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65855. * well as opacity information in the alpha channel.
  65856. */
  65857. baseTexture: BaseTexture;
  65858. /**
  65859. * Specifies the metallic scalar value of the material.
  65860. * Can also be used to scale the metalness values of the metallic texture.
  65861. */
  65862. metallic: number;
  65863. /**
  65864. * Specifies the roughness scalar value of the material.
  65865. * Can also be used to scale the roughness values of the metallic texture.
  65866. */
  65867. roughness: number;
  65868. /**
  65869. * Texture containing both the metallic value in the B channel and the
  65870. * roughness value in the G channel to keep better precision.
  65871. */
  65872. metallicRoughnessTexture: BaseTexture;
  65873. /**
  65874. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65875. *
  65876. * @param name The material name
  65877. * @param scene The scene the material will be use in.
  65878. */
  65879. constructor(name: string, scene: Scene);
  65880. /**
  65881. * Return the currrent class name of the material.
  65882. */
  65883. getClassName(): string;
  65884. /**
  65885. * Makes a duplicate of the current material.
  65886. * @param name - name to use for the new material.
  65887. */
  65888. clone(name: string): PBRMetallicRoughnessMaterial;
  65889. /**
  65890. * Serialize the material to a parsable JSON object.
  65891. */
  65892. serialize(): any;
  65893. /**
  65894. * Parses a JSON object correponding to the serialize function.
  65895. */
  65896. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65897. }
  65898. }
  65899. declare module BABYLON {
  65900. /**
  65901. * The PBR material of BJS following the specular glossiness convention.
  65902. *
  65903. * This fits to the PBR convention in the GLTF definition:
  65904. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65905. */
  65906. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65907. /**
  65908. * Specifies the diffuse color of the material.
  65909. */
  65910. diffuseColor: Color3;
  65911. /**
  65912. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65913. * channel.
  65914. */
  65915. diffuseTexture: BaseTexture;
  65916. /**
  65917. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65918. */
  65919. specularColor: Color3;
  65920. /**
  65921. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65922. */
  65923. glossiness: number;
  65924. /**
  65925. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65926. */
  65927. specularGlossinessTexture: BaseTexture;
  65928. /**
  65929. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65930. */
  65931. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65932. /**
  65933. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65934. *
  65935. * @param name The material name
  65936. * @param scene The scene the material will be use in.
  65937. */
  65938. constructor(name: string, scene: Scene);
  65939. /**
  65940. * Return the currrent class name of the material.
  65941. */
  65942. getClassName(): string;
  65943. /**
  65944. * Makes a duplicate of the current material.
  65945. * @param name - name to use for the new material.
  65946. */
  65947. clone(name: string): PBRSpecularGlossinessMaterial;
  65948. /**
  65949. * Serialize the material to a parsable JSON object.
  65950. */
  65951. serialize(): any;
  65952. /**
  65953. * Parses a JSON object correponding to the serialize function.
  65954. */
  65955. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65956. }
  65957. }
  65958. declare module BABYLON {
  65959. /**
  65960. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65961. * It can help converting any input color in a desired output one. This can then be used to create effects
  65962. * from sepia, black and white to sixties or futuristic rendering...
  65963. *
  65964. * The only supported format is currently 3dl.
  65965. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65966. */
  65967. export class ColorGradingTexture extends BaseTexture {
  65968. /**
  65969. * The texture URL.
  65970. */
  65971. url: string;
  65972. /**
  65973. * Empty line regex stored for GC.
  65974. */
  65975. private static _noneEmptyLineRegex;
  65976. private _textureMatrix;
  65977. private _onLoad;
  65978. /**
  65979. * Instantiates a ColorGradingTexture from the following parameters.
  65980. *
  65981. * @param url The location of the color gradind data (currently only supporting 3dl)
  65982. * @param sceneOrEngine The scene or engine the texture will be used in
  65983. * @param onLoad defines a callback triggered when the texture has been loaded
  65984. */
  65985. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65986. /**
  65987. * Fires the onload event from the constructor if requested.
  65988. */
  65989. private _triggerOnLoad;
  65990. /**
  65991. * Returns the texture matrix used in most of the material.
  65992. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65993. */
  65994. getTextureMatrix(): Matrix;
  65995. /**
  65996. * Occurs when the file being loaded is a .3dl LUT file.
  65997. */
  65998. private load3dlTexture;
  65999. /**
  66000. * Starts the loading process of the texture.
  66001. */
  66002. private loadTexture;
  66003. /**
  66004. * Clones the color gradind texture.
  66005. */
  66006. clone(): ColorGradingTexture;
  66007. /**
  66008. * Called during delayed load for textures.
  66009. */
  66010. delayLoad(): void;
  66011. /**
  66012. * Parses a color grading texture serialized by Babylon.
  66013. * @param parsedTexture The texture information being parsedTexture
  66014. * @param scene The scene to load the texture in
  66015. * @param rootUrl The root url of the data assets to load
  66016. * @return A color gradind texture
  66017. */
  66018. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66019. /**
  66020. * Serializes the LUT texture to json format.
  66021. */
  66022. serialize(): any;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /**
  66027. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66028. */
  66029. export class EquiRectangularCubeTexture extends BaseTexture {
  66030. /** The six faces of the cube. */
  66031. private static _FacesMapping;
  66032. private _noMipmap;
  66033. private _onLoad;
  66034. private _onError;
  66035. /** The size of the cubemap. */
  66036. private _size;
  66037. /** The buffer of the image. */
  66038. private _buffer;
  66039. /** The width of the input image. */
  66040. private _width;
  66041. /** The height of the input image. */
  66042. private _height;
  66043. /** The URL to the image. */
  66044. url: string;
  66045. /**
  66046. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66047. * @param url The location of the image
  66048. * @param scene The scene the texture will be used in
  66049. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66050. * @param noMipmap Forces to not generate the mipmap if true
  66051. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66052. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66053. * @param onLoad — defines a callback called when texture is loaded
  66054. * @param onError — defines a callback called if there is an error
  66055. */
  66056. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66057. /**
  66058. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66059. */
  66060. private loadImage;
  66061. /**
  66062. * Convert the image buffer into a cubemap and create a CubeTexture.
  66063. */
  66064. private loadTexture;
  66065. /**
  66066. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66067. * @param buffer The ArrayBuffer that should be converted.
  66068. * @returns The buffer as Float32Array.
  66069. */
  66070. private getFloat32ArrayFromArrayBuffer;
  66071. /**
  66072. * Get the current class name of the texture useful for serialization or dynamic coding.
  66073. * @returns "EquiRectangularCubeTexture"
  66074. */
  66075. getClassName(): string;
  66076. /**
  66077. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66078. * @returns A clone of the current EquiRectangularCubeTexture.
  66079. */
  66080. clone(): EquiRectangularCubeTexture;
  66081. }
  66082. }
  66083. declare module BABYLON {
  66084. /**
  66085. * Defines the options related to the creation of an HtmlElementTexture
  66086. */
  66087. export interface IHtmlElementTextureOptions {
  66088. /**
  66089. * Defines wether mip maps should be created or not.
  66090. */
  66091. generateMipMaps?: boolean;
  66092. /**
  66093. * Defines the sampling mode of the texture.
  66094. */
  66095. samplingMode?: number;
  66096. /**
  66097. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66098. */
  66099. engine: Nullable<ThinEngine>;
  66100. /**
  66101. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66102. */
  66103. scene: Nullable<Scene>;
  66104. }
  66105. /**
  66106. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66107. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66108. * is automatically managed.
  66109. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66110. * in your application.
  66111. *
  66112. * As the update is not automatic, you need to call them manually.
  66113. */
  66114. export class HtmlElementTexture extends BaseTexture {
  66115. /**
  66116. * The texture URL.
  66117. */
  66118. element: HTMLVideoElement | HTMLCanvasElement;
  66119. private static readonly DefaultOptions;
  66120. private _textureMatrix;
  66121. private _isVideo;
  66122. private _generateMipMaps;
  66123. private _samplingMode;
  66124. /**
  66125. * Instantiates a HtmlElementTexture from the following parameters.
  66126. *
  66127. * @param name Defines the name of the texture
  66128. * @param element Defines the video or canvas the texture is filled with
  66129. * @param options Defines the other none mandatory texture creation options
  66130. */
  66131. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66132. private _createInternalTexture;
  66133. /**
  66134. * Returns the texture matrix used in most of the material.
  66135. */
  66136. getTextureMatrix(): Matrix;
  66137. /**
  66138. * Updates the content of the texture.
  66139. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66140. */
  66141. update(invertY?: Nullable<boolean>): void;
  66142. }
  66143. }
  66144. declare module BABYLON {
  66145. /**
  66146. * Based on jsTGALoader - Javascript loader for TGA file
  66147. * By Vincent Thibault
  66148. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66149. */
  66150. export class TGATools {
  66151. private static _TYPE_INDEXED;
  66152. private static _TYPE_RGB;
  66153. private static _TYPE_GREY;
  66154. private static _TYPE_RLE_INDEXED;
  66155. private static _TYPE_RLE_RGB;
  66156. private static _TYPE_RLE_GREY;
  66157. private static _ORIGIN_MASK;
  66158. private static _ORIGIN_SHIFT;
  66159. private static _ORIGIN_BL;
  66160. private static _ORIGIN_BR;
  66161. private static _ORIGIN_UL;
  66162. private static _ORIGIN_UR;
  66163. /**
  66164. * Gets the header of a TGA file
  66165. * @param data defines the TGA data
  66166. * @returns the header
  66167. */
  66168. static GetTGAHeader(data: Uint8Array): any;
  66169. /**
  66170. * Uploads TGA content to a Babylon Texture
  66171. * @hidden
  66172. */
  66173. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66174. /** @hidden */
  66175. 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;
  66176. /** @hidden */
  66177. 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;
  66178. /** @hidden */
  66179. 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;
  66180. /** @hidden */
  66181. 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;
  66182. /** @hidden */
  66183. 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;
  66184. /** @hidden */
  66185. 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;
  66186. }
  66187. }
  66188. declare module BABYLON {
  66189. /**
  66190. * Implementation of the TGA Texture Loader.
  66191. * @hidden
  66192. */
  66193. export class _TGATextureLoader implements IInternalTextureLoader {
  66194. /**
  66195. * Defines wether the loader supports cascade loading the different faces.
  66196. */
  66197. readonly supportCascades: boolean;
  66198. /**
  66199. * This returns if the loader support the current file information.
  66200. * @param extension defines the file extension of the file being loaded
  66201. * @returns true if the loader can load the specified file
  66202. */
  66203. canLoad(extension: string): boolean;
  66204. /**
  66205. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66206. * @param data contains the texture data
  66207. * @param texture defines the BabylonJS internal texture
  66208. * @param createPolynomials will be true if polynomials have been requested
  66209. * @param onLoad defines the callback to trigger once the texture is ready
  66210. * @param onError defines the callback to trigger in case of error
  66211. */
  66212. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66213. /**
  66214. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66215. * @param data contains the texture data
  66216. * @param texture defines the BabylonJS internal texture
  66217. * @param callback defines the method to call once ready to upload
  66218. */
  66219. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66220. }
  66221. }
  66222. declare module BABYLON {
  66223. /**
  66224. * Implementation of the HDR Texture Loader.
  66225. * @hidden
  66226. */
  66227. export class _HDRTextureLoader implements IInternalTextureLoader {
  66228. /**
  66229. * Defines wether the loader supports cascade loading the different faces.
  66230. */
  66231. readonly supportCascades: boolean;
  66232. /**
  66233. * This returns if the loader support the current file information.
  66234. * @param extension defines the file extension of the file being loaded
  66235. * @returns true if the loader can load the specified file
  66236. */
  66237. canLoad(extension: string): boolean;
  66238. /**
  66239. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66240. * @param data contains the texture data
  66241. * @param texture defines the BabylonJS internal texture
  66242. * @param createPolynomials will be true if polynomials have been requested
  66243. * @param onLoad defines the callback to trigger once the texture is ready
  66244. * @param onError defines the callback to trigger in case of error
  66245. */
  66246. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66247. /**
  66248. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66249. * @param data contains the texture data
  66250. * @param texture defines the BabylonJS internal texture
  66251. * @param callback defines the method to call once ready to upload
  66252. */
  66253. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /**
  66258. * Info about the .basis files
  66259. */
  66260. class BasisFileInfo {
  66261. /**
  66262. * If the file has alpha
  66263. */
  66264. hasAlpha: boolean;
  66265. /**
  66266. * Info about each image of the basis file
  66267. */
  66268. images: Array<{
  66269. levels: Array<{
  66270. width: number;
  66271. height: number;
  66272. transcodedPixels: ArrayBufferView;
  66273. }>;
  66274. }>;
  66275. }
  66276. /**
  66277. * Result of transcoding a basis file
  66278. */
  66279. class TranscodeResult {
  66280. /**
  66281. * Info about the .basis file
  66282. */
  66283. fileInfo: BasisFileInfo;
  66284. /**
  66285. * Format to use when loading the file
  66286. */
  66287. format: number;
  66288. }
  66289. /**
  66290. * Configuration options for the Basis transcoder
  66291. */
  66292. export class BasisTranscodeConfiguration {
  66293. /**
  66294. * Supported compression formats used to determine the supported output format of the transcoder
  66295. */
  66296. supportedCompressionFormats?: {
  66297. /**
  66298. * etc1 compression format
  66299. */
  66300. etc1?: boolean;
  66301. /**
  66302. * s3tc compression format
  66303. */
  66304. s3tc?: boolean;
  66305. /**
  66306. * pvrtc compression format
  66307. */
  66308. pvrtc?: boolean;
  66309. /**
  66310. * etc2 compression format
  66311. */
  66312. etc2?: boolean;
  66313. };
  66314. /**
  66315. * If mipmap levels should be loaded for transcoded images (Default: true)
  66316. */
  66317. loadMipmapLevels?: boolean;
  66318. /**
  66319. * Index of a single image to load (Default: all images)
  66320. */
  66321. loadSingleImage?: number;
  66322. }
  66323. /**
  66324. * Used to load .Basis files
  66325. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66326. */
  66327. export class BasisTools {
  66328. private static _IgnoreSupportedFormats;
  66329. /**
  66330. * URL to use when loading the basis transcoder
  66331. */
  66332. static JSModuleURL: string;
  66333. /**
  66334. * URL to use when loading the wasm module for the transcoder
  66335. */
  66336. static WasmModuleURL: string;
  66337. /**
  66338. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66339. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66340. * @returns internal format corresponding to the Basis format
  66341. */
  66342. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66343. private static _WorkerPromise;
  66344. private static _Worker;
  66345. private static _actionId;
  66346. private static _CreateWorkerAsync;
  66347. /**
  66348. * Transcodes a loaded image file to compressed pixel data
  66349. * @param data image data to transcode
  66350. * @param config configuration options for the transcoding
  66351. * @returns a promise resulting in the transcoded image
  66352. */
  66353. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66354. /**
  66355. * Loads a texture from the transcode result
  66356. * @param texture texture load to
  66357. * @param transcodeResult the result of transcoding the basis file to load from
  66358. */
  66359. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66360. }
  66361. }
  66362. declare module BABYLON {
  66363. /**
  66364. * Loader for .basis file format
  66365. */
  66366. export class _BasisTextureLoader implements IInternalTextureLoader {
  66367. /**
  66368. * Defines whether the loader supports cascade loading the different faces.
  66369. */
  66370. readonly supportCascades: boolean;
  66371. /**
  66372. * This returns if the loader support the current file information.
  66373. * @param extension defines the file extension of the file being loaded
  66374. * @returns true if the loader can load the specified file
  66375. */
  66376. canLoad(extension: string): boolean;
  66377. /**
  66378. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66379. * @param data contains the texture data
  66380. * @param texture defines the BabylonJS internal texture
  66381. * @param createPolynomials will be true if polynomials have been requested
  66382. * @param onLoad defines the callback to trigger once the texture is ready
  66383. * @param onError defines the callback to trigger in case of error
  66384. */
  66385. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66386. /**
  66387. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66388. * @param data contains the texture data
  66389. * @param texture defines the BabylonJS internal texture
  66390. * @param callback defines the method to call once ready to upload
  66391. */
  66392. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66393. }
  66394. }
  66395. declare module BABYLON {
  66396. /**
  66397. * Defines the basic options interface of a TexturePacker Frame
  66398. */
  66399. export interface ITexturePackerFrame {
  66400. /**
  66401. * The frame ID
  66402. */
  66403. id: number;
  66404. /**
  66405. * The frames Scale
  66406. */
  66407. scale: Vector2;
  66408. /**
  66409. * The Frames offset
  66410. */
  66411. offset: Vector2;
  66412. }
  66413. /**
  66414. * This is a support class for frame Data on texture packer sets.
  66415. */
  66416. export class TexturePackerFrame implements ITexturePackerFrame {
  66417. /**
  66418. * The frame ID
  66419. */
  66420. id: number;
  66421. /**
  66422. * The frames Scale
  66423. */
  66424. scale: Vector2;
  66425. /**
  66426. * The Frames offset
  66427. */
  66428. offset: Vector2;
  66429. /**
  66430. * Initializes a texture package frame.
  66431. * @param id The numerical frame identifier
  66432. * @param scale Scalar Vector2 for UV frame
  66433. * @param offset Vector2 for the frame position in UV units.
  66434. * @returns TexturePackerFrame
  66435. */
  66436. constructor(id: number, scale: Vector2, offset: Vector2);
  66437. }
  66438. }
  66439. declare module BABYLON {
  66440. /**
  66441. * Defines the basic options interface of a TexturePacker
  66442. */
  66443. export interface ITexturePackerOptions {
  66444. /**
  66445. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66446. */
  66447. map?: string[];
  66448. /**
  66449. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66450. */
  66451. uvsIn?: string;
  66452. /**
  66453. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66454. */
  66455. uvsOut?: string;
  66456. /**
  66457. * number representing the layout style. Defaults to LAYOUT_STRIP
  66458. */
  66459. layout?: number;
  66460. /**
  66461. * number of columns if using custom column count layout(2). This defaults to 4.
  66462. */
  66463. colnum?: number;
  66464. /**
  66465. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66466. */
  66467. updateInputMeshes?: boolean;
  66468. /**
  66469. * boolean flag to dispose all the source textures. Defaults to true.
  66470. */
  66471. disposeSources?: boolean;
  66472. /**
  66473. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66474. */
  66475. fillBlanks?: boolean;
  66476. /**
  66477. * string value representing the context fill style color. Defaults to 'black'.
  66478. */
  66479. customFillColor?: string;
  66480. /**
  66481. * Width and Height Value of each Frame in the TexturePacker Sets
  66482. */
  66483. frameSize?: number;
  66484. /**
  66485. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66486. */
  66487. paddingRatio?: number;
  66488. /**
  66489. * Number that declares the fill method for the padding gutter.
  66490. */
  66491. paddingMode?: number;
  66492. /**
  66493. * If in SUBUV_COLOR padding mode what color to use.
  66494. */
  66495. paddingColor?: Color3 | Color4;
  66496. }
  66497. /**
  66498. * Defines the basic interface of a TexturePacker JSON File
  66499. */
  66500. export interface ITexturePackerJSON {
  66501. /**
  66502. * The frame ID
  66503. */
  66504. name: string;
  66505. /**
  66506. * The base64 channel data
  66507. */
  66508. sets: any;
  66509. /**
  66510. * The options of the Packer
  66511. */
  66512. options: ITexturePackerOptions;
  66513. /**
  66514. * The frame data of the Packer
  66515. */
  66516. frames: Array<number>;
  66517. }
  66518. /**
  66519. * This is a support class that generates a series of packed texture sets.
  66520. * @see https://doc.babylonjs.com/babylon101/materials
  66521. */
  66522. export class TexturePacker {
  66523. /** Packer Layout Constant 0 */
  66524. static readonly LAYOUT_STRIP: number;
  66525. /** Packer Layout Constant 1 */
  66526. static readonly LAYOUT_POWER2: number;
  66527. /** Packer Layout Constant 2 */
  66528. static readonly LAYOUT_COLNUM: number;
  66529. /** Packer Layout Constant 0 */
  66530. static readonly SUBUV_WRAP: number;
  66531. /** Packer Layout Constant 1 */
  66532. static readonly SUBUV_EXTEND: number;
  66533. /** Packer Layout Constant 2 */
  66534. static readonly SUBUV_COLOR: number;
  66535. /** The Name of the Texture Package */
  66536. name: string;
  66537. /** The scene scope of the TexturePacker */
  66538. scene: Scene;
  66539. /** The Meshes to target */
  66540. meshes: AbstractMesh[];
  66541. /** Arguments passed with the Constructor */
  66542. options: ITexturePackerOptions;
  66543. /** The promise that is started upon initialization */
  66544. promise: Nullable<Promise<TexturePacker | string>>;
  66545. /** The Container object for the channel sets that are generated */
  66546. sets: object;
  66547. /** The Container array for the frames that are generated */
  66548. frames: TexturePackerFrame[];
  66549. /** The expected number of textures the system is parsing. */
  66550. private _expecting;
  66551. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66552. private _paddingValue;
  66553. /**
  66554. * Initializes a texture package series from an array of meshes or a single mesh.
  66555. * @param name The name of the package
  66556. * @param meshes The target meshes to compose the package from
  66557. * @param options The arguments that texture packer should follow while building.
  66558. * @param scene The scene which the textures are scoped to.
  66559. * @returns TexturePacker
  66560. */
  66561. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66562. /**
  66563. * Starts the package process
  66564. * @param resolve The promises resolution function
  66565. * @returns TexturePacker
  66566. */
  66567. private _createFrames;
  66568. /**
  66569. * Calculates the Size of the Channel Sets
  66570. * @returns Vector2
  66571. */
  66572. private _calculateSize;
  66573. /**
  66574. * Calculates the UV data for the frames.
  66575. * @param baseSize the base frameSize
  66576. * @param padding the base frame padding
  66577. * @param dtSize size of the Dynamic Texture for that channel
  66578. * @param dtUnits is 1/dtSize
  66579. * @param update flag to update the input meshes
  66580. */
  66581. private _calculateMeshUVFrames;
  66582. /**
  66583. * Calculates the frames Offset.
  66584. * @param index of the frame
  66585. * @returns Vector2
  66586. */
  66587. private _getFrameOffset;
  66588. /**
  66589. * Updates a Mesh to the frame data
  66590. * @param mesh that is the target
  66591. * @param frameID or the frame index
  66592. */
  66593. private _updateMeshUV;
  66594. /**
  66595. * Updates a Meshes materials to use the texture packer channels
  66596. * @param m is the mesh to target
  66597. * @param force all channels on the packer to be set.
  66598. */
  66599. private _updateTextureReferences;
  66600. /**
  66601. * Public method to set a Mesh to a frame
  66602. * @param m that is the target
  66603. * @param frameID or the frame index
  66604. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66605. */
  66606. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66607. /**
  66608. * Starts the async promise to compile the texture packer.
  66609. * @returns Promise<void>
  66610. */
  66611. processAsync(): Promise<void>;
  66612. /**
  66613. * Disposes all textures associated with this packer
  66614. */
  66615. dispose(): void;
  66616. /**
  66617. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66618. * @param imageType is the image type to use.
  66619. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66620. */
  66621. download(imageType?: string, quality?: number): void;
  66622. /**
  66623. * Public method to load a texturePacker JSON file.
  66624. * @param data of the JSON file in string format.
  66625. */
  66626. updateFromJSON(data: string): void;
  66627. }
  66628. }
  66629. declare module BABYLON {
  66630. /**
  66631. * 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.
  66632. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66633. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66634. */
  66635. export class CustomProceduralTexture extends ProceduralTexture {
  66636. private _animate;
  66637. private _time;
  66638. private _config;
  66639. private _texturePath;
  66640. /**
  66641. * Instantiates a new Custom Procedural Texture.
  66642. * 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.
  66643. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66644. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66645. * @param name Define the name of the texture
  66646. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66647. * @param size Define the size of the texture to create
  66648. * @param scene Define the scene the texture belongs to
  66649. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66650. * @param generateMipMaps Define if the texture should creates mip maps or not
  66651. */
  66652. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66653. private _loadJson;
  66654. /**
  66655. * Is the texture ready to be used ? (rendered at least once)
  66656. * @returns true if ready, otherwise, false.
  66657. */
  66658. isReady(): boolean;
  66659. /**
  66660. * Render the texture to its associated render target.
  66661. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66662. */
  66663. render(useCameraPostProcess?: boolean): void;
  66664. /**
  66665. * Update the list of dependant textures samplers in the shader.
  66666. */
  66667. updateTextures(): void;
  66668. /**
  66669. * Update the uniform values of the procedural texture in the shader.
  66670. */
  66671. updateShaderUniforms(): void;
  66672. /**
  66673. * Define if the texture animates or not.
  66674. */
  66675. get animate(): boolean;
  66676. set animate(value: boolean);
  66677. }
  66678. }
  66679. declare module BABYLON {
  66680. /** @hidden */
  66681. export var noisePixelShader: {
  66682. name: string;
  66683. shader: string;
  66684. };
  66685. }
  66686. declare module BABYLON {
  66687. /**
  66688. * Class used to generate noise procedural textures
  66689. */
  66690. export class NoiseProceduralTexture extends ProceduralTexture {
  66691. /** Gets or sets the start time (default is 0) */
  66692. time: number;
  66693. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66694. brightness: number;
  66695. /** Defines the number of octaves to process */
  66696. octaves: number;
  66697. /** Defines the level of persistence (0.8 by default) */
  66698. persistence: number;
  66699. /** Gets or sets animation speed factor (default is 1) */
  66700. animationSpeedFactor: number;
  66701. /**
  66702. * Creates a new NoiseProceduralTexture
  66703. * @param name defines the name fo the texture
  66704. * @param size defines the size of the texture (default is 256)
  66705. * @param scene defines the hosting scene
  66706. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66707. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66708. */
  66709. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66710. private _updateShaderUniforms;
  66711. protected _getDefines(): string;
  66712. /** Generate the current state of the procedural texture */
  66713. render(useCameraPostProcess?: boolean): void;
  66714. /**
  66715. * Serializes this noise procedural texture
  66716. * @returns a serialized noise procedural texture object
  66717. */
  66718. serialize(): any;
  66719. /**
  66720. * Clone the texture.
  66721. * @returns the cloned texture
  66722. */
  66723. clone(): NoiseProceduralTexture;
  66724. /**
  66725. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66726. * @param parsedTexture defines parsed texture data
  66727. * @param scene defines the current scene
  66728. * @param rootUrl defines the root URL containing noise procedural texture information
  66729. * @returns a parsed NoiseProceduralTexture
  66730. */
  66731. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66732. }
  66733. }
  66734. declare module BABYLON {
  66735. /**
  66736. * Raw cube texture where the raw buffers are passed in
  66737. */
  66738. export class RawCubeTexture extends CubeTexture {
  66739. /**
  66740. * Creates a cube texture where the raw buffers are passed in.
  66741. * @param scene defines the scene the texture is attached to
  66742. * @param data defines the array of data to use to create each face
  66743. * @param size defines the size of the textures
  66744. * @param format defines the format of the data
  66745. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66746. * @param generateMipMaps defines if the engine should generate the mip levels
  66747. * @param invertY defines if data must be stored with Y axis inverted
  66748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66749. * @param compression defines the compression used (null by default)
  66750. */
  66751. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66752. /**
  66753. * Updates the raw cube texture.
  66754. * @param data defines the data to store
  66755. * @param format defines the data format
  66756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66757. * @param invertY defines if data must be stored with Y axis inverted
  66758. * @param compression defines the compression used (null by default)
  66759. * @param level defines which level of the texture to update
  66760. */
  66761. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66762. /**
  66763. * Updates a raw cube texture with RGBD encoded data.
  66764. * @param data defines the array of data [mipmap][face] to use to create each face
  66765. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66766. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66767. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66768. * @returns a promsie that resolves when the operation is complete
  66769. */
  66770. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66771. /**
  66772. * Clones the raw cube texture.
  66773. * @return a new cube texture
  66774. */
  66775. clone(): CubeTexture;
  66776. /** @hidden */
  66777. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66778. }
  66779. }
  66780. declare module BABYLON {
  66781. /**
  66782. * Class used to store 2D array textures containing user data
  66783. */
  66784. export class RawTexture2DArray extends Texture {
  66785. /** Gets or sets the texture format to use */
  66786. format: number;
  66787. /**
  66788. * Create a new RawTexture2DArray
  66789. * @param data defines the data of the texture
  66790. * @param width defines the width of the texture
  66791. * @param height defines the height of the texture
  66792. * @param depth defines the number of layers of the texture
  66793. * @param format defines the texture format to use
  66794. * @param scene defines the hosting scene
  66795. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66796. * @param invertY defines if texture must be stored with Y axis inverted
  66797. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66798. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66799. */
  66800. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66801. /** Gets or sets the texture format to use */
  66802. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66803. /**
  66804. * Update the texture with new data
  66805. * @param data defines the data to store in the texture
  66806. */
  66807. update(data: ArrayBufferView): void;
  66808. }
  66809. }
  66810. declare module BABYLON {
  66811. /**
  66812. * Class used to store 3D textures containing user data
  66813. */
  66814. export class RawTexture3D extends Texture {
  66815. /** Gets or sets the texture format to use */
  66816. format: number;
  66817. /**
  66818. * Create a new RawTexture3D
  66819. * @param data defines the data of the texture
  66820. * @param width defines the width of the texture
  66821. * @param height defines the height of the texture
  66822. * @param depth defines the depth of the texture
  66823. * @param format defines the texture format to use
  66824. * @param scene defines the hosting scene
  66825. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66826. * @param invertY defines if texture must be stored with Y axis inverted
  66827. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66828. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66829. */
  66830. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66831. /** Gets or sets the texture format to use */
  66832. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66833. /**
  66834. * Update the texture with new data
  66835. * @param data defines the data to store in the texture
  66836. */
  66837. update(data: ArrayBufferView): void;
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * Creates a refraction texture used by refraction channel of the standard material.
  66843. * It is like a mirror but to see through a material.
  66844. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66845. */
  66846. export class RefractionTexture extends RenderTargetTexture {
  66847. /**
  66848. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66849. * 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.
  66850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66851. */
  66852. refractionPlane: Plane;
  66853. /**
  66854. * Define how deep under the surface we should see.
  66855. */
  66856. depth: number;
  66857. /**
  66858. * Creates a refraction texture used by refraction channel of the standard material.
  66859. * It is like a mirror but to see through a material.
  66860. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66861. * @param name Define the texture name
  66862. * @param size Define the size of the underlying texture
  66863. * @param scene Define the scene the refraction belongs to
  66864. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66865. */
  66866. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66867. /**
  66868. * Clone the refraction texture.
  66869. * @returns the cloned texture
  66870. */
  66871. clone(): RefractionTexture;
  66872. /**
  66873. * Serialize the texture to a JSON representation you could use in Parse later on
  66874. * @returns the serialized JSON representation
  66875. */
  66876. serialize(): any;
  66877. }
  66878. }
  66879. declare module BABYLON {
  66880. /**
  66881. * Block used to add support for vertex skinning (bones)
  66882. */
  66883. export class BonesBlock extends NodeMaterialBlock {
  66884. /**
  66885. * Creates a new BonesBlock
  66886. * @param name defines the block name
  66887. */
  66888. constructor(name: string);
  66889. /**
  66890. * Initialize the block and prepare the context for build
  66891. * @param state defines the state that will be used for the build
  66892. */
  66893. initialize(state: NodeMaterialBuildState): void;
  66894. /**
  66895. * Gets the current class name
  66896. * @returns the class name
  66897. */
  66898. getClassName(): string;
  66899. /**
  66900. * Gets the matrix indices input component
  66901. */
  66902. get matricesIndices(): NodeMaterialConnectionPoint;
  66903. /**
  66904. * Gets the matrix weights input component
  66905. */
  66906. get matricesWeights(): NodeMaterialConnectionPoint;
  66907. /**
  66908. * Gets the extra matrix indices input component
  66909. */
  66910. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66911. /**
  66912. * Gets the extra matrix weights input component
  66913. */
  66914. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the world input component
  66917. */
  66918. get world(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the output component
  66921. */
  66922. get output(): NodeMaterialConnectionPoint;
  66923. autoConfigure(material: NodeMaterial): void;
  66924. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66927. protected _buildBlock(state: NodeMaterialBuildState): this;
  66928. }
  66929. }
  66930. declare module BABYLON {
  66931. /**
  66932. * Block used to add support for instances
  66933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66934. */
  66935. export class InstancesBlock extends NodeMaterialBlock {
  66936. /**
  66937. * Creates a new InstancesBlock
  66938. * @param name defines the block name
  66939. */
  66940. constructor(name: string);
  66941. /**
  66942. * Gets the current class name
  66943. * @returns the class name
  66944. */
  66945. getClassName(): string;
  66946. /**
  66947. * Gets the first world row input component
  66948. */
  66949. get world0(): NodeMaterialConnectionPoint;
  66950. /**
  66951. * Gets the second world row input component
  66952. */
  66953. get world1(): NodeMaterialConnectionPoint;
  66954. /**
  66955. * Gets the third world row input component
  66956. */
  66957. get world2(): NodeMaterialConnectionPoint;
  66958. /**
  66959. * Gets the forth world row input component
  66960. */
  66961. get world3(): NodeMaterialConnectionPoint;
  66962. /**
  66963. * Gets the world input component
  66964. */
  66965. get world(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the output component
  66968. */
  66969. get output(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the isntanceID component
  66972. */
  66973. get instanceID(): NodeMaterialConnectionPoint;
  66974. autoConfigure(material: NodeMaterial): void;
  66975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66976. protected _buildBlock(state: NodeMaterialBuildState): this;
  66977. }
  66978. }
  66979. declare module BABYLON {
  66980. /**
  66981. * Block used to add morph targets support to vertex shader
  66982. */
  66983. export class MorphTargetsBlock extends NodeMaterialBlock {
  66984. private _repeatableContentAnchor;
  66985. /**
  66986. * Create a new MorphTargetsBlock
  66987. * @param name defines the block name
  66988. */
  66989. constructor(name: string);
  66990. /**
  66991. * Gets the current class name
  66992. * @returns the class name
  66993. */
  66994. getClassName(): string;
  66995. /**
  66996. * Gets the position input component
  66997. */
  66998. get position(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the normal input component
  67001. */
  67002. get normal(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the tangent input component
  67005. */
  67006. get tangent(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the tangent input component
  67009. */
  67010. get uv(): NodeMaterialConnectionPoint;
  67011. /**
  67012. * Gets the position output component
  67013. */
  67014. get positionOutput(): NodeMaterialConnectionPoint;
  67015. /**
  67016. * Gets the normal output component
  67017. */
  67018. get normalOutput(): NodeMaterialConnectionPoint;
  67019. /**
  67020. * Gets the tangent output component
  67021. */
  67022. get tangentOutput(): NodeMaterialConnectionPoint;
  67023. /**
  67024. * Gets the tangent output component
  67025. */
  67026. get uvOutput(): NodeMaterialConnectionPoint;
  67027. initialize(state: NodeMaterialBuildState): void;
  67028. autoConfigure(material: NodeMaterial): void;
  67029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67031. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67032. protected _buildBlock(state: NodeMaterialBuildState): this;
  67033. }
  67034. }
  67035. declare module BABYLON {
  67036. /**
  67037. * Block used to get data information from a light
  67038. */
  67039. export class LightInformationBlock extends NodeMaterialBlock {
  67040. private _lightDataUniformName;
  67041. private _lightColorUniformName;
  67042. private _lightTypeDefineName;
  67043. /**
  67044. * Gets or sets the light associated with this block
  67045. */
  67046. light: Nullable<Light>;
  67047. /**
  67048. * Creates a new LightInformationBlock
  67049. * @param name defines the block name
  67050. */
  67051. constructor(name: string);
  67052. /**
  67053. * Gets the current class name
  67054. * @returns the class name
  67055. */
  67056. getClassName(): string;
  67057. /**
  67058. * Gets the world position input component
  67059. */
  67060. get worldPosition(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the direction output component
  67063. */
  67064. get direction(): NodeMaterialConnectionPoint;
  67065. /**
  67066. * Gets the direction output component
  67067. */
  67068. get color(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the direction output component
  67071. */
  67072. get intensity(): NodeMaterialConnectionPoint;
  67073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67075. protected _buildBlock(state: NodeMaterialBuildState): this;
  67076. serialize(): any;
  67077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67078. }
  67079. }
  67080. declare module BABYLON {
  67081. /**
  67082. * Block used to add image processing support to fragment shader
  67083. */
  67084. export class ImageProcessingBlock extends NodeMaterialBlock {
  67085. /**
  67086. * Create a new ImageProcessingBlock
  67087. * @param name defines the block name
  67088. */
  67089. constructor(name: string);
  67090. /**
  67091. * Gets the current class name
  67092. * @returns the class name
  67093. */
  67094. getClassName(): string;
  67095. /**
  67096. * Gets the color input component
  67097. */
  67098. get color(): NodeMaterialConnectionPoint;
  67099. /**
  67100. * Gets the output component
  67101. */
  67102. get output(): NodeMaterialConnectionPoint;
  67103. /**
  67104. * Initialize the block and prepare the context for build
  67105. * @param state defines the state that will be used for the build
  67106. */
  67107. initialize(state: NodeMaterialBuildState): void;
  67108. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67111. protected _buildBlock(state: NodeMaterialBuildState): this;
  67112. }
  67113. }
  67114. declare module BABYLON {
  67115. /**
  67116. * Block used to pertub normals based on a normal map
  67117. */
  67118. export class PerturbNormalBlock extends NodeMaterialBlock {
  67119. private _tangentSpaceParameterName;
  67120. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67121. invertX: boolean;
  67122. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67123. invertY: boolean;
  67124. /**
  67125. * Create a new PerturbNormalBlock
  67126. * @param name defines the block name
  67127. */
  67128. constructor(name: string);
  67129. /**
  67130. * Gets the current class name
  67131. * @returns the class name
  67132. */
  67133. getClassName(): string;
  67134. /**
  67135. * Gets the world position input component
  67136. */
  67137. get worldPosition(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the world normal input component
  67140. */
  67141. get worldNormal(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the world tangent input component
  67144. */
  67145. get worldTangent(): NodeMaterialConnectionPoint;
  67146. /**
  67147. * Gets the uv input component
  67148. */
  67149. get uv(): NodeMaterialConnectionPoint;
  67150. /**
  67151. * Gets the normal map color input component
  67152. */
  67153. get normalMapColor(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the strength input component
  67156. */
  67157. get strength(): NodeMaterialConnectionPoint;
  67158. /**
  67159. * Gets the output component
  67160. */
  67161. get output(): NodeMaterialConnectionPoint;
  67162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67164. autoConfigure(material: NodeMaterial): void;
  67165. protected _buildBlock(state: NodeMaterialBuildState): this;
  67166. protected _dumpPropertiesCode(): string;
  67167. serialize(): any;
  67168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67169. }
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * Block used to discard a pixel if a value is smaller than a cutoff
  67174. */
  67175. export class DiscardBlock extends NodeMaterialBlock {
  67176. /**
  67177. * Create a new DiscardBlock
  67178. * @param name defines the block name
  67179. */
  67180. constructor(name: string);
  67181. /**
  67182. * Gets the current class name
  67183. * @returns the class name
  67184. */
  67185. getClassName(): string;
  67186. /**
  67187. * Gets the color input component
  67188. */
  67189. get value(): NodeMaterialConnectionPoint;
  67190. /**
  67191. * Gets the cutoff input component
  67192. */
  67193. get cutoff(): NodeMaterialConnectionPoint;
  67194. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67195. }
  67196. }
  67197. declare module BABYLON {
  67198. /**
  67199. * Block used to test if the fragment shader is front facing
  67200. */
  67201. export class FrontFacingBlock extends NodeMaterialBlock {
  67202. /**
  67203. * Creates a new FrontFacingBlock
  67204. * @param name defines the block name
  67205. */
  67206. constructor(name: string);
  67207. /**
  67208. * Gets the current class name
  67209. * @returns the class name
  67210. */
  67211. getClassName(): string;
  67212. /**
  67213. * Gets the output component
  67214. */
  67215. get output(): NodeMaterialConnectionPoint;
  67216. protected _buildBlock(state: NodeMaterialBuildState): this;
  67217. }
  67218. }
  67219. declare module BABYLON {
  67220. /**
  67221. * Block used to get the derivative value on x and y of a given input
  67222. */
  67223. export class DerivativeBlock extends NodeMaterialBlock {
  67224. /**
  67225. * Create a new DerivativeBlock
  67226. * @param name defines the block name
  67227. */
  67228. constructor(name: string);
  67229. /**
  67230. * Gets the current class name
  67231. * @returns the class name
  67232. */
  67233. getClassName(): string;
  67234. /**
  67235. * Gets the input component
  67236. */
  67237. get input(): NodeMaterialConnectionPoint;
  67238. /**
  67239. * Gets the derivative output on x
  67240. */
  67241. get dx(): NodeMaterialConnectionPoint;
  67242. /**
  67243. * Gets the derivative output on y
  67244. */
  67245. get dy(): NodeMaterialConnectionPoint;
  67246. protected _buildBlock(state: NodeMaterialBuildState): this;
  67247. }
  67248. }
  67249. declare module BABYLON {
  67250. /**
  67251. * Block used to make gl_FragCoord available
  67252. */
  67253. export class FragCoordBlock extends NodeMaterialBlock {
  67254. /**
  67255. * Creates a new FragCoordBlock
  67256. * @param name defines the block name
  67257. */
  67258. constructor(name: string);
  67259. /**
  67260. * Gets the current class name
  67261. * @returns the class name
  67262. */
  67263. getClassName(): string;
  67264. /**
  67265. * Gets the xy component
  67266. */
  67267. get xy(): NodeMaterialConnectionPoint;
  67268. /**
  67269. * Gets the xyz component
  67270. */
  67271. get xyz(): NodeMaterialConnectionPoint;
  67272. /**
  67273. * Gets the xyzw component
  67274. */
  67275. get xyzw(): NodeMaterialConnectionPoint;
  67276. /**
  67277. * Gets the x component
  67278. */
  67279. get x(): NodeMaterialConnectionPoint;
  67280. /**
  67281. * Gets the y component
  67282. */
  67283. get y(): NodeMaterialConnectionPoint;
  67284. /**
  67285. * Gets the z component
  67286. */
  67287. get z(): NodeMaterialConnectionPoint;
  67288. /**
  67289. * Gets the w component
  67290. */
  67291. get output(): NodeMaterialConnectionPoint;
  67292. protected writeOutputs(state: NodeMaterialBuildState): string;
  67293. protected _buildBlock(state: NodeMaterialBuildState): this;
  67294. }
  67295. }
  67296. declare module BABYLON {
  67297. /**
  67298. * Block used to get the screen sizes
  67299. */
  67300. export class ScreenSizeBlock extends NodeMaterialBlock {
  67301. private _varName;
  67302. private _scene;
  67303. /**
  67304. * Creates a new ScreenSizeBlock
  67305. * @param name defines the block name
  67306. */
  67307. constructor(name: string);
  67308. /**
  67309. * Gets the current class name
  67310. * @returns the class name
  67311. */
  67312. getClassName(): string;
  67313. /**
  67314. * Gets the xy component
  67315. */
  67316. get xy(): NodeMaterialConnectionPoint;
  67317. /**
  67318. * Gets the x component
  67319. */
  67320. get x(): NodeMaterialConnectionPoint;
  67321. /**
  67322. * Gets the y component
  67323. */
  67324. get y(): NodeMaterialConnectionPoint;
  67325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67326. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67327. protected _buildBlock(state: NodeMaterialBuildState): this;
  67328. }
  67329. }
  67330. declare module BABYLON {
  67331. /**
  67332. * Block used to add support for scene fog
  67333. */
  67334. export class FogBlock extends NodeMaterialBlock {
  67335. private _fogDistanceName;
  67336. private _fogParameters;
  67337. /**
  67338. * Create a new FogBlock
  67339. * @param name defines the block name
  67340. */
  67341. constructor(name: string);
  67342. /**
  67343. * Gets the current class name
  67344. * @returns the class name
  67345. */
  67346. getClassName(): string;
  67347. /**
  67348. * Gets the world position input component
  67349. */
  67350. get worldPosition(): NodeMaterialConnectionPoint;
  67351. /**
  67352. * Gets the view input component
  67353. */
  67354. get view(): NodeMaterialConnectionPoint;
  67355. /**
  67356. * Gets the color input component
  67357. */
  67358. get input(): NodeMaterialConnectionPoint;
  67359. /**
  67360. * Gets the fog color input component
  67361. */
  67362. get fogColor(): NodeMaterialConnectionPoint;
  67363. /**
  67364. * Gets the output component
  67365. */
  67366. get output(): NodeMaterialConnectionPoint;
  67367. autoConfigure(material: NodeMaterial): void;
  67368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67370. protected _buildBlock(state: NodeMaterialBuildState): this;
  67371. }
  67372. }
  67373. declare module BABYLON {
  67374. /**
  67375. * Block used to add light in the fragment shader
  67376. */
  67377. export class LightBlock extends NodeMaterialBlock {
  67378. private _lightId;
  67379. /**
  67380. * Gets or sets the light associated with this block
  67381. */
  67382. light: Nullable<Light>;
  67383. /**
  67384. * Create a new LightBlock
  67385. * @param name defines the block name
  67386. */
  67387. constructor(name: string);
  67388. /**
  67389. * Gets the current class name
  67390. * @returns the class name
  67391. */
  67392. getClassName(): string;
  67393. /**
  67394. * Gets the world position input component
  67395. */
  67396. get worldPosition(): NodeMaterialConnectionPoint;
  67397. /**
  67398. * Gets the world normal input component
  67399. */
  67400. get worldNormal(): NodeMaterialConnectionPoint;
  67401. /**
  67402. * Gets the camera (or eye) position component
  67403. */
  67404. get cameraPosition(): NodeMaterialConnectionPoint;
  67405. /**
  67406. * Gets the glossiness component
  67407. */
  67408. get glossiness(): NodeMaterialConnectionPoint;
  67409. /**
  67410. * Gets the glossinness power component
  67411. */
  67412. get glossPower(): NodeMaterialConnectionPoint;
  67413. /**
  67414. * Gets the diffuse color component
  67415. */
  67416. get diffuseColor(): NodeMaterialConnectionPoint;
  67417. /**
  67418. * Gets the specular color component
  67419. */
  67420. get specularColor(): NodeMaterialConnectionPoint;
  67421. /**
  67422. * Gets the view matrix component
  67423. */
  67424. get view(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the diffuse output component
  67427. */
  67428. get diffuseOutput(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the specular output component
  67431. */
  67432. get specularOutput(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the shadow output component
  67435. */
  67436. get shadow(): NodeMaterialConnectionPoint;
  67437. autoConfigure(material: NodeMaterial): void;
  67438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67439. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67441. private _injectVertexCode;
  67442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67443. serialize(): any;
  67444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67445. }
  67446. }
  67447. declare module BABYLON {
  67448. /**
  67449. * Block used to read a reflection texture from a sampler
  67450. */
  67451. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67452. /**
  67453. * Create a new ReflectionTextureBlock
  67454. * @param name defines the block name
  67455. */
  67456. constructor(name: string);
  67457. /**
  67458. * Gets the current class name
  67459. * @returns the class name
  67460. */
  67461. getClassName(): string;
  67462. /**
  67463. * Gets the world position input component
  67464. */
  67465. get position(): NodeMaterialConnectionPoint;
  67466. /**
  67467. * Gets the world position input component
  67468. */
  67469. get worldPosition(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the world normal input component
  67472. */
  67473. get worldNormal(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the world input component
  67476. */
  67477. get world(): NodeMaterialConnectionPoint;
  67478. /**
  67479. * Gets the camera (or eye) position component
  67480. */
  67481. get cameraPosition(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the view input component
  67484. */
  67485. get view(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the rgb output component
  67488. */
  67489. get rgb(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the rgba output component
  67492. */
  67493. get rgba(): NodeMaterialConnectionPoint;
  67494. /**
  67495. * Gets the r output component
  67496. */
  67497. get r(): NodeMaterialConnectionPoint;
  67498. /**
  67499. * Gets the g output component
  67500. */
  67501. get g(): NodeMaterialConnectionPoint;
  67502. /**
  67503. * Gets the b output component
  67504. */
  67505. get b(): NodeMaterialConnectionPoint;
  67506. /**
  67507. * Gets the a output component
  67508. */
  67509. get a(): NodeMaterialConnectionPoint;
  67510. autoConfigure(material: NodeMaterial): void;
  67511. protected _buildBlock(state: NodeMaterialBuildState): this;
  67512. }
  67513. }
  67514. declare module BABYLON {
  67515. /**
  67516. * Block used to add 2 vectors
  67517. */
  67518. export class AddBlock extends NodeMaterialBlock {
  67519. /**
  67520. * Creates a new AddBlock
  67521. * @param name defines the block name
  67522. */
  67523. constructor(name: string);
  67524. /**
  67525. * Gets the current class name
  67526. * @returns the class name
  67527. */
  67528. getClassName(): string;
  67529. /**
  67530. * Gets the left operand input component
  67531. */
  67532. get left(): NodeMaterialConnectionPoint;
  67533. /**
  67534. * Gets the right operand input component
  67535. */
  67536. get right(): NodeMaterialConnectionPoint;
  67537. /**
  67538. * Gets the output component
  67539. */
  67540. get output(): NodeMaterialConnectionPoint;
  67541. protected _buildBlock(state: NodeMaterialBuildState): this;
  67542. }
  67543. }
  67544. declare module BABYLON {
  67545. /**
  67546. * Block used to scale a vector by a float
  67547. */
  67548. export class ScaleBlock extends NodeMaterialBlock {
  67549. /**
  67550. * Creates a new ScaleBlock
  67551. * @param name defines the block name
  67552. */
  67553. constructor(name: string);
  67554. /**
  67555. * Gets the current class name
  67556. * @returns the class name
  67557. */
  67558. getClassName(): string;
  67559. /**
  67560. * Gets the input component
  67561. */
  67562. get input(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the factor input component
  67565. */
  67566. get factor(): NodeMaterialConnectionPoint;
  67567. /**
  67568. * Gets the output component
  67569. */
  67570. get output(): NodeMaterialConnectionPoint;
  67571. protected _buildBlock(state: NodeMaterialBuildState): this;
  67572. }
  67573. }
  67574. declare module BABYLON {
  67575. /**
  67576. * Block used to clamp a float
  67577. */
  67578. export class ClampBlock extends NodeMaterialBlock {
  67579. /** Gets or sets the minimum range */
  67580. minimum: number;
  67581. /** Gets or sets the maximum range */
  67582. maximum: number;
  67583. /**
  67584. * Creates a new ClampBlock
  67585. * @param name defines the block name
  67586. */
  67587. constructor(name: string);
  67588. /**
  67589. * Gets the current class name
  67590. * @returns the class name
  67591. */
  67592. getClassName(): string;
  67593. /**
  67594. * Gets the value input component
  67595. */
  67596. get value(): NodeMaterialConnectionPoint;
  67597. /**
  67598. * Gets the output component
  67599. */
  67600. get output(): NodeMaterialConnectionPoint;
  67601. protected _buildBlock(state: NodeMaterialBuildState): this;
  67602. protected _dumpPropertiesCode(): string;
  67603. serialize(): any;
  67604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67605. }
  67606. }
  67607. declare module BABYLON {
  67608. /**
  67609. * Block used to apply a cross product between 2 vectors
  67610. */
  67611. export class CrossBlock extends NodeMaterialBlock {
  67612. /**
  67613. * Creates a new CrossBlock
  67614. * @param name defines the block name
  67615. */
  67616. constructor(name: string);
  67617. /**
  67618. * Gets the current class name
  67619. * @returns the class name
  67620. */
  67621. getClassName(): string;
  67622. /**
  67623. * Gets the left operand input component
  67624. */
  67625. get left(): NodeMaterialConnectionPoint;
  67626. /**
  67627. * Gets the right operand input component
  67628. */
  67629. get right(): NodeMaterialConnectionPoint;
  67630. /**
  67631. * Gets the output component
  67632. */
  67633. get output(): NodeMaterialConnectionPoint;
  67634. protected _buildBlock(state: NodeMaterialBuildState): this;
  67635. }
  67636. }
  67637. declare module BABYLON {
  67638. /**
  67639. * Block used to apply a dot product between 2 vectors
  67640. */
  67641. export class DotBlock extends NodeMaterialBlock {
  67642. /**
  67643. * Creates a new DotBlock
  67644. * @param name defines the block name
  67645. */
  67646. constructor(name: string);
  67647. /**
  67648. * Gets the current class name
  67649. * @returns the class name
  67650. */
  67651. getClassName(): string;
  67652. /**
  67653. * Gets the left operand input component
  67654. */
  67655. get left(): NodeMaterialConnectionPoint;
  67656. /**
  67657. * Gets the right operand input component
  67658. */
  67659. get right(): NodeMaterialConnectionPoint;
  67660. /**
  67661. * Gets the output component
  67662. */
  67663. get output(): NodeMaterialConnectionPoint;
  67664. protected _buildBlock(state: NodeMaterialBuildState): this;
  67665. }
  67666. }
  67667. declare module BABYLON {
  67668. /**
  67669. * Block used to normalize a vector
  67670. */
  67671. export class NormalizeBlock extends NodeMaterialBlock {
  67672. /**
  67673. * Creates a new NormalizeBlock
  67674. * @param name defines the block name
  67675. */
  67676. constructor(name: string);
  67677. /**
  67678. * Gets the current class name
  67679. * @returns the class name
  67680. */
  67681. getClassName(): string;
  67682. /**
  67683. * Gets the input component
  67684. */
  67685. get input(): NodeMaterialConnectionPoint;
  67686. /**
  67687. * Gets the output component
  67688. */
  67689. get output(): NodeMaterialConnectionPoint;
  67690. protected _buildBlock(state: NodeMaterialBuildState): this;
  67691. }
  67692. }
  67693. declare module BABYLON {
  67694. /**
  67695. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67696. */
  67697. export class ColorMergerBlock extends NodeMaterialBlock {
  67698. /**
  67699. * Create a new ColorMergerBlock
  67700. * @param name defines the block name
  67701. */
  67702. constructor(name: string);
  67703. /**
  67704. * Gets the current class name
  67705. * @returns the class name
  67706. */
  67707. getClassName(): string;
  67708. /**
  67709. * Gets the rgb component (input)
  67710. */
  67711. get rgbIn(): NodeMaterialConnectionPoint;
  67712. /**
  67713. * Gets the r component (input)
  67714. */
  67715. get r(): NodeMaterialConnectionPoint;
  67716. /**
  67717. * Gets the g component (input)
  67718. */
  67719. get g(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the b component (input)
  67722. */
  67723. get b(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the a component (input)
  67726. */
  67727. get a(): NodeMaterialConnectionPoint;
  67728. /**
  67729. * Gets the rgba component (output)
  67730. */
  67731. get rgba(): NodeMaterialConnectionPoint;
  67732. /**
  67733. * Gets the rgb component (output)
  67734. */
  67735. get rgbOut(): NodeMaterialConnectionPoint;
  67736. /**
  67737. * Gets the rgb component (output)
  67738. * @deprecated Please use rgbOut instead.
  67739. */
  67740. get rgb(): NodeMaterialConnectionPoint;
  67741. protected _buildBlock(state: NodeMaterialBuildState): this;
  67742. }
  67743. }
  67744. declare module BABYLON {
  67745. /**
  67746. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67747. */
  67748. export class VectorSplitterBlock extends NodeMaterialBlock {
  67749. /**
  67750. * Create a new VectorSplitterBlock
  67751. * @param name defines the block name
  67752. */
  67753. constructor(name: string);
  67754. /**
  67755. * Gets the current class name
  67756. * @returns the class name
  67757. */
  67758. getClassName(): string;
  67759. /**
  67760. * Gets the xyzw component (input)
  67761. */
  67762. get xyzw(): NodeMaterialConnectionPoint;
  67763. /**
  67764. * Gets the xyz component (input)
  67765. */
  67766. get xyzIn(): NodeMaterialConnectionPoint;
  67767. /**
  67768. * Gets the xy component (input)
  67769. */
  67770. get xyIn(): NodeMaterialConnectionPoint;
  67771. /**
  67772. * Gets the xyz component (output)
  67773. */
  67774. get xyzOut(): NodeMaterialConnectionPoint;
  67775. /**
  67776. * Gets the xy component (output)
  67777. */
  67778. get xyOut(): NodeMaterialConnectionPoint;
  67779. /**
  67780. * Gets the x component (output)
  67781. */
  67782. get x(): NodeMaterialConnectionPoint;
  67783. /**
  67784. * Gets the y component (output)
  67785. */
  67786. get y(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the z component (output)
  67789. */
  67790. get z(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the w component (output)
  67793. */
  67794. get w(): NodeMaterialConnectionPoint;
  67795. protected _inputRename(name: string): string;
  67796. protected _outputRename(name: string): string;
  67797. protected _buildBlock(state: NodeMaterialBuildState): this;
  67798. }
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * Block used to lerp between 2 values
  67803. */
  67804. export class LerpBlock extends NodeMaterialBlock {
  67805. /**
  67806. * Creates a new LerpBlock
  67807. * @param name defines the block name
  67808. */
  67809. constructor(name: string);
  67810. /**
  67811. * Gets the current class name
  67812. * @returns the class name
  67813. */
  67814. getClassName(): string;
  67815. /**
  67816. * Gets the left operand input component
  67817. */
  67818. get left(): NodeMaterialConnectionPoint;
  67819. /**
  67820. * Gets the right operand input component
  67821. */
  67822. get right(): NodeMaterialConnectionPoint;
  67823. /**
  67824. * Gets the gradient operand input component
  67825. */
  67826. get gradient(): NodeMaterialConnectionPoint;
  67827. /**
  67828. * Gets the output component
  67829. */
  67830. get output(): NodeMaterialConnectionPoint;
  67831. protected _buildBlock(state: NodeMaterialBuildState): this;
  67832. }
  67833. }
  67834. declare module BABYLON {
  67835. /**
  67836. * Block used to divide 2 vectors
  67837. */
  67838. export class DivideBlock extends NodeMaterialBlock {
  67839. /**
  67840. * Creates a new DivideBlock
  67841. * @param name defines the block name
  67842. */
  67843. constructor(name: string);
  67844. /**
  67845. * Gets the current class name
  67846. * @returns the class name
  67847. */
  67848. getClassName(): string;
  67849. /**
  67850. * Gets the left operand input component
  67851. */
  67852. get left(): NodeMaterialConnectionPoint;
  67853. /**
  67854. * Gets the right operand input component
  67855. */
  67856. get right(): NodeMaterialConnectionPoint;
  67857. /**
  67858. * Gets the output component
  67859. */
  67860. get output(): NodeMaterialConnectionPoint;
  67861. protected _buildBlock(state: NodeMaterialBuildState): this;
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /**
  67866. * Block used to subtract 2 vectors
  67867. */
  67868. export class SubtractBlock extends NodeMaterialBlock {
  67869. /**
  67870. * Creates a new SubtractBlock
  67871. * @param name defines the block name
  67872. */
  67873. constructor(name: string);
  67874. /**
  67875. * Gets the current class name
  67876. * @returns the class name
  67877. */
  67878. getClassName(): string;
  67879. /**
  67880. * Gets the left operand input component
  67881. */
  67882. get left(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the right operand input component
  67885. */
  67886. get right(): NodeMaterialConnectionPoint;
  67887. /**
  67888. * Gets the output component
  67889. */
  67890. get output(): NodeMaterialConnectionPoint;
  67891. protected _buildBlock(state: NodeMaterialBuildState): this;
  67892. }
  67893. }
  67894. declare module BABYLON {
  67895. /**
  67896. * Block used to step a value
  67897. */
  67898. export class StepBlock extends NodeMaterialBlock {
  67899. /**
  67900. * Creates a new StepBlock
  67901. * @param name defines the block name
  67902. */
  67903. constructor(name: string);
  67904. /**
  67905. * Gets the current class name
  67906. * @returns the class name
  67907. */
  67908. getClassName(): string;
  67909. /**
  67910. * Gets the value operand input component
  67911. */
  67912. get value(): NodeMaterialConnectionPoint;
  67913. /**
  67914. * Gets the edge operand input component
  67915. */
  67916. get edge(): NodeMaterialConnectionPoint;
  67917. /**
  67918. * Gets the output component
  67919. */
  67920. get output(): NodeMaterialConnectionPoint;
  67921. protected _buildBlock(state: NodeMaterialBuildState): this;
  67922. }
  67923. }
  67924. declare module BABYLON {
  67925. /**
  67926. * Block used to get the opposite (1 - x) of a value
  67927. */
  67928. export class OneMinusBlock extends NodeMaterialBlock {
  67929. /**
  67930. * Creates a new OneMinusBlock
  67931. * @param name defines the block name
  67932. */
  67933. constructor(name: string);
  67934. /**
  67935. * Gets the current class name
  67936. * @returns the class name
  67937. */
  67938. getClassName(): string;
  67939. /**
  67940. * Gets the input component
  67941. */
  67942. get input(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the output component
  67945. */
  67946. get output(): NodeMaterialConnectionPoint;
  67947. protected _buildBlock(state: NodeMaterialBuildState): this;
  67948. }
  67949. }
  67950. declare module BABYLON {
  67951. /**
  67952. * Block used to get the view direction
  67953. */
  67954. export class ViewDirectionBlock extends NodeMaterialBlock {
  67955. /**
  67956. * Creates a new ViewDirectionBlock
  67957. * @param name defines the block name
  67958. */
  67959. constructor(name: string);
  67960. /**
  67961. * Gets the current class name
  67962. * @returns the class name
  67963. */
  67964. getClassName(): string;
  67965. /**
  67966. * Gets the world position component
  67967. */
  67968. get worldPosition(): NodeMaterialConnectionPoint;
  67969. /**
  67970. * Gets the camera position component
  67971. */
  67972. get cameraPosition(): NodeMaterialConnectionPoint;
  67973. /**
  67974. * Gets the output component
  67975. */
  67976. get output(): NodeMaterialConnectionPoint;
  67977. autoConfigure(material: NodeMaterial): void;
  67978. protected _buildBlock(state: NodeMaterialBuildState): this;
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /**
  67983. * Block used to compute fresnel value
  67984. */
  67985. export class FresnelBlock extends NodeMaterialBlock {
  67986. /**
  67987. * Create a new FresnelBlock
  67988. * @param name defines the block name
  67989. */
  67990. constructor(name: string);
  67991. /**
  67992. * Gets the current class name
  67993. * @returns the class name
  67994. */
  67995. getClassName(): string;
  67996. /**
  67997. * Gets the world normal input component
  67998. */
  67999. get worldNormal(): NodeMaterialConnectionPoint;
  68000. /**
  68001. * Gets the view direction input component
  68002. */
  68003. get viewDirection(): NodeMaterialConnectionPoint;
  68004. /**
  68005. * Gets the bias input component
  68006. */
  68007. get bias(): NodeMaterialConnectionPoint;
  68008. /**
  68009. * Gets the camera (or eye) position component
  68010. */
  68011. get power(): NodeMaterialConnectionPoint;
  68012. /**
  68013. * Gets the fresnel output component
  68014. */
  68015. get fresnel(): NodeMaterialConnectionPoint;
  68016. autoConfigure(material: NodeMaterial): void;
  68017. protected _buildBlock(state: NodeMaterialBuildState): this;
  68018. }
  68019. }
  68020. declare module BABYLON {
  68021. /**
  68022. * Block used to get the max of 2 values
  68023. */
  68024. export class MaxBlock extends NodeMaterialBlock {
  68025. /**
  68026. * Creates a new MaxBlock
  68027. * @param name defines the block name
  68028. */
  68029. constructor(name: string);
  68030. /**
  68031. * Gets the current class name
  68032. * @returns the class name
  68033. */
  68034. getClassName(): string;
  68035. /**
  68036. * Gets the left operand input component
  68037. */
  68038. get left(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the right operand input component
  68041. */
  68042. get right(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the output component
  68045. */
  68046. get output(): NodeMaterialConnectionPoint;
  68047. protected _buildBlock(state: NodeMaterialBuildState): this;
  68048. }
  68049. }
  68050. declare module BABYLON {
  68051. /**
  68052. * Block used to get the min of 2 values
  68053. */
  68054. export class MinBlock extends NodeMaterialBlock {
  68055. /**
  68056. * Creates a new MinBlock
  68057. * @param name defines the block name
  68058. */
  68059. constructor(name: string);
  68060. /**
  68061. * Gets the current class name
  68062. * @returns the class name
  68063. */
  68064. getClassName(): string;
  68065. /**
  68066. * Gets the left operand input component
  68067. */
  68068. get left(): NodeMaterialConnectionPoint;
  68069. /**
  68070. * Gets the right operand input component
  68071. */
  68072. get right(): NodeMaterialConnectionPoint;
  68073. /**
  68074. * Gets the output component
  68075. */
  68076. get output(): NodeMaterialConnectionPoint;
  68077. protected _buildBlock(state: NodeMaterialBuildState): this;
  68078. }
  68079. }
  68080. declare module BABYLON {
  68081. /**
  68082. * Block used to get the distance between 2 values
  68083. */
  68084. export class DistanceBlock extends NodeMaterialBlock {
  68085. /**
  68086. * Creates a new DistanceBlock
  68087. * @param name defines the block name
  68088. */
  68089. constructor(name: string);
  68090. /**
  68091. * Gets the current class name
  68092. * @returns the class name
  68093. */
  68094. getClassName(): string;
  68095. /**
  68096. * Gets the left operand input component
  68097. */
  68098. get left(): NodeMaterialConnectionPoint;
  68099. /**
  68100. * Gets the right operand input component
  68101. */
  68102. get right(): NodeMaterialConnectionPoint;
  68103. /**
  68104. * Gets the output component
  68105. */
  68106. get output(): NodeMaterialConnectionPoint;
  68107. protected _buildBlock(state: NodeMaterialBuildState): this;
  68108. }
  68109. }
  68110. declare module BABYLON {
  68111. /**
  68112. * Block used to get the length of a vector
  68113. */
  68114. export class LengthBlock extends NodeMaterialBlock {
  68115. /**
  68116. * Creates a new LengthBlock
  68117. * @param name defines the block name
  68118. */
  68119. constructor(name: string);
  68120. /**
  68121. * Gets the current class name
  68122. * @returns the class name
  68123. */
  68124. getClassName(): string;
  68125. /**
  68126. * Gets the value input component
  68127. */
  68128. get value(): NodeMaterialConnectionPoint;
  68129. /**
  68130. * Gets the output component
  68131. */
  68132. get output(): NodeMaterialConnectionPoint;
  68133. protected _buildBlock(state: NodeMaterialBuildState): this;
  68134. }
  68135. }
  68136. declare module BABYLON {
  68137. /**
  68138. * Block used to get negative version of a value (i.e. x * -1)
  68139. */
  68140. export class NegateBlock extends NodeMaterialBlock {
  68141. /**
  68142. * Creates a new NegateBlock
  68143. * @param name defines the block name
  68144. */
  68145. constructor(name: string);
  68146. /**
  68147. * Gets the current class name
  68148. * @returns the class name
  68149. */
  68150. getClassName(): string;
  68151. /**
  68152. * Gets the value input component
  68153. */
  68154. get value(): NodeMaterialConnectionPoint;
  68155. /**
  68156. * Gets the output component
  68157. */
  68158. get output(): NodeMaterialConnectionPoint;
  68159. protected _buildBlock(state: NodeMaterialBuildState): this;
  68160. }
  68161. }
  68162. declare module BABYLON {
  68163. /**
  68164. * Block used to get the value of the first parameter raised to the power of the second
  68165. */
  68166. export class PowBlock extends NodeMaterialBlock {
  68167. /**
  68168. * Creates a new PowBlock
  68169. * @param name defines the block name
  68170. */
  68171. constructor(name: string);
  68172. /**
  68173. * Gets the current class name
  68174. * @returns the class name
  68175. */
  68176. getClassName(): string;
  68177. /**
  68178. * Gets the value operand input component
  68179. */
  68180. get value(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the power operand input component
  68183. */
  68184. get power(): NodeMaterialConnectionPoint;
  68185. /**
  68186. * Gets the output component
  68187. */
  68188. get output(): NodeMaterialConnectionPoint;
  68189. protected _buildBlock(state: NodeMaterialBuildState): this;
  68190. }
  68191. }
  68192. declare module BABYLON {
  68193. /**
  68194. * Block used to get a random number
  68195. */
  68196. export class RandomNumberBlock extends NodeMaterialBlock {
  68197. /**
  68198. * Creates a new RandomNumberBlock
  68199. * @param name defines the block name
  68200. */
  68201. constructor(name: string);
  68202. /**
  68203. * Gets the current class name
  68204. * @returns the class name
  68205. */
  68206. getClassName(): string;
  68207. /**
  68208. * Gets the seed input component
  68209. */
  68210. get seed(): NodeMaterialConnectionPoint;
  68211. /**
  68212. * Gets the output component
  68213. */
  68214. get output(): NodeMaterialConnectionPoint;
  68215. protected _buildBlock(state: NodeMaterialBuildState): this;
  68216. }
  68217. }
  68218. declare module BABYLON {
  68219. /**
  68220. * Block used to compute arc tangent of 2 values
  68221. */
  68222. export class ArcTan2Block extends NodeMaterialBlock {
  68223. /**
  68224. * Creates a new ArcTan2Block
  68225. * @param name defines the block name
  68226. */
  68227. constructor(name: string);
  68228. /**
  68229. * Gets the current class name
  68230. * @returns the class name
  68231. */
  68232. getClassName(): string;
  68233. /**
  68234. * Gets the x operand input component
  68235. */
  68236. get x(): NodeMaterialConnectionPoint;
  68237. /**
  68238. * Gets the y operand input component
  68239. */
  68240. get y(): NodeMaterialConnectionPoint;
  68241. /**
  68242. * Gets the output component
  68243. */
  68244. get output(): NodeMaterialConnectionPoint;
  68245. protected _buildBlock(state: NodeMaterialBuildState): this;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /**
  68250. * Block used to smooth step a value
  68251. */
  68252. export class SmoothStepBlock extends NodeMaterialBlock {
  68253. /**
  68254. * Creates a new SmoothStepBlock
  68255. * @param name defines the block name
  68256. */
  68257. constructor(name: string);
  68258. /**
  68259. * Gets the current class name
  68260. * @returns the class name
  68261. */
  68262. getClassName(): string;
  68263. /**
  68264. * Gets the value operand input component
  68265. */
  68266. get value(): NodeMaterialConnectionPoint;
  68267. /**
  68268. * Gets the first edge operand input component
  68269. */
  68270. get edge0(): NodeMaterialConnectionPoint;
  68271. /**
  68272. * Gets the second edge operand input component
  68273. */
  68274. get edge1(): NodeMaterialConnectionPoint;
  68275. /**
  68276. * Gets the output component
  68277. */
  68278. get output(): NodeMaterialConnectionPoint;
  68279. protected _buildBlock(state: NodeMaterialBuildState): this;
  68280. }
  68281. }
  68282. declare module BABYLON {
  68283. /**
  68284. * Block used to get the reciprocal (1 / x) of a value
  68285. */
  68286. export class ReciprocalBlock extends NodeMaterialBlock {
  68287. /**
  68288. * Creates a new ReciprocalBlock
  68289. * @param name defines the block name
  68290. */
  68291. constructor(name: string);
  68292. /**
  68293. * Gets the current class name
  68294. * @returns the class name
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * Gets the input component
  68299. */
  68300. get input(): NodeMaterialConnectionPoint;
  68301. /**
  68302. * Gets the output component
  68303. */
  68304. get output(): NodeMaterialConnectionPoint;
  68305. protected _buildBlock(state: NodeMaterialBuildState): this;
  68306. }
  68307. }
  68308. declare module BABYLON {
  68309. /**
  68310. * Block used to replace a color by another one
  68311. */
  68312. export class ReplaceColorBlock extends NodeMaterialBlock {
  68313. /**
  68314. * Creates a new ReplaceColorBlock
  68315. * @param name defines the block name
  68316. */
  68317. constructor(name: string);
  68318. /**
  68319. * Gets the current class name
  68320. * @returns the class name
  68321. */
  68322. getClassName(): string;
  68323. /**
  68324. * Gets the value input component
  68325. */
  68326. get value(): NodeMaterialConnectionPoint;
  68327. /**
  68328. * Gets the reference input component
  68329. */
  68330. get reference(): NodeMaterialConnectionPoint;
  68331. /**
  68332. * Gets the distance input component
  68333. */
  68334. get distance(): NodeMaterialConnectionPoint;
  68335. /**
  68336. * Gets the replacement input component
  68337. */
  68338. get replacement(): NodeMaterialConnectionPoint;
  68339. /**
  68340. * Gets the output component
  68341. */
  68342. get output(): NodeMaterialConnectionPoint;
  68343. protected _buildBlock(state: NodeMaterialBuildState): this;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /**
  68348. * Block used to posterize a value
  68349. * @see https://en.wikipedia.org/wiki/Posterization
  68350. */
  68351. export class PosterizeBlock extends NodeMaterialBlock {
  68352. /**
  68353. * Creates a new PosterizeBlock
  68354. * @param name defines the block name
  68355. */
  68356. constructor(name: string);
  68357. /**
  68358. * Gets the current class name
  68359. * @returns the class name
  68360. */
  68361. getClassName(): string;
  68362. /**
  68363. * Gets the value input component
  68364. */
  68365. get value(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the steps input component
  68368. */
  68369. get steps(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the output component
  68372. */
  68373. get output(): NodeMaterialConnectionPoint;
  68374. protected _buildBlock(state: NodeMaterialBuildState): this;
  68375. }
  68376. }
  68377. declare module BABYLON {
  68378. /**
  68379. * Operations supported by the Wave block
  68380. */
  68381. export enum WaveBlockKind {
  68382. /** SawTooth */
  68383. SawTooth = 0,
  68384. /** Square */
  68385. Square = 1,
  68386. /** Triangle */
  68387. Triangle = 2
  68388. }
  68389. /**
  68390. * Block used to apply wave operation to floats
  68391. */
  68392. export class WaveBlock extends NodeMaterialBlock {
  68393. /**
  68394. * Gets or sets the kibnd of wave to be applied by the block
  68395. */
  68396. kind: WaveBlockKind;
  68397. /**
  68398. * Creates a new WaveBlock
  68399. * @param name defines the block name
  68400. */
  68401. constructor(name: string);
  68402. /**
  68403. * Gets the current class name
  68404. * @returns the class name
  68405. */
  68406. getClassName(): string;
  68407. /**
  68408. * Gets the input component
  68409. */
  68410. get input(): NodeMaterialConnectionPoint;
  68411. /**
  68412. * Gets the output component
  68413. */
  68414. get output(): NodeMaterialConnectionPoint;
  68415. protected _buildBlock(state: NodeMaterialBuildState): this;
  68416. serialize(): any;
  68417. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68418. }
  68419. }
  68420. declare module BABYLON {
  68421. /**
  68422. * Class used to store a color step for the GradientBlock
  68423. */
  68424. export class GradientBlockColorStep {
  68425. private _step;
  68426. /**
  68427. * Gets value indicating which step this color is associated with (between 0 and 1)
  68428. */
  68429. get step(): number;
  68430. /**
  68431. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68432. */
  68433. set step(val: number);
  68434. private _color;
  68435. /**
  68436. * Gets the color associated with this step
  68437. */
  68438. get color(): Color3;
  68439. /**
  68440. * Sets the color associated with this step
  68441. */
  68442. set color(val: Color3);
  68443. /**
  68444. * Creates a new GradientBlockColorStep
  68445. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68446. * @param color defines the color associated with this step
  68447. */
  68448. constructor(step: number, color: Color3);
  68449. }
  68450. /**
  68451. * Block used to return a color from a gradient based on an input value between 0 and 1
  68452. */
  68453. export class GradientBlock extends NodeMaterialBlock {
  68454. /**
  68455. * Gets or sets the list of color steps
  68456. */
  68457. colorSteps: GradientBlockColorStep[];
  68458. /** Gets an observable raised when the value is changed */
  68459. onValueChangedObservable: Observable<GradientBlock>;
  68460. /** calls observable when the value is changed*/
  68461. colorStepsUpdated(): void;
  68462. /**
  68463. * Creates a new GradientBlock
  68464. * @param name defines the block name
  68465. */
  68466. constructor(name: string);
  68467. /**
  68468. * Gets the current class name
  68469. * @returns the class name
  68470. */
  68471. getClassName(): string;
  68472. /**
  68473. * Gets the gradient input component
  68474. */
  68475. get gradient(): NodeMaterialConnectionPoint;
  68476. /**
  68477. * Gets the output component
  68478. */
  68479. get output(): NodeMaterialConnectionPoint;
  68480. private _writeColorConstant;
  68481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68482. serialize(): any;
  68483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68484. protected _dumpPropertiesCode(): string;
  68485. }
  68486. }
  68487. declare module BABYLON {
  68488. /**
  68489. * Block used to normalize lerp between 2 values
  68490. */
  68491. export class NLerpBlock extends NodeMaterialBlock {
  68492. /**
  68493. * Creates a new NLerpBlock
  68494. * @param name defines the block name
  68495. */
  68496. constructor(name: string);
  68497. /**
  68498. * Gets the current class name
  68499. * @returns the class name
  68500. */
  68501. getClassName(): string;
  68502. /**
  68503. * Gets the left operand input component
  68504. */
  68505. get left(): NodeMaterialConnectionPoint;
  68506. /**
  68507. * Gets the right operand input component
  68508. */
  68509. get right(): NodeMaterialConnectionPoint;
  68510. /**
  68511. * Gets the gradient operand input component
  68512. */
  68513. get gradient(): NodeMaterialConnectionPoint;
  68514. /**
  68515. * Gets the output component
  68516. */
  68517. get output(): NodeMaterialConnectionPoint;
  68518. protected _buildBlock(state: NodeMaterialBuildState): this;
  68519. }
  68520. }
  68521. declare module BABYLON {
  68522. /**
  68523. * block used to Generate a Worley Noise 3D Noise Pattern
  68524. */
  68525. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68526. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68527. manhattanDistance: boolean;
  68528. /**
  68529. * Creates a new WorleyNoise3DBlock
  68530. * @param name defines the block name
  68531. */
  68532. constructor(name: string);
  68533. /**
  68534. * Gets the current class name
  68535. * @returns the class name
  68536. */
  68537. getClassName(): string;
  68538. /**
  68539. * Gets the seed input component
  68540. */
  68541. get seed(): NodeMaterialConnectionPoint;
  68542. /**
  68543. * Gets the jitter input component
  68544. */
  68545. get jitter(): NodeMaterialConnectionPoint;
  68546. /**
  68547. * Gets the output component
  68548. */
  68549. get output(): NodeMaterialConnectionPoint;
  68550. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68551. /**
  68552. * Exposes the properties to the UI?
  68553. */
  68554. protected _dumpPropertiesCode(): string;
  68555. /**
  68556. * Exposes the properties to the Seralize?
  68557. */
  68558. serialize(): any;
  68559. /**
  68560. * Exposes the properties to the deseralize?
  68561. */
  68562. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68563. }
  68564. }
  68565. declare module BABYLON {
  68566. /**
  68567. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68568. */
  68569. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68570. /**
  68571. * Creates a new SimplexPerlin3DBlock
  68572. * @param name defines the block name
  68573. */
  68574. constructor(name: string);
  68575. /**
  68576. * Gets the current class name
  68577. * @returns the class name
  68578. */
  68579. getClassName(): string;
  68580. /**
  68581. * Gets the seed operand input component
  68582. */
  68583. get seed(): NodeMaterialConnectionPoint;
  68584. /**
  68585. * Gets the output component
  68586. */
  68587. get output(): NodeMaterialConnectionPoint;
  68588. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68589. }
  68590. }
  68591. declare module BABYLON {
  68592. /**
  68593. * Block used to blend normals
  68594. */
  68595. export class NormalBlendBlock extends NodeMaterialBlock {
  68596. /**
  68597. * Creates a new NormalBlendBlock
  68598. * @param name defines the block name
  68599. */
  68600. constructor(name: string);
  68601. /**
  68602. * Gets the current class name
  68603. * @returns the class name
  68604. */
  68605. getClassName(): string;
  68606. /**
  68607. * Gets the first input component
  68608. */
  68609. get normalMap0(): NodeMaterialConnectionPoint;
  68610. /**
  68611. * Gets the second input component
  68612. */
  68613. get normalMap1(): NodeMaterialConnectionPoint;
  68614. /**
  68615. * Gets the output component
  68616. */
  68617. get output(): NodeMaterialConnectionPoint;
  68618. protected _buildBlock(state: NodeMaterialBuildState): this;
  68619. }
  68620. }
  68621. declare module BABYLON {
  68622. /**
  68623. * Block used to rotate a 2d vector by a given angle
  68624. */
  68625. export class Rotate2dBlock extends NodeMaterialBlock {
  68626. /**
  68627. * Creates a new Rotate2dBlock
  68628. * @param name defines the block name
  68629. */
  68630. constructor(name: string);
  68631. /**
  68632. * Gets the current class name
  68633. * @returns the class name
  68634. */
  68635. getClassName(): string;
  68636. /**
  68637. * Gets the input vector
  68638. */
  68639. get input(): NodeMaterialConnectionPoint;
  68640. /**
  68641. * Gets the input angle
  68642. */
  68643. get angle(): NodeMaterialConnectionPoint;
  68644. /**
  68645. * Gets the output component
  68646. */
  68647. get output(): NodeMaterialConnectionPoint;
  68648. autoConfigure(material: NodeMaterial): void;
  68649. protected _buildBlock(state: NodeMaterialBuildState): this;
  68650. }
  68651. }
  68652. declare module BABYLON {
  68653. /**
  68654. * Block used to get the reflected vector from a direction and a normal
  68655. */
  68656. export class ReflectBlock extends NodeMaterialBlock {
  68657. /**
  68658. * Creates a new ReflectBlock
  68659. * @param name defines the block name
  68660. */
  68661. constructor(name: string);
  68662. /**
  68663. * Gets the current class name
  68664. * @returns the class name
  68665. */
  68666. getClassName(): string;
  68667. /**
  68668. * Gets the incident component
  68669. */
  68670. get incident(): NodeMaterialConnectionPoint;
  68671. /**
  68672. * Gets the normal component
  68673. */
  68674. get normal(): NodeMaterialConnectionPoint;
  68675. /**
  68676. * Gets the output component
  68677. */
  68678. get output(): NodeMaterialConnectionPoint;
  68679. protected _buildBlock(state: NodeMaterialBuildState): this;
  68680. }
  68681. }
  68682. declare module BABYLON {
  68683. /**
  68684. * Block used to get the refracted vector from a direction and a normal
  68685. */
  68686. export class RefractBlock extends NodeMaterialBlock {
  68687. /**
  68688. * Creates a new RefractBlock
  68689. * @param name defines the block name
  68690. */
  68691. constructor(name: string);
  68692. /**
  68693. * Gets the current class name
  68694. * @returns the class name
  68695. */
  68696. getClassName(): string;
  68697. /**
  68698. * Gets the incident component
  68699. */
  68700. get incident(): NodeMaterialConnectionPoint;
  68701. /**
  68702. * Gets the normal component
  68703. */
  68704. get normal(): NodeMaterialConnectionPoint;
  68705. /**
  68706. * Gets the index of refraction component
  68707. */
  68708. get ior(): NodeMaterialConnectionPoint;
  68709. /**
  68710. * Gets the output component
  68711. */
  68712. get output(): NodeMaterialConnectionPoint;
  68713. protected _buildBlock(state: NodeMaterialBuildState): this;
  68714. }
  68715. }
  68716. declare module BABYLON {
  68717. /**
  68718. * Block used to desaturate a color
  68719. */
  68720. export class DesaturateBlock extends NodeMaterialBlock {
  68721. /**
  68722. * Creates a new DesaturateBlock
  68723. * @param name defines the block name
  68724. */
  68725. constructor(name: string);
  68726. /**
  68727. * Gets the current class name
  68728. * @returns the class name
  68729. */
  68730. getClassName(): string;
  68731. /**
  68732. * Gets the color operand input component
  68733. */
  68734. get color(): NodeMaterialConnectionPoint;
  68735. /**
  68736. * Gets the level operand input component
  68737. */
  68738. get level(): NodeMaterialConnectionPoint;
  68739. /**
  68740. * Gets the output component
  68741. */
  68742. get output(): NodeMaterialConnectionPoint;
  68743. protected _buildBlock(state: NodeMaterialBuildState): this;
  68744. }
  68745. }
  68746. declare module BABYLON {
  68747. /**
  68748. * Block used to implement the reflection module of the PBR material
  68749. */
  68750. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68751. /** @hidden */
  68752. _defineLODReflectionAlpha: string;
  68753. /** @hidden */
  68754. _defineLinearSpecularReflection: string;
  68755. private _vEnvironmentIrradianceName;
  68756. /** @hidden */
  68757. _vReflectionMicrosurfaceInfosName: string;
  68758. /** @hidden */
  68759. _vReflectionInfosName: string;
  68760. /** @hidden */
  68761. _vReflectionFilteringInfoName: string;
  68762. private _scene;
  68763. /**
  68764. * The properties below are set by the main PBR block prior to calling methods of this class.
  68765. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68766. * It's less burden on the user side in the editor part.
  68767. */
  68768. /** @hidden */
  68769. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68770. /** @hidden */
  68771. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68772. /** @hidden */
  68773. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68774. /** @hidden */
  68775. viewConnectionPoint: NodeMaterialConnectionPoint;
  68776. /**
  68777. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68778. * diffuse part of the IBL.
  68779. */
  68780. useSphericalHarmonics: boolean;
  68781. /**
  68782. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68783. */
  68784. forceIrradianceInFragment: boolean;
  68785. /**
  68786. * Create a new ReflectionBlock
  68787. * @param name defines the block name
  68788. */
  68789. constructor(name: string);
  68790. /**
  68791. * Gets the current class name
  68792. * @returns the class name
  68793. */
  68794. getClassName(): string;
  68795. /**
  68796. * Gets the position input component
  68797. */
  68798. get position(): NodeMaterialConnectionPoint;
  68799. /**
  68800. * Gets the world position input component
  68801. */
  68802. get worldPosition(): NodeMaterialConnectionPoint;
  68803. /**
  68804. * Gets the world normal input component
  68805. */
  68806. get worldNormal(): NodeMaterialConnectionPoint;
  68807. /**
  68808. * Gets the world input component
  68809. */
  68810. get world(): NodeMaterialConnectionPoint;
  68811. /**
  68812. * Gets the camera (or eye) position component
  68813. */
  68814. get cameraPosition(): NodeMaterialConnectionPoint;
  68815. /**
  68816. * Gets the view input component
  68817. */
  68818. get view(): NodeMaterialConnectionPoint;
  68819. /**
  68820. * Gets the color input component
  68821. */
  68822. get color(): NodeMaterialConnectionPoint;
  68823. /**
  68824. * Gets the reflection object output component
  68825. */
  68826. get reflection(): NodeMaterialConnectionPoint;
  68827. /**
  68828. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68829. */
  68830. get hasTexture(): boolean;
  68831. /**
  68832. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68833. */
  68834. get reflectionColor(): string;
  68835. protected _getTexture(): Nullable<BaseTexture>;
  68836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68838. /**
  68839. * Gets the code to inject in the vertex shader
  68840. * @param state current state of the node material building
  68841. * @returns the shader code
  68842. */
  68843. handleVertexSide(state: NodeMaterialBuildState): string;
  68844. /**
  68845. * Gets the main code of the block (fragment side)
  68846. * @param state current state of the node material building
  68847. * @param normalVarName name of the existing variable corresponding to the normal
  68848. * @returns the shader code
  68849. */
  68850. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68851. protected _buildBlock(state: NodeMaterialBuildState): this;
  68852. protected _dumpPropertiesCode(): string;
  68853. serialize(): any;
  68854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68855. }
  68856. }
  68857. declare module BABYLON {
  68858. /**
  68859. * Block used to implement the sheen module of the PBR material
  68860. */
  68861. export class SheenBlock extends NodeMaterialBlock {
  68862. /**
  68863. * Create a new SheenBlock
  68864. * @param name defines the block name
  68865. */
  68866. constructor(name: string);
  68867. /**
  68868. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68869. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68870. * making it easier to setup and tweak the effect
  68871. */
  68872. albedoScaling: boolean;
  68873. /**
  68874. * Defines if the sheen is linked to the sheen color.
  68875. */
  68876. linkSheenWithAlbedo: boolean;
  68877. /**
  68878. * Initialize the block and prepare the context for build
  68879. * @param state defines the state that will be used for the build
  68880. */
  68881. initialize(state: NodeMaterialBuildState): void;
  68882. /**
  68883. * Gets the current class name
  68884. * @returns the class name
  68885. */
  68886. getClassName(): string;
  68887. /**
  68888. * Gets the intensity input component
  68889. */
  68890. get intensity(): NodeMaterialConnectionPoint;
  68891. /**
  68892. * Gets the color input component
  68893. */
  68894. get color(): NodeMaterialConnectionPoint;
  68895. /**
  68896. * Gets the roughness input component
  68897. */
  68898. get roughness(): NodeMaterialConnectionPoint;
  68899. /**
  68900. * Gets the sheen object output component
  68901. */
  68902. get sheen(): NodeMaterialConnectionPoint;
  68903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68904. /**
  68905. * Gets the main code of the block (fragment side)
  68906. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68907. * @returns the shader code
  68908. */
  68909. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68910. protected _buildBlock(state: NodeMaterialBuildState): this;
  68911. protected _dumpPropertiesCode(): string;
  68912. serialize(): any;
  68913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68914. }
  68915. }
  68916. declare module BABYLON {
  68917. /**
  68918. * Block used to implement the anisotropy module of the PBR material
  68919. */
  68920. export class AnisotropyBlock extends NodeMaterialBlock {
  68921. /**
  68922. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68923. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68924. * It's less burden on the user side in the editor part.
  68925. */
  68926. /** @hidden */
  68927. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68928. /** @hidden */
  68929. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68930. /**
  68931. * Create a new AnisotropyBlock
  68932. * @param name defines the block name
  68933. */
  68934. constructor(name: string);
  68935. /**
  68936. * Initialize the block and prepare the context for build
  68937. * @param state defines the state that will be used for the build
  68938. */
  68939. initialize(state: NodeMaterialBuildState): void;
  68940. /**
  68941. * Gets the current class name
  68942. * @returns the class name
  68943. */
  68944. getClassName(): string;
  68945. /**
  68946. * Gets the intensity input component
  68947. */
  68948. get intensity(): NodeMaterialConnectionPoint;
  68949. /**
  68950. * Gets the direction input component
  68951. */
  68952. get direction(): NodeMaterialConnectionPoint;
  68953. /**
  68954. * Gets the uv input component
  68955. */
  68956. get uv(): NodeMaterialConnectionPoint;
  68957. /**
  68958. * Gets the worldTangent input component
  68959. */
  68960. get worldTangent(): NodeMaterialConnectionPoint;
  68961. /**
  68962. * Gets the anisotropy object output component
  68963. */
  68964. get anisotropy(): NodeMaterialConnectionPoint;
  68965. private _generateTBNSpace;
  68966. /**
  68967. * Gets the main code of the block (fragment side)
  68968. * @param state current state of the node material building
  68969. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68970. * @returns the shader code
  68971. */
  68972. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68974. protected _buildBlock(state: NodeMaterialBuildState): this;
  68975. }
  68976. }
  68977. declare module BABYLON {
  68978. /**
  68979. * Block used to implement the clear coat module of the PBR material
  68980. */
  68981. export class ClearCoatBlock extends NodeMaterialBlock {
  68982. private _scene;
  68983. /**
  68984. * Create a new ClearCoatBlock
  68985. * @param name defines the block name
  68986. */
  68987. constructor(name: string);
  68988. /**
  68989. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68990. */
  68991. remapF0OnInterfaceChange: boolean;
  68992. /**
  68993. * Initialize the block and prepare the context for build
  68994. * @param state defines the state that will be used for the build
  68995. */
  68996. initialize(state: NodeMaterialBuildState): void;
  68997. /**
  68998. * Gets the current class name
  68999. * @returns the class name
  69000. */
  69001. getClassName(): string;
  69002. /**
  69003. * Gets the intensity input component
  69004. */
  69005. get intensity(): NodeMaterialConnectionPoint;
  69006. /**
  69007. * Gets the roughness input component
  69008. */
  69009. get roughness(): NodeMaterialConnectionPoint;
  69010. /**
  69011. * Gets the ior input component
  69012. */
  69013. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69014. /**
  69015. * Gets the bump texture input component
  69016. */
  69017. get normalMapColor(): NodeMaterialConnectionPoint;
  69018. /**
  69019. * Gets the uv input component
  69020. */
  69021. get uv(): NodeMaterialConnectionPoint;
  69022. /**
  69023. * Gets the tint color input component
  69024. */
  69025. get tintColor(): NodeMaterialConnectionPoint;
  69026. /**
  69027. * Gets the tint "at distance" input component
  69028. */
  69029. get tintAtDistance(): NodeMaterialConnectionPoint;
  69030. /**
  69031. * Gets the tint thickness input component
  69032. */
  69033. get tintThickness(): NodeMaterialConnectionPoint;
  69034. /**
  69035. * Gets the world tangent input component
  69036. */
  69037. get worldTangent(): NodeMaterialConnectionPoint;
  69038. /**
  69039. * Gets the clear coat object output component
  69040. */
  69041. get clearcoat(): NodeMaterialConnectionPoint;
  69042. autoConfigure(material: NodeMaterial): void;
  69043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69045. private _generateTBNSpace;
  69046. /**
  69047. * Gets the main code of the block (fragment side)
  69048. * @param state current state of the node material building
  69049. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69050. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69051. * @param worldPosVarName name of the variable holding the world position
  69052. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69053. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69054. * @param worldNormalVarName name of the variable holding the world normal
  69055. * @returns the shader code
  69056. */
  69057. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69058. protected _buildBlock(state: NodeMaterialBuildState): this;
  69059. protected _dumpPropertiesCode(): string;
  69060. serialize(): any;
  69061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69062. }
  69063. }
  69064. declare module BABYLON {
  69065. /**
  69066. * Block used to implement the sub surface module of the PBR material
  69067. */
  69068. export class SubSurfaceBlock extends NodeMaterialBlock {
  69069. /**
  69070. * Create a new SubSurfaceBlock
  69071. * @param name defines the block name
  69072. */
  69073. constructor(name: string);
  69074. /**
  69075. * Initialize the block and prepare the context for build
  69076. * @param state defines the state that will be used for the build
  69077. */
  69078. initialize(state: NodeMaterialBuildState): void;
  69079. /**
  69080. * Gets the current class name
  69081. * @returns the class name
  69082. */
  69083. getClassName(): string;
  69084. /**
  69085. * Gets the thickness component
  69086. */
  69087. get thickness(): NodeMaterialConnectionPoint;
  69088. /**
  69089. * Gets the tint color input component
  69090. */
  69091. get tintColor(): NodeMaterialConnectionPoint;
  69092. /**
  69093. * Gets the translucency intensity input component
  69094. */
  69095. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69096. /**
  69097. * Gets the translucency diffusion distance input component
  69098. */
  69099. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69100. /**
  69101. * Gets the refraction object parameters
  69102. */
  69103. get refraction(): NodeMaterialConnectionPoint;
  69104. /**
  69105. * Gets the sub surface object output component
  69106. */
  69107. get subsurface(): NodeMaterialConnectionPoint;
  69108. autoConfigure(material: NodeMaterial): void;
  69109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69110. /**
  69111. * Gets the main code of the block (fragment side)
  69112. * @param state current state of the node material building
  69113. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69114. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69115. * @param worldPosVarName name of the variable holding the world position
  69116. * @returns the shader code
  69117. */
  69118. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69119. protected _buildBlock(state: NodeMaterialBuildState): this;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. /**
  69124. * Block used to implement the PBR metallic/roughness model
  69125. */
  69126. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69127. /**
  69128. * Gets or sets the light associated with this block
  69129. */
  69130. light: Nullable<Light>;
  69131. private _lightId;
  69132. private _scene;
  69133. private _environmentBRDFTexture;
  69134. private _environmentBrdfSamplerName;
  69135. private _vNormalWName;
  69136. private _invertNormalName;
  69137. private _metallicReflectanceColor;
  69138. private _metallicF0Factor;
  69139. private _vMetallicReflectanceFactorsName;
  69140. /**
  69141. * Create a new ReflectionBlock
  69142. * @param name defines the block name
  69143. */
  69144. constructor(name: string);
  69145. /**
  69146. * Intensity of the direct lights e.g. the four lights available in your scene.
  69147. * This impacts both the direct diffuse and specular highlights.
  69148. */
  69149. directIntensity: number;
  69150. /**
  69151. * Intensity of the environment e.g. how much the environment will light the object
  69152. * either through harmonics for rough material or through the refelction for shiny ones.
  69153. */
  69154. environmentIntensity: number;
  69155. /**
  69156. * This is a special control allowing the reduction of the specular highlights coming from the
  69157. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69158. */
  69159. specularIntensity: number;
  69160. /**
  69161. * Defines the falloff type used in this material.
  69162. * It by default is Physical.
  69163. */
  69164. lightFalloff: number;
  69165. /**
  69166. * Specifies that alpha test should be used
  69167. */
  69168. useAlphaTest: boolean;
  69169. /**
  69170. * Defines the alpha limits in alpha test mode.
  69171. */
  69172. alphaTestCutoff: number;
  69173. /**
  69174. * Specifies that alpha blending should be used
  69175. */
  69176. useAlphaBlending: boolean;
  69177. /**
  69178. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69179. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69180. */
  69181. useRadianceOverAlpha: boolean;
  69182. /**
  69183. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69184. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69185. */
  69186. useSpecularOverAlpha: boolean;
  69187. /**
  69188. * Enables specular anti aliasing in the PBR shader.
  69189. * It will both interacts on the Geometry for analytical and IBL lighting.
  69190. * It also prefilter the roughness map based on the bump values.
  69191. */
  69192. enableSpecularAntiAliasing: boolean;
  69193. /**
  69194. * Enables realtime filtering on the texture.
  69195. */
  69196. realTimeFiltering: boolean;
  69197. /**
  69198. * Quality switch for realtime filtering
  69199. */
  69200. realTimeFilteringQuality: number;
  69201. /**
  69202. * Defines if the material uses energy conservation.
  69203. */
  69204. useEnergyConservation: boolean;
  69205. /**
  69206. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69207. * too much the area relying on ambient texture to define their ambient occlusion.
  69208. */
  69209. useRadianceOcclusion: boolean;
  69210. /**
  69211. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69212. * makes the reflect vector face the model (under horizon).
  69213. */
  69214. useHorizonOcclusion: boolean;
  69215. /**
  69216. * If set to true, no lighting calculations will be applied.
  69217. */
  69218. unlit: boolean;
  69219. /**
  69220. * Force normal to face away from face.
  69221. */
  69222. forceNormalForward: boolean;
  69223. /**
  69224. * Defines the material debug mode.
  69225. * It helps seeing only some components of the material while troubleshooting.
  69226. */
  69227. debugMode: number;
  69228. /**
  69229. * Specify from where on screen the debug mode should start.
  69230. * The value goes from -1 (full screen) to 1 (not visible)
  69231. * It helps with side by side comparison against the final render
  69232. * This defaults to 0
  69233. */
  69234. debugLimit: number;
  69235. /**
  69236. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69237. * You can use the factor to better multiply the final value.
  69238. */
  69239. debugFactor: number;
  69240. /**
  69241. * Initialize the block and prepare the context for build
  69242. * @param state defines the state that will be used for the build
  69243. */
  69244. initialize(state: NodeMaterialBuildState): void;
  69245. /**
  69246. * Gets the current class name
  69247. * @returns the class name
  69248. */
  69249. getClassName(): string;
  69250. /**
  69251. * Gets the world position input component
  69252. */
  69253. get worldPosition(): NodeMaterialConnectionPoint;
  69254. /**
  69255. * Gets the world normal input component
  69256. */
  69257. get worldNormal(): NodeMaterialConnectionPoint;
  69258. /**
  69259. * Gets the view matrix parameter
  69260. */
  69261. get view(): NodeMaterialConnectionPoint;
  69262. /**
  69263. * Gets the camera position input component
  69264. */
  69265. get cameraPosition(): NodeMaterialConnectionPoint;
  69266. /**
  69267. * Gets the perturbed normal input component
  69268. */
  69269. get perturbedNormal(): NodeMaterialConnectionPoint;
  69270. /**
  69271. * Gets the base color input component
  69272. */
  69273. get baseColor(): NodeMaterialConnectionPoint;
  69274. /**
  69275. * Gets the metallic input component
  69276. */
  69277. get metallic(): NodeMaterialConnectionPoint;
  69278. /**
  69279. * Gets the roughness input component
  69280. */
  69281. get roughness(): NodeMaterialConnectionPoint;
  69282. /**
  69283. * Gets the ambient occlusion input component
  69284. */
  69285. get ambientOcc(): NodeMaterialConnectionPoint;
  69286. /**
  69287. * Gets the opacity input component
  69288. */
  69289. get opacity(): NodeMaterialConnectionPoint;
  69290. /**
  69291. * Gets the index of refraction input component
  69292. */
  69293. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69294. /**
  69295. * Gets the ambient color input component
  69296. */
  69297. get ambientColor(): NodeMaterialConnectionPoint;
  69298. /**
  69299. * Gets the reflection object parameters
  69300. */
  69301. get reflection(): NodeMaterialConnectionPoint;
  69302. /**
  69303. * Gets the clear coat object parameters
  69304. */
  69305. get clearcoat(): NodeMaterialConnectionPoint;
  69306. /**
  69307. * Gets the sheen object parameters
  69308. */
  69309. get sheen(): NodeMaterialConnectionPoint;
  69310. /**
  69311. * Gets the sub surface object parameters
  69312. */
  69313. get subsurface(): NodeMaterialConnectionPoint;
  69314. /**
  69315. * Gets the anisotropy object parameters
  69316. */
  69317. get anisotropy(): NodeMaterialConnectionPoint;
  69318. /**
  69319. * Gets the ambient output component
  69320. */
  69321. get ambientClr(): NodeMaterialConnectionPoint;
  69322. /**
  69323. * Gets the diffuse output component
  69324. */
  69325. get diffuseDir(): NodeMaterialConnectionPoint;
  69326. /**
  69327. * Gets the specular output component
  69328. */
  69329. get specularDir(): NodeMaterialConnectionPoint;
  69330. /**
  69331. * Gets the clear coat output component
  69332. */
  69333. get clearcoatDir(): NodeMaterialConnectionPoint;
  69334. /**
  69335. * Gets the sheen output component
  69336. */
  69337. get sheenDir(): NodeMaterialConnectionPoint;
  69338. /**
  69339. * Gets the indirect diffuse output component
  69340. */
  69341. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69342. /**
  69343. * Gets the indirect specular output component
  69344. */
  69345. get specularIndirect(): NodeMaterialConnectionPoint;
  69346. /**
  69347. * Gets the indirect clear coat output component
  69348. */
  69349. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69350. /**
  69351. * Gets the indirect sheen output component
  69352. */
  69353. get sheenIndirect(): NodeMaterialConnectionPoint;
  69354. /**
  69355. * Gets the refraction output component
  69356. */
  69357. get refraction(): NodeMaterialConnectionPoint;
  69358. /**
  69359. * Gets the global lighting output component
  69360. */
  69361. get lighting(): NodeMaterialConnectionPoint;
  69362. /**
  69363. * Gets the shadow output component
  69364. */
  69365. get shadow(): NodeMaterialConnectionPoint;
  69366. /**
  69367. * Gets the alpha output component
  69368. */
  69369. get alpha(): NodeMaterialConnectionPoint;
  69370. autoConfigure(material: NodeMaterial): void;
  69371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69372. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69373. isReady(): boolean;
  69374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69375. private _injectVertexCode;
  69376. private _getAlbedoOpacityCode;
  69377. private _getAmbientOcclusionCode;
  69378. private _getReflectivityCode;
  69379. protected _buildBlock(state: NodeMaterialBuildState): this;
  69380. protected _dumpPropertiesCode(): string;
  69381. serialize(): any;
  69382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69383. }
  69384. }
  69385. declare module BABYLON {
  69386. /**
  69387. * Block used to compute value of one parameter modulo another
  69388. */
  69389. export class ModBlock extends NodeMaterialBlock {
  69390. /**
  69391. * Creates a new ModBlock
  69392. * @param name defines the block name
  69393. */
  69394. constructor(name: string);
  69395. /**
  69396. * Gets the current class name
  69397. * @returns the class name
  69398. */
  69399. getClassName(): string;
  69400. /**
  69401. * Gets the left operand input component
  69402. */
  69403. get left(): NodeMaterialConnectionPoint;
  69404. /**
  69405. * Gets the right operand input component
  69406. */
  69407. get right(): NodeMaterialConnectionPoint;
  69408. /**
  69409. * Gets the output component
  69410. */
  69411. get output(): NodeMaterialConnectionPoint;
  69412. protected _buildBlock(state: NodeMaterialBuildState): this;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /**
  69417. * Configuration for Draco compression
  69418. */
  69419. export interface IDracoCompressionConfiguration {
  69420. /**
  69421. * Configuration for the decoder.
  69422. */
  69423. decoder: {
  69424. /**
  69425. * The url to the WebAssembly module.
  69426. */
  69427. wasmUrl?: string;
  69428. /**
  69429. * The url to the WebAssembly binary.
  69430. */
  69431. wasmBinaryUrl?: string;
  69432. /**
  69433. * The url to the fallback JavaScript module.
  69434. */
  69435. fallbackUrl?: string;
  69436. };
  69437. }
  69438. /**
  69439. * Draco compression (https://google.github.io/draco/)
  69440. *
  69441. * This class wraps the Draco module.
  69442. *
  69443. * **Encoder**
  69444. *
  69445. * The encoder is not currently implemented.
  69446. *
  69447. * **Decoder**
  69448. *
  69449. * 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.
  69450. *
  69451. * To update the configuration, use the following code:
  69452. * ```javascript
  69453. * DracoCompression.Configuration = {
  69454. * decoder: {
  69455. * wasmUrl: "<url to the WebAssembly library>",
  69456. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69457. * fallbackUrl: "<url to the fallback JavaScript library>",
  69458. * }
  69459. * };
  69460. * ```
  69461. *
  69462. * 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.
  69463. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69464. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69465. *
  69466. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69467. * ```javascript
  69468. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69469. * ```
  69470. *
  69471. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69472. */
  69473. export class DracoCompression implements IDisposable {
  69474. private _workerPoolPromise?;
  69475. private _decoderModulePromise?;
  69476. /**
  69477. * The configuration. Defaults to the following urls:
  69478. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69479. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69480. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69481. */
  69482. static Configuration: IDracoCompressionConfiguration;
  69483. /**
  69484. * Returns true if the decoder configuration is available.
  69485. */
  69486. static get DecoderAvailable(): boolean;
  69487. /**
  69488. * Default number of workers to create when creating the draco compression object.
  69489. */
  69490. static DefaultNumWorkers: number;
  69491. private static GetDefaultNumWorkers;
  69492. private static _Default;
  69493. /**
  69494. * Default instance for the draco compression object.
  69495. */
  69496. static get Default(): DracoCompression;
  69497. /**
  69498. * Constructor
  69499. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69500. */
  69501. constructor(numWorkers?: number);
  69502. /**
  69503. * Stop all async operations and release resources.
  69504. */
  69505. dispose(): void;
  69506. /**
  69507. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69508. * @returns a promise that resolves when ready
  69509. */
  69510. whenReadyAsync(): Promise<void>;
  69511. /**
  69512. * Decode Draco compressed mesh data to vertex data.
  69513. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69514. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69515. * @returns A promise that resolves with the decoded vertex data
  69516. */
  69517. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69518. [kind: string]: number;
  69519. }): Promise<VertexData>;
  69520. }
  69521. }
  69522. declare module BABYLON {
  69523. /**
  69524. * Class for building Constructive Solid Geometry
  69525. */
  69526. export class CSG {
  69527. private polygons;
  69528. /**
  69529. * The world matrix
  69530. */
  69531. matrix: Matrix;
  69532. /**
  69533. * Stores the position
  69534. */
  69535. position: Vector3;
  69536. /**
  69537. * Stores the rotation
  69538. */
  69539. rotation: Vector3;
  69540. /**
  69541. * Stores the rotation quaternion
  69542. */
  69543. rotationQuaternion: Nullable<Quaternion>;
  69544. /**
  69545. * Stores the scaling vector
  69546. */
  69547. scaling: Vector3;
  69548. /**
  69549. * Convert the Mesh to CSG
  69550. * @param mesh The Mesh to convert to CSG
  69551. * @returns A new CSG from the Mesh
  69552. */
  69553. static FromMesh(mesh: Mesh): CSG;
  69554. /**
  69555. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69556. * @param polygons Polygons used to construct a CSG solid
  69557. */
  69558. private static FromPolygons;
  69559. /**
  69560. * Clones, or makes a deep copy, of the CSG
  69561. * @returns A new CSG
  69562. */
  69563. clone(): CSG;
  69564. /**
  69565. * Unions this CSG with another CSG
  69566. * @param csg The CSG to union against this CSG
  69567. * @returns The unioned CSG
  69568. */
  69569. union(csg: CSG): CSG;
  69570. /**
  69571. * Unions this CSG with another CSG in place
  69572. * @param csg The CSG to union against this CSG
  69573. */
  69574. unionInPlace(csg: CSG): void;
  69575. /**
  69576. * Subtracts this CSG with another CSG
  69577. * @param csg The CSG to subtract against this CSG
  69578. * @returns A new CSG
  69579. */
  69580. subtract(csg: CSG): CSG;
  69581. /**
  69582. * Subtracts this CSG with another CSG in place
  69583. * @param csg The CSG to subtact against this CSG
  69584. */
  69585. subtractInPlace(csg: CSG): void;
  69586. /**
  69587. * Intersect this CSG with another CSG
  69588. * @param csg The CSG to intersect against this CSG
  69589. * @returns A new CSG
  69590. */
  69591. intersect(csg: CSG): CSG;
  69592. /**
  69593. * Intersects this CSG with another CSG in place
  69594. * @param csg The CSG to intersect against this CSG
  69595. */
  69596. intersectInPlace(csg: CSG): void;
  69597. /**
  69598. * Return a new CSG solid with solid and empty space switched. This solid is
  69599. * not modified.
  69600. * @returns A new CSG solid with solid and empty space switched
  69601. */
  69602. inverse(): CSG;
  69603. /**
  69604. * Inverses the CSG in place
  69605. */
  69606. inverseInPlace(): void;
  69607. /**
  69608. * This is used to keep meshes transformations so they can be restored
  69609. * when we build back a Babylon Mesh
  69610. * NB : All CSG operations are performed in world coordinates
  69611. * @param csg The CSG to copy the transform attributes from
  69612. * @returns This CSG
  69613. */
  69614. copyTransformAttributes(csg: CSG): CSG;
  69615. /**
  69616. * Build Raw mesh from CSG
  69617. * Coordinates here are in world space
  69618. * @param name The name of the mesh geometry
  69619. * @param scene The Scene
  69620. * @param keepSubMeshes Specifies if the submeshes should be kept
  69621. * @returns A new Mesh
  69622. */
  69623. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69624. /**
  69625. * Build Mesh from CSG taking material and transforms into account
  69626. * @param name The name of the Mesh
  69627. * @param material The material of the Mesh
  69628. * @param scene The Scene
  69629. * @param keepSubMeshes Specifies if submeshes should be kept
  69630. * @returns The new Mesh
  69631. */
  69632. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69633. }
  69634. }
  69635. declare module BABYLON {
  69636. /**
  69637. * Class used to create a trail following a mesh
  69638. */
  69639. export class TrailMesh extends Mesh {
  69640. private _generator;
  69641. private _autoStart;
  69642. private _running;
  69643. private _diameter;
  69644. private _length;
  69645. private _sectionPolygonPointsCount;
  69646. private _sectionVectors;
  69647. private _sectionNormalVectors;
  69648. private _beforeRenderObserver;
  69649. /**
  69650. * @constructor
  69651. * @param name The value used by scene.getMeshByName() to do a lookup.
  69652. * @param generator The mesh or transform node to generate a trail.
  69653. * @param scene The scene to add this mesh to.
  69654. * @param diameter Diameter of trailing mesh. Default is 1.
  69655. * @param length Length of trailing mesh. Default is 60.
  69656. * @param autoStart Automatically start trailing mesh. Default true.
  69657. */
  69658. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69659. /**
  69660. * "TrailMesh"
  69661. * @returns "TrailMesh"
  69662. */
  69663. getClassName(): string;
  69664. private _createMesh;
  69665. /**
  69666. * Start trailing mesh.
  69667. */
  69668. start(): void;
  69669. /**
  69670. * Stop trailing mesh.
  69671. */
  69672. stop(): void;
  69673. /**
  69674. * Update trailing mesh geometry.
  69675. */
  69676. update(): void;
  69677. /**
  69678. * Returns a new TrailMesh object.
  69679. * @param name is a string, the name given to the new mesh
  69680. * @param newGenerator use new generator object for cloned trail mesh
  69681. * @returns a new mesh
  69682. */
  69683. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69684. /**
  69685. * Serializes this trail mesh
  69686. * @param serializationObject object to write serialization to
  69687. */
  69688. serialize(serializationObject: any): void;
  69689. /**
  69690. * Parses a serialized trail mesh
  69691. * @param parsedMesh the serialized mesh
  69692. * @param scene the scene to create the trail mesh in
  69693. * @returns the created trail mesh
  69694. */
  69695. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Class containing static functions to help procedurally build meshes
  69701. */
  69702. export class TiledBoxBuilder {
  69703. /**
  69704. * Creates a box mesh
  69705. * 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)
  69706. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69708. * * 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
  69709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69710. * @param name defines the name of the mesh
  69711. * @param options defines the options used to create the mesh
  69712. * @param scene defines the hosting scene
  69713. * @returns the box mesh
  69714. */
  69715. static CreateTiledBox(name: string, options: {
  69716. pattern?: number;
  69717. width?: number;
  69718. height?: number;
  69719. depth?: number;
  69720. tileSize?: number;
  69721. tileWidth?: number;
  69722. tileHeight?: number;
  69723. alignHorizontal?: number;
  69724. alignVertical?: number;
  69725. faceUV?: Vector4[];
  69726. faceColors?: Color4[];
  69727. sideOrientation?: number;
  69728. updatable?: boolean;
  69729. }, scene?: Nullable<Scene>): Mesh;
  69730. }
  69731. }
  69732. declare module BABYLON {
  69733. /**
  69734. * Class containing static functions to help procedurally build meshes
  69735. */
  69736. export class TorusKnotBuilder {
  69737. /**
  69738. * Creates a torus knot mesh
  69739. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69740. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69741. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69742. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69744. * * 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
  69745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69746. * @param name defines the name of the mesh
  69747. * @param options defines the options used to create the mesh
  69748. * @param scene defines the hosting scene
  69749. * @returns the torus knot mesh
  69750. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69751. */
  69752. static CreateTorusKnot(name: string, options: {
  69753. radius?: number;
  69754. tube?: number;
  69755. radialSegments?: number;
  69756. tubularSegments?: number;
  69757. p?: number;
  69758. q?: number;
  69759. updatable?: boolean;
  69760. sideOrientation?: number;
  69761. frontUVs?: Vector4;
  69762. backUVs?: Vector4;
  69763. }, scene: any): Mesh;
  69764. }
  69765. }
  69766. declare module BABYLON {
  69767. /**
  69768. * Polygon
  69769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69770. */
  69771. export class Polygon {
  69772. /**
  69773. * Creates a rectangle
  69774. * @param xmin bottom X coord
  69775. * @param ymin bottom Y coord
  69776. * @param xmax top X coord
  69777. * @param ymax top Y coord
  69778. * @returns points that make the resulting rectation
  69779. */
  69780. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69781. /**
  69782. * Creates a circle
  69783. * @param radius radius of circle
  69784. * @param cx scale in x
  69785. * @param cy scale in y
  69786. * @param numberOfSides number of sides that make up the circle
  69787. * @returns points that make the resulting circle
  69788. */
  69789. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69790. /**
  69791. * Creates a polygon from input string
  69792. * @param input Input polygon data
  69793. * @returns the parsed points
  69794. */
  69795. static Parse(input: string): Vector2[];
  69796. /**
  69797. * Starts building a polygon from x and y coordinates
  69798. * @param x x coordinate
  69799. * @param y y coordinate
  69800. * @returns the started path2
  69801. */
  69802. static StartingAt(x: number, y: number): Path2;
  69803. }
  69804. /**
  69805. * Builds a polygon
  69806. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69807. */
  69808. export class PolygonMeshBuilder {
  69809. private _points;
  69810. private _outlinepoints;
  69811. private _holes;
  69812. private _name;
  69813. private _scene;
  69814. private _epoints;
  69815. private _eholes;
  69816. private _addToepoint;
  69817. /**
  69818. * Babylon reference to the earcut plugin.
  69819. */
  69820. bjsEarcut: any;
  69821. /**
  69822. * Creates a PolygonMeshBuilder
  69823. * @param name name of the builder
  69824. * @param contours Path of the polygon
  69825. * @param scene scene to add to when creating the mesh
  69826. * @param earcutInjection can be used to inject your own earcut reference
  69827. */
  69828. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69829. /**
  69830. * Adds a hole within the polygon
  69831. * @param hole Array of points defining the hole
  69832. * @returns this
  69833. */
  69834. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69835. /**
  69836. * Creates the polygon
  69837. * @param updatable If the mesh should be updatable
  69838. * @param depth The depth of the mesh created
  69839. * @param smoothingThreshold Dot product threshold for smoothed normals
  69840. * @returns the created mesh
  69841. */
  69842. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  69843. /**
  69844. * Creates the polygon
  69845. * @param depth The depth of the mesh created
  69846. * @param smoothingThreshold Dot product threshold for smoothed normals
  69847. * @returns the created VertexData
  69848. */
  69849. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  69850. /**
  69851. * Adds a side to the polygon
  69852. * @param positions points that make the polygon
  69853. * @param normals normals of the polygon
  69854. * @param uvs uvs of the polygon
  69855. * @param indices indices of the polygon
  69856. * @param bounds bounds of the polygon
  69857. * @param points points of the polygon
  69858. * @param depth depth of the polygon
  69859. * @param flip flip of the polygon
  69860. */
  69861. private addSide;
  69862. }
  69863. }
  69864. declare module BABYLON {
  69865. /**
  69866. * Class containing static functions to help procedurally build meshes
  69867. */
  69868. export class PolygonBuilder {
  69869. /**
  69870. * Creates a polygon mesh
  69871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69872. * * 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
  69873. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69875. * * 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)
  69876. * * Remember you can only change the shape positions, not their number when updating a polygon
  69877. * @param name defines the name of the mesh
  69878. * @param options defines the options used to create the mesh
  69879. * @param scene defines the hosting scene
  69880. * @param earcutInjection can be used to inject your own earcut reference
  69881. * @returns the polygon mesh
  69882. */
  69883. static CreatePolygon(name: string, options: {
  69884. shape: Vector3[];
  69885. holes?: Vector3[][];
  69886. depth?: number;
  69887. smoothingThreshold?: number;
  69888. faceUV?: Vector4[];
  69889. faceColors?: Color4[];
  69890. updatable?: boolean;
  69891. sideOrientation?: number;
  69892. frontUVs?: Vector4;
  69893. backUVs?: Vector4;
  69894. wrap?: boolean;
  69895. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69896. /**
  69897. * Creates an extruded polygon mesh, with depth in the Y direction.
  69898. * * 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)
  69899. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69900. * @param name defines the name of the mesh
  69901. * @param options defines the options used to create the mesh
  69902. * @param scene defines the hosting scene
  69903. * @param earcutInjection can be used to inject your own earcut reference
  69904. * @returns the polygon mesh
  69905. */
  69906. static ExtrudePolygon(name: string, options: {
  69907. shape: Vector3[];
  69908. holes?: Vector3[][];
  69909. depth?: number;
  69910. faceUV?: Vector4[];
  69911. faceColors?: Color4[];
  69912. updatable?: boolean;
  69913. sideOrientation?: number;
  69914. frontUVs?: Vector4;
  69915. backUVs?: Vector4;
  69916. wrap?: boolean;
  69917. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69918. }
  69919. }
  69920. declare module BABYLON {
  69921. /**
  69922. * Class containing static functions to help procedurally build meshes
  69923. */
  69924. export class LatheBuilder {
  69925. /**
  69926. * Creates lathe mesh.
  69927. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69928. * * 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
  69929. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69930. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69931. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69932. * * 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
  69933. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69934. * * 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
  69935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69936. * * 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
  69937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69939. * @param name defines the name of the mesh
  69940. * @param options defines the options used to create the mesh
  69941. * @param scene defines the hosting scene
  69942. * @returns the lathe mesh
  69943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69944. */
  69945. static CreateLathe(name: string, options: {
  69946. shape: Vector3[];
  69947. radius?: number;
  69948. tessellation?: number;
  69949. clip?: number;
  69950. arc?: number;
  69951. closed?: boolean;
  69952. updatable?: boolean;
  69953. sideOrientation?: number;
  69954. frontUVs?: Vector4;
  69955. backUVs?: Vector4;
  69956. cap?: number;
  69957. invertUV?: boolean;
  69958. }, scene?: Nullable<Scene>): Mesh;
  69959. }
  69960. }
  69961. declare module BABYLON {
  69962. /**
  69963. * Class containing static functions to help procedurally build meshes
  69964. */
  69965. export class TiledPlaneBuilder {
  69966. /**
  69967. * Creates a tiled plane mesh
  69968. * * The parameter `pattern` will, depending on value, do nothing or
  69969. * * * flip (reflect about central vertical) alternate tiles across and up
  69970. * * * flip every tile on alternate rows
  69971. * * * rotate (180 degs) alternate tiles across and up
  69972. * * * rotate every tile on alternate rows
  69973. * * * flip and rotate alternate tiles across and up
  69974. * * * flip and rotate every tile on alternate rows
  69975. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69976. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69977. * * 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
  69978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69979. * * 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)
  69980. * * 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)
  69981. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69982. * @param name defines the name of the mesh
  69983. * @param options defines the options used to create the mesh
  69984. * @param scene defines the hosting scene
  69985. * @returns the box mesh
  69986. */
  69987. static CreateTiledPlane(name: string, options: {
  69988. pattern?: number;
  69989. tileSize?: number;
  69990. tileWidth?: number;
  69991. tileHeight?: number;
  69992. size?: number;
  69993. width?: number;
  69994. height?: number;
  69995. alignHorizontal?: number;
  69996. alignVertical?: number;
  69997. sideOrientation?: number;
  69998. frontUVs?: Vector4;
  69999. backUVs?: Vector4;
  70000. updatable?: boolean;
  70001. }, scene?: Nullable<Scene>): Mesh;
  70002. }
  70003. }
  70004. declare module BABYLON {
  70005. /**
  70006. * Class containing static functions to help procedurally build meshes
  70007. */
  70008. export class TubeBuilder {
  70009. /**
  70010. * Creates a tube mesh.
  70011. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70012. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70013. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70014. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70015. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70016. * * 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)
  70017. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70018. * * 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
  70019. * * 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
  70020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70021. * * 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
  70022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70024. * @param name defines the name of the mesh
  70025. * @param options defines the options used to create the mesh
  70026. * @param scene defines the hosting scene
  70027. * @returns the tube mesh
  70028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70029. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70030. */
  70031. static CreateTube(name: string, options: {
  70032. path: Vector3[];
  70033. radius?: number;
  70034. tessellation?: number;
  70035. radiusFunction?: {
  70036. (i: number, distance: number): number;
  70037. };
  70038. cap?: number;
  70039. arc?: number;
  70040. updatable?: boolean;
  70041. sideOrientation?: number;
  70042. frontUVs?: Vector4;
  70043. backUVs?: Vector4;
  70044. instance?: Mesh;
  70045. invertUV?: boolean;
  70046. }, scene?: Nullable<Scene>): Mesh;
  70047. }
  70048. }
  70049. declare module BABYLON {
  70050. /**
  70051. * Class containing static functions to help procedurally build meshes
  70052. */
  70053. export class IcoSphereBuilder {
  70054. /**
  70055. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70056. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70057. * * 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`)
  70058. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70059. * * 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
  70060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70061. * * 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
  70062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70063. * @param name defines the name of the mesh
  70064. * @param options defines the options used to create the mesh
  70065. * @param scene defines the hosting scene
  70066. * @returns the icosahedron mesh
  70067. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70068. */
  70069. static CreateIcoSphere(name: string, options: {
  70070. radius?: number;
  70071. radiusX?: number;
  70072. radiusY?: number;
  70073. radiusZ?: number;
  70074. flat?: boolean;
  70075. subdivisions?: number;
  70076. sideOrientation?: number;
  70077. frontUVs?: Vector4;
  70078. backUVs?: Vector4;
  70079. updatable?: boolean;
  70080. }, scene?: Nullable<Scene>): Mesh;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /**
  70085. * Class containing static functions to help procedurally build meshes
  70086. */
  70087. export class DecalBuilder {
  70088. /**
  70089. * Creates a decal mesh.
  70090. * 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
  70091. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70092. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70093. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70094. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70095. * @param name defines the name of the mesh
  70096. * @param sourceMesh defines the mesh where the decal must be applied
  70097. * @param options defines the options used to create the mesh
  70098. * @param scene defines the hosting scene
  70099. * @returns the decal mesh
  70100. * @see https://doc.babylonjs.com/how_to/decals
  70101. */
  70102. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70103. position?: Vector3;
  70104. normal?: Vector3;
  70105. size?: Vector3;
  70106. angle?: number;
  70107. }): Mesh;
  70108. }
  70109. }
  70110. declare module BABYLON {
  70111. /**
  70112. * Class containing static functions to help procedurally build meshes
  70113. */
  70114. export class MeshBuilder {
  70115. /**
  70116. * Creates a box mesh
  70117. * * The parameter `size` sets the size (float) of each box side (default 1)
  70118. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70119. * * 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)
  70120. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70122. * * 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
  70123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70124. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70125. * @param name defines the name of the mesh
  70126. * @param options defines the options used to create the mesh
  70127. * @param scene defines the hosting scene
  70128. * @returns the box mesh
  70129. */
  70130. static CreateBox(name: string, options: {
  70131. size?: number;
  70132. width?: number;
  70133. height?: number;
  70134. depth?: number;
  70135. faceUV?: Vector4[];
  70136. faceColors?: Color4[];
  70137. sideOrientation?: number;
  70138. frontUVs?: Vector4;
  70139. backUVs?: Vector4;
  70140. wrap?: boolean;
  70141. topBaseAt?: number;
  70142. bottomBaseAt?: number;
  70143. updatable?: boolean;
  70144. }, scene?: Nullable<Scene>): Mesh;
  70145. /**
  70146. * Creates a tiled box mesh
  70147. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70149. * @param name defines the name of the mesh
  70150. * @param options defines the options used to create the mesh
  70151. * @param scene defines the hosting scene
  70152. * @returns the tiled box mesh
  70153. */
  70154. static CreateTiledBox(name: string, options: {
  70155. pattern?: number;
  70156. size?: number;
  70157. width?: number;
  70158. height?: number;
  70159. depth: number;
  70160. tileSize?: number;
  70161. tileWidth?: number;
  70162. tileHeight?: number;
  70163. faceUV?: Vector4[];
  70164. faceColors?: Color4[];
  70165. alignHorizontal?: number;
  70166. alignVertical?: number;
  70167. sideOrientation?: number;
  70168. updatable?: boolean;
  70169. }, scene?: Nullable<Scene>): Mesh;
  70170. /**
  70171. * Creates a sphere mesh
  70172. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70173. * * 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`)
  70174. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70175. * * 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
  70176. * * 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)
  70177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70178. * * 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
  70179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70180. * @param name defines the name of the mesh
  70181. * @param options defines the options used to create the mesh
  70182. * @param scene defines the hosting scene
  70183. * @returns the sphere mesh
  70184. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70185. */
  70186. static CreateSphere(name: string, options: {
  70187. segments?: number;
  70188. diameter?: number;
  70189. diameterX?: number;
  70190. diameterY?: number;
  70191. diameterZ?: number;
  70192. arc?: number;
  70193. slice?: number;
  70194. sideOrientation?: number;
  70195. frontUVs?: Vector4;
  70196. backUVs?: Vector4;
  70197. updatable?: boolean;
  70198. }, scene?: Nullable<Scene>): Mesh;
  70199. /**
  70200. * Creates a plane polygonal mesh. By default, this is a disc
  70201. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70202. * * 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
  70203. * * 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
  70204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70205. * * 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
  70206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70207. * @param name defines the name of the mesh
  70208. * @param options defines the options used to create the mesh
  70209. * @param scene defines the hosting scene
  70210. * @returns the plane polygonal mesh
  70211. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70212. */
  70213. static CreateDisc(name: string, options: {
  70214. radius?: number;
  70215. tessellation?: number;
  70216. arc?: number;
  70217. updatable?: boolean;
  70218. sideOrientation?: number;
  70219. frontUVs?: Vector4;
  70220. backUVs?: Vector4;
  70221. }, scene?: Nullable<Scene>): Mesh;
  70222. /**
  70223. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70224. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70225. * * 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`)
  70226. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70227. * * 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
  70228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70229. * * 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
  70230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70231. * @param name defines the name of the mesh
  70232. * @param options defines the options used to create the mesh
  70233. * @param scene defines the hosting scene
  70234. * @returns the icosahedron mesh
  70235. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70236. */
  70237. static CreateIcoSphere(name: string, options: {
  70238. radius?: number;
  70239. radiusX?: number;
  70240. radiusY?: number;
  70241. radiusZ?: number;
  70242. flat?: boolean;
  70243. subdivisions?: number;
  70244. sideOrientation?: number;
  70245. frontUVs?: Vector4;
  70246. backUVs?: Vector4;
  70247. updatable?: boolean;
  70248. }, scene?: Nullable<Scene>): Mesh;
  70249. /**
  70250. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70251. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70252. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70253. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70254. * * 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
  70255. * * 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
  70256. * * 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
  70257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70258. * * 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
  70259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70260. * * 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
  70261. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70262. * * 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
  70263. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70265. * @param name defines the name of the mesh
  70266. * @param options defines the options used to create the mesh
  70267. * @param scene defines the hosting scene
  70268. * @returns the ribbon mesh
  70269. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70271. */
  70272. static CreateRibbon(name: string, options: {
  70273. pathArray: Vector3[][];
  70274. closeArray?: boolean;
  70275. closePath?: boolean;
  70276. offset?: number;
  70277. updatable?: boolean;
  70278. sideOrientation?: number;
  70279. frontUVs?: Vector4;
  70280. backUVs?: Vector4;
  70281. instance?: Mesh;
  70282. invertUV?: boolean;
  70283. uvs?: Vector2[];
  70284. colors?: Color4[];
  70285. }, scene?: Nullable<Scene>): Mesh;
  70286. /**
  70287. * Creates a cylinder or a cone mesh
  70288. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70289. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70290. * * 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.
  70291. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70292. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70293. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70294. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70295. * * 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).
  70296. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70297. * * 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).
  70298. * * 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
  70299. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70300. * * 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
  70301. * * 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.
  70302. * * If `enclose` is false, a ring surface is one element.
  70303. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70304. * * 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
  70305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70306. * * 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
  70307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70308. * @param name defines the name of the mesh
  70309. * @param options defines the options used to create the mesh
  70310. * @param scene defines the hosting scene
  70311. * @returns the cylinder mesh
  70312. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70313. */
  70314. static CreateCylinder(name: string, options: {
  70315. height?: number;
  70316. diameterTop?: number;
  70317. diameterBottom?: number;
  70318. diameter?: number;
  70319. tessellation?: number;
  70320. subdivisions?: number;
  70321. arc?: number;
  70322. faceColors?: Color4[];
  70323. faceUV?: Vector4[];
  70324. updatable?: boolean;
  70325. hasRings?: boolean;
  70326. enclose?: boolean;
  70327. cap?: number;
  70328. sideOrientation?: number;
  70329. frontUVs?: Vector4;
  70330. backUVs?: Vector4;
  70331. }, scene?: Nullable<Scene>): Mesh;
  70332. /**
  70333. * Creates a torus mesh
  70334. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70335. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70336. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70338. * * 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
  70339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70340. * @param name defines the name of the mesh
  70341. * @param options defines the options used to create the mesh
  70342. * @param scene defines the hosting scene
  70343. * @returns the torus mesh
  70344. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70345. */
  70346. static CreateTorus(name: string, options: {
  70347. diameter?: number;
  70348. thickness?: number;
  70349. tessellation?: number;
  70350. updatable?: boolean;
  70351. sideOrientation?: number;
  70352. frontUVs?: Vector4;
  70353. backUVs?: Vector4;
  70354. }, scene?: Nullable<Scene>): Mesh;
  70355. /**
  70356. * Creates a torus knot mesh
  70357. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70358. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70359. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70360. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70362. * * 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
  70363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70364. * @param name defines the name of the mesh
  70365. * @param options defines the options used to create the mesh
  70366. * @param scene defines the hosting scene
  70367. * @returns the torus knot mesh
  70368. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70369. */
  70370. static CreateTorusKnot(name: string, options: {
  70371. radius?: number;
  70372. tube?: number;
  70373. radialSegments?: number;
  70374. tubularSegments?: number;
  70375. p?: number;
  70376. q?: number;
  70377. updatable?: boolean;
  70378. sideOrientation?: number;
  70379. frontUVs?: Vector4;
  70380. backUVs?: Vector4;
  70381. }, scene?: Nullable<Scene>): Mesh;
  70382. /**
  70383. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70384. * * 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
  70385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70386. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70387. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70388. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70389. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70390. * * 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
  70391. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70394. * @param name defines the name of the new line system
  70395. * @param options defines the options used to create the line system
  70396. * @param scene defines the hosting scene
  70397. * @returns a new line system mesh
  70398. */
  70399. static CreateLineSystem(name: string, options: {
  70400. lines: Vector3[][];
  70401. updatable?: boolean;
  70402. instance?: Nullable<LinesMesh>;
  70403. colors?: Nullable<Color4[][]>;
  70404. useVertexAlpha?: boolean;
  70405. }, scene: Nullable<Scene>): LinesMesh;
  70406. /**
  70407. * Creates a line mesh
  70408. * 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
  70409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70410. * * The parameter `points` is an array successive Vector3
  70411. * * 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
  70412. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70413. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70414. * * When updating an instance, remember that only point positions can change, not the number of points
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70417. * @param name defines the name of the new line system
  70418. * @param options defines the options used to create the line system
  70419. * @param scene defines the hosting scene
  70420. * @returns a new line mesh
  70421. */
  70422. static CreateLines(name: string, options: {
  70423. points: Vector3[];
  70424. updatable?: boolean;
  70425. instance?: Nullable<LinesMesh>;
  70426. colors?: Color4[];
  70427. useVertexAlpha?: boolean;
  70428. }, scene?: Nullable<Scene>): LinesMesh;
  70429. /**
  70430. * Creates a dashed line mesh
  70431. * * 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
  70432. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70433. * * The parameter `points` is an array successive Vector3
  70434. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70435. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70436. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70437. * * 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
  70438. * * When updating an instance, remember that only point positions can change, not the number of points
  70439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70440. * @param name defines the name of the mesh
  70441. * @param options defines the options used to create the mesh
  70442. * @param scene defines the hosting scene
  70443. * @returns the dashed line mesh
  70444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70445. */
  70446. static CreateDashedLines(name: string, options: {
  70447. points: Vector3[];
  70448. dashSize?: number;
  70449. gapSize?: number;
  70450. dashNb?: number;
  70451. updatable?: boolean;
  70452. instance?: LinesMesh;
  70453. }, scene?: Nullable<Scene>): LinesMesh;
  70454. /**
  70455. * 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.
  70456. * * 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.
  70457. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70458. * * 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.
  70459. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70460. * * 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
  70461. * * 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
  70462. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70464. * * 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
  70465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70467. * @param name defines the name of the mesh
  70468. * @param options defines the options used to create the mesh
  70469. * @param scene defines the hosting scene
  70470. * @returns the extruded shape mesh
  70471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70473. */
  70474. static ExtrudeShape(name: string, options: {
  70475. shape: Vector3[];
  70476. path: Vector3[];
  70477. scale?: number;
  70478. rotation?: number;
  70479. cap?: number;
  70480. updatable?: boolean;
  70481. sideOrientation?: number;
  70482. frontUVs?: Vector4;
  70483. backUVs?: Vector4;
  70484. instance?: Mesh;
  70485. invertUV?: boolean;
  70486. }, scene?: Nullable<Scene>): Mesh;
  70487. /**
  70488. * Creates an custom extruded shape mesh.
  70489. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70490. * * 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.
  70491. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70492. * * 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
  70493. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70494. * * 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
  70495. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70496. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70497. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70498. * * 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
  70499. * * 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
  70500. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70502. * * 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
  70503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70505. * @param name defines the name of the mesh
  70506. * @param options defines the options used to create the mesh
  70507. * @param scene defines the hosting scene
  70508. * @returns the custom extruded shape mesh
  70509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70512. */
  70513. static ExtrudeShapeCustom(name: string, options: {
  70514. shape: Vector3[];
  70515. path: Vector3[];
  70516. scaleFunction?: any;
  70517. rotationFunction?: any;
  70518. ribbonCloseArray?: boolean;
  70519. ribbonClosePath?: boolean;
  70520. cap?: number;
  70521. updatable?: boolean;
  70522. sideOrientation?: number;
  70523. frontUVs?: Vector4;
  70524. backUVs?: Vector4;
  70525. instance?: Mesh;
  70526. invertUV?: boolean;
  70527. }, scene?: Nullable<Scene>): Mesh;
  70528. /**
  70529. * Creates lathe mesh.
  70530. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70531. * * 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
  70532. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70533. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70534. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70535. * * 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
  70536. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70537. * * 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
  70538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70539. * * 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
  70540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70542. * @param name defines the name of the mesh
  70543. * @param options defines the options used to create the mesh
  70544. * @param scene defines the hosting scene
  70545. * @returns the lathe mesh
  70546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70547. */
  70548. static CreateLathe(name: string, options: {
  70549. shape: Vector3[];
  70550. radius?: number;
  70551. tessellation?: number;
  70552. clip?: number;
  70553. arc?: number;
  70554. closed?: boolean;
  70555. updatable?: boolean;
  70556. sideOrientation?: number;
  70557. frontUVs?: Vector4;
  70558. backUVs?: Vector4;
  70559. cap?: number;
  70560. invertUV?: boolean;
  70561. }, scene?: Nullable<Scene>): Mesh;
  70562. /**
  70563. * Creates a tiled plane mesh
  70564. * * You can set a limited pattern arrangement with the tiles
  70565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70566. * * 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
  70567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70568. * @param name defines the name of the mesh
  70569. * @param options defines the options used to create the mesh
  70570. * @param scene defines the hosting scene
  70571. * @returns the plane mesh
  70572. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70573. */
  70574. static CreateTiledPlane(name: string, options: {
  70575. pattern?: number;
  70576. tileSize?: number;
  70577. tileWidth?: number;
  70578. tileHeight?: number;
  70579. size?: number;
  70580. width?: number;
  70581. height?: number;
  70582. alignHorizontal?: number;
  70583. alignVertical?: number;
  70584. sideOrientation?: number;
  70585. frontUVs?: Vector4;
  70586. backUVs?: Vector4;
  70587. updatable?: boolean;
  70588. }, scene?: Nullable<Scene>): Mesh;
  70589. /**
  70590. * Creates a plane mesh
  70591. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70592. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70593. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70595. * * 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
  70596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70597. * @param name defines the name of the mesh
  70598. * @param options defines the options used to create the mesh
  70599. * @param scene defines the hosting scene
  70600. * @returns the plane mesh
  70601. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70602. */
  70603. static CreatePlane(name: string, options: {
  70604. size?: number;
  70605. width?: number;
  70606. height?: number;
  70607. sideOrientation?: number;
  70608. frontUVs?: Vector4;
  70609. backUVs?: Vector4;
  70610. updatable?: boolean;
  70611. sourcePlane?: Plane;
  70612. }, scene?: Nullable<Scene>): Mesh;
  70613. /**
  70614. * Creates a ground mesh
  70615. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70616. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70618. * @param name defines the name of the mesh
  70619. * @param options defines the options used to create the mesh
  70620. * @param scene defines the hosting scene
  70621. * @returns the ground mesh
  70622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70623. */
  70624. static CreateGround(name: string, options: {
  70625. width?: number;
  70626. height?: number;
  70627. subdivisions?: number;
  70628. subdivisionsX?: number;
  70629. subdivisionsY?: number;
  70630. updatable?: boolean;
  70631. }, scene?: Nullable<Scene>): Mesh;
  70632. /**
  70633. * Creates a tiled ground mesh
  70634. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70635. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70636. * * 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
  70637. * * 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
  70638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70639. * @param name defines the name of the mesh
  70640. * @param options defines the options used to create the mesh
  70641. * @param scene defines the hosting scene
  70642. * @returns the tiled ground mesh
  70643. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70644. */
  70645. static CreateTiledGround(name: string, options: {
  70646. xmin: number;
  70647. zmin: number;
  70648. xmax: number;
  70649. zmax: number;
  70650. subdivisions?: {
  70651. w: number;
  70652. h: number;
  70653. };
  70654. precision?: {
  70655. w: number;
  70656. h: number;
  70657. };
  70658. updatable?: boolean;
  70659. }, scene?: Nullable<Scene>): Mesh;
  70660. /**
  70661. * Creates a ground mesh from a height map
  70662. * * The parameter `url` sets the URL of the height map image resource.
  70663. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70664. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70665. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70666. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70667. * * 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.
  70668. * * 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).
  70669. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70671. * @param name defines the name of the mesh
  70672. * @param url defines the url to the height map
  70673. * @param options defines the options used to create the mesh
  70674. * @param scene defines the hosting scene
  70675. * @returns the ground mesh
  70676. * @see https://doc.babylonjs.com/babylon101/height_map
  70677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70678. */
  70679. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70680. width?: number;
  70681. height?: number;
  70682. subdivisions?: number;
  70683. minHeight?: number;
  70684. maxHeight?: number;
  70685. colorFilter?: Color3;
  70686. alphaFilter?: number;
  70687. updatable?: boolean;
  70688. onReady?: (mesh: GroundMesh) => void;
  70689. }, scene?: Nullable<Scene>): GroundMesh;
  70690. /**
  70691. * Creates a polygon mesh
  70692. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70693. * * 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
  70694. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70696. * * 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)
  70697. * * Remember you can only change the shape positions, not their number when updating a polygon
  70698. * @param name defines the name of the mesh
  70699. * @param options defines the options used to create the mesh
  70700. * @param scene defines the hosting scene
  70701. * @param earcutInjection can be used to inject your own earcut reference
  70702. * @returns the polygon mesh
  70703. */
  70704. static CreatePolygon(name: string, options: {
  70705. shape: Vector3[];
  70706. holes?: Vector3[][];
  70707. depth?: number;
  70708. faceUV?: Vector4[];
  70709. faceColors?: Color4[];
  70710. updatable?: boolean;
  70711. sideOrientation?: number;
  70712. frontUVs?: Vector4;
  70713. backUVs?: Vector4;
  70714. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70715. /**
  70716. * Creates an extruded polygon mesh, with depth in the Y direction.
  70717. * * 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)
  70718. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70719. * @param name defines the name of the mesh
  70720. * @param options defines the options used to create the mesh
  70721. * @param scene defines the hosting scene
  70722. * @param earcutInjection can be used to inject your own earcut reference
  70723. * @returns the polygon mesh
  70724. */
  70725. static ExtrudePolygon(name: string, options: {
  70726. shape: Vector3[];
  70727. holes?: Vector3[][];
  70728. depth?: number;
  70729. faceUV?: Vector4[];
  70730. faceColors?: Color4[];
  70731. updatable?: boolean;
  70732. sideOrientation?: number;
  70733. frontUVs?: Vector4;
  70734. backUVs?: Vector4;
  70735. wrap?: boolean;
  70736. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70737. /**
  70738. * Creates a tube mesh.
  70739. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70740. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70741. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70742. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70743. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70744. * * 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)
  70745. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70746. * * 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
  70747. * * 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
  70748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70749. * * 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
  70750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70752. * @param name defines the name of the mesh
  70753. * @param options defines the options used to create the mesh
  70754. * @param scene defines the hosting scene
  70755. * @returns the tube mesh
  70756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70757. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70758. */
  70759. static CreateTube(name: string, options: {
  70760. path: Vector3[];
  70761. radius?: number;
  70762. tessellation?: number;
  70763. radiusFunction?: {
  70764. (i: number, distance: number): number;
  70765. };
  70766. cap?: number;
  70767. arc?: number;
  70768. updatable?: boolean;
  70769. sideOrientation?: number;
  70770. frontUVs?: Vector4;
  70771. backUVs?: Vector4;
  70772. instance?: Mesh;
  70773. invertUV?: boolean;
  70774. }, scene?: Nullable<Scene>): Mesh;
  70775. /**
  70776. * Creates a polyhedron mesh
  70777. * * 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
  70778. * * The parameter `size` (positive float, default 1) sets the polygon size
  70779. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70780. * * 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`
  70781. * * 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
  70782. * * 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)`)
  70783. * * 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
  70784. * * 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
  70785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70786. * * 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
  70787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70788. * @param name defines the name of the mesh
  70789. * @param options defines the options used to create the mesh
  70790. * @param scene defines the hosting scene
  70791. * @returns the polyhedron mesh
  70792. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70793. */
  70794. static CreatePolyhedron(name: string, options: {
  70795. type?: number;
  70796. size?: number;
  70797. sizeX?: number;
  70798. sizeY?: number;
  70799. sizeZ?: number;
  70800. custom?: any;
  70801. faceUV?: Vector4[];
  70802. faceColors?: Color4[];
  70803. flat?: boolean;
  70804. updatable?: boolean;
  70805. sideOrientation?: number;
  70806. frontUVs?: Vector4;
  70807. backUVs?: Vector4;
  70808. }, scene?: Nullable<Scene>): Mesh;
  70809. /**
  70810. * Creates a decal mesh.
  70811. * 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
  70812. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70813. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70814. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70815. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70816. * @param name defines the name of the mesh
  70817. * @param sourceMesh defines the mesh where the decal must be applied
  70818. * @param options defines the options used to create the mesh
  70819. * @param scene defines the hosting scene
  70820. * @returns the decal mesh
  70821. * @see https://doc.babylonjs.com/how_to/decals
  70822. */
  70823. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70824. position?: Vector3;
  70825. normal?: Vector3;
  70826. size?: Vector3;
  70827. angle?: number;
  70828. }): Mesh;
  70829. /**
  70830. * Creates a Capsule Mesh
  70831. * @param name defines the name of the mesh.
  70832. * @param options the constructors options used to shape the mesh.
  70833. * @param scene defines the scene the mesh is scoped to.
  70834. * @returns the capsule mesh
  70835. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70836. */
  70837. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70838. }
  70839. }
  70840. declare module BABYLON {
  70841. /**
  70842. * A simplifier interface for future simplification implementations
  70843. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70844. */
  70845. export interface ISimplifier {
  70846. /**
  70847. * Simplification of a given mesh according to the given settings.
  70848. * Since this requires computation, it is assumed that the function runs async.
  70849. * @param settings The settings of the simplification, including quality and distance
  70850. * @param successCallback A callback that will be called after the mesh was simplified.
  70851. * @param errorCallback in case of an error, this callback will be called. optional.
  70852. */
  70853. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70854. }
  70855. /**
  70856. * Expected simplification settings.
  70857. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70858. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70859. */
  70860. export interface ISimplificationSettings {
  70861. /**
  70862. * Gets or sets the expected quality
  70863. */
  70864. quality: number;
  70865. /**
  70866. * Gets or sets the distance when this optimized version should be used
  70867. */
  70868. distance: number;
  70869. /**
  70870. * Gets an already optimized mesh
  70871. */
  70872. optimizeMesh?: boolean;
  70873. }
  70874. /**
  70875. * Class used to specify simplification options
  70876. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70877. */
  70878. export class SimplificationSettings implements ISimplificationSettings {
  70879. /** expected quality */
  70880. quality: number;
  70881. /** distance when this optimized version should be used */
  70882. distance: number;
  70883. /** already optimized mesh */
  70884. optimizeMesh?: boolean | undefined;
  70885. /**
  70886. * Creates a SimplificationSettings
  70887. * @param quality expected quality
  70888. * @param distance distance when this optimized version should be used
  70889. * @param optimizeMesh already optimized mesh
  70890. */
  70891. constructor(
  70892. /** expected quality */
  70893. quality: number,
  70894. /** distance when this optimized version should be used */
  70895. distance: number,
  70896. /** already optimized mesh */
  70897. optimizeMesh?: boolean | undefined);
  70898. }
  70899. /**
  70900. * Interface used to define a simplification task
  70901. */
  70902. export interface ISimplificationTask {
  70903. /**
  70904. * Array of settings
  70905. */
  70906. settings: Array<ISimplificationSettings>;
  70907. /**
  70908. * Simplification type
  70909. */
  70910. simplificationType: SimplificationType;
  70911. /**
  70912. * Mesh to simplify
  70913. */
  70914. mesh: Mesh;
  70915. /**
  70916. * Callback called on success
  70917. */
  70918. successCallback?: () => void;
  70919. /**
  70920. * Defines if parallel processing can be used
  70921. */
  70922. parallelProcessing: boolean;
  70923. }
  70924. /**
  70925. * Queue used to order the simplification tasks
  70926. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70927. */
  70928. export class SimplificationQueue {
  70929. private _simplificationArray;
  70930. /**
  70931. * Gets a boolean indicating that the process is still running
  70932. */
  70933. running: boolean;
  70934. /**
  70935. * Creates a new queue
  70936. */
  70937. constructor();
  70938. /**
  70939. * Adds a new simplification task
  70940. * @param task defines a task to add
  70941. */
  70942. addTask(task: ISimplificationTask): void;
  70943. /**
  70944. * Execute next task
  70945. */
  70946. executeNext(): void;
  70947. /**
  70948. * Execute a simplification task
  70949. * @param task defines the task to run
  70950. */
  70951. runSimplification(task: ISimplificationTask): void;
  70952. private getSimplifier;
  70953. }
  70954. /**
  70955. * The implemented types of simplification
  70956. * At the moment only Quadratic Error Decimation is implemented
  70957. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70958. */
  70959. export enum SimplificationType {
  70960. /** Quadratic error decimation */
  70961. QUADRATIC = 0
  70962. }
  70963. /**
  70964. * An implementation of the Quadratic Error simplification algorithm.
  70965. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70966. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70967. * @author RaananW
  70968. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70969. */
  70970. export class QuadraticErrorSimplification implements ISimplifier {
  70971. private _mesh;
  70972. private triangles;
  70973. private vertices;
  70974. private references;
  70975. private _reconstructedMesh;
  70976. /** Gets or sets the number pf sync interations */
  70977. syncIterations: number;
  70978. /** Gets or sets the aggressiveness of the simplifier */
  70979. aggressiveness: number;
  70980. /** Gets or sets the number of allowed iterations for decimation */
  70981. decimationIterations: number;
  70982. /** Gets or sets the espilon to use for bounding box computation */
  70983. boundingBoxEpsilon: number;
  70984. /**
  70985. * Creates a new QuadraticErrorSimplification
  70986. * @param _mesh defines the target mesh
  70987. */
  70988. constructor(_mesh: Mesh);
  70989. /**
  70990. * Simplification of a given mesh according to the given settings.
  70991. * Since this requires computation, it is assumed that the function runs async.
  70992. * @param settings The settings of the simplification, including quality and distance
  70993. * @param successCallback A callback that will be called after the mesh was simplified.
  70994. */
  70995. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70996. private runDecimation;
  70997. private initWithMesh;
  70998. private init;
  70999. private reconstructMesh;
  71000. private initDecimatedMesh;
  71001. private isFlipped;
  71002. private updateTriangles;
  71003. private identifyBorder;
  71004. private updateMesh;
  71005. private vertexError;
  71006. private calculateError;
  71007. }
  71008. }
  71009. declare module BABYLON {
  71010. interface Scene {
  71011. /** @hidden (Backing field) */
  71012. _simplificationQueue: SimplificationQueue;
  71013. /**
  71014. * Gets or sets the simplification queue attached to the scene
  71015. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71016. */
  71017. simplificationQueue: SimplificationQueue;
  71018. }
  71019. interface Mesh {
  71020. /**
  71021. * Simplify the mesh according to the given array of settings.
  71022. * Function will return immediately and will simplify async
  71023. * @param settings a collection of simplification settings
  71024. * @param parallelProcessing should all levels calculate parallel or one after the other
  71025. * @param simplificationType the type of simplification to run
  71026. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71027. * @returns the current mesh
  71028. */
  71029. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71030. }
  71031. /**
  71032. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71033. * created in a scene
  71034. */
  71035. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71036. /**
  71037. * The component name helpfull to identify the component in the list of scene components.
  71038. */
  71039. readonly name: string;
  71040. /**
  71041. * The scene the component belongs to.
  71042. */
  71043. scene: Scene;
  71044. /**
  71045. * Creates a new instance of the component for the given scene
  71046. * @param scene Defines the scene to register the component in
  71047. */
  71048. constructor(scene: Scene);
  71049. /**
  71050. * Registers the component in a given scene
  71051. */
  71052. register(): void;
  71053. /**
  71054. * Rebuilds the elements related to this component in case of
  71055. * context lost for instance.
  71056. */
  71057. rebuild(): void;
  71058. /**
  71059. * Disposes the component and the associated ressources
  71060. */
  71061. dispose(): void;
  71062. private _beforeCameraUpdate;
  71063. }
  71064. }
  71065. declare module BABYLON {
  71066. interface Mesh {
  71067. /**
  71068. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71069. */
  71070. thinInstanceEnablePicking: boolean;
  71071. /**
  71072. * Creates a new thin instance
  71073. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71074. * @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
  71075. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71076. */
  71077. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71078. /**
  71079. * Adds the transformation (matrix) of the current mesh as a thin instance
  71080. * @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
  71081. * @returns the thin instance index number
  71082. */
  71083. thinInstanceAddSelf(refresh: boolean): number;
  71084. /**
  71085. * Registers a custom attribute to be used with thin instances
  71086. * @param kind name of the attribute
  71087. * @param stride size in floats of the attribute
  71088. */
  71089. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71090. /**
  71091. * Sets the matrix of a thin instance
  71092. * @param index index of the thin instance
  71093. * @param matrix matrix to set
  71094. * @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
  71095. */
  71096. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71097. /**
  71098. * Sets the value of a custom attribute for a thin instance
  71099. * @param kind name of the attribute
  71100. * @param index index of the thin instance
  71101. * @param value value to set
  71102. * @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
  71103. */
  71104. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71105. /**
  71106. * 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.
  71107. */
  71108. thinInstanceCount: number;
  71109. /**
  71110. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71111. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71112. * @param buffer buffer to set
  71113. * @param stride size in floats of each value of the buffer
  71114. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71115. */
  71116. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71117. /**
  71118. * Gets the list of world matrices
  71119. * @return an array containing all the world matrices from the thin instances
  71120. */
  71121. thinInstanceGetWorldMatrices(): Matrix[];
  71122. /**
  71123. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71124. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71125. */
  71126. thinInstanceBufferUpdated(kind: string): void;
  71127. /**
  71128. * Applies a partial update to a buffer directly on the GPU
  71129. * 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
  71130. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71131. * @param data the data to set in the GPU buffer
  71132. * @param offset the offset in the GPU buffer where to update the data
  71133. */
  71134. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71135. /**
  71136. * Refreshes the bounding info, taking into account all the thin instances defined
  71137. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71138. */
  71139. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71140. /** @hidden */
  71141. _thinInstanceInitializeUserStorage(): void;
  71142. /** @hidden */
  71143. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71144. /** @hidden */
  71145. _userThinInstanceBuffersStorage: {
  71146. data: {
  71147. [key: string]: Float32Array;
  71148. };
  71149. sizes: {
  71150. [key: string]: number;
  71151. };
  71152. vertexBuffers: {
  71153. [key: string]: Nullable<VertexBuffer>;
  71154. };
  71155. strides: {
  71156. [key: string]: number;
  71157. };
  71158. };
  71159. }
  71160. }
  71161. declare module BABYLON {
  71162. /**
  71163. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71164. */
  71165. export interface INavigationEnginePlugin {
  71166. /**
  71167. * plugin name
  71168. */
  71169. name: string;
  71170. /**
  71171. * Creates a navigation mesh
  71172. * @param meshes array of all the geometry used to compute the navigatio mesh
  71173. * @param parameters bunch of parameters used to filter geometry
  71174. */
  71175. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71176. /**
  71177. * Create a navigation mesh debug mesh
  71178. * @param scene is where the mesh will be added
  71179. * @returns debug display mesh
  71180. */
  71181. createDebugNavMesh(scene: Scene): Mesh;
  71182. /**
  71183. * Get a navigation mesh constrained position, closest to the parameter position
  71184. * @param position world position
  71185. * @returns the closest point to position constrained by the navigation mesh
  71186. */
  71187. getClosestPoint(position: Vector3): Vector3;
  71188. /**
  71189. * Get a navigation mesh constrained position, closest to the parameter position
  71190. * @param position world position
  71191. * @param result output the closest point to position constrained by the navigation mesh
  71192. */
  71193. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71194. /**
  71195. * Get a navigation mesh constrained position, within a particular radius
  71196. * @param position world position
  71197. * @param maxRadius the maximum distance to the constrained world position
  71198. * @returns the closest point to position constrained by the navigation mesh
  71199. */
  71200. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71201. /**
  71202. * Get a navigation mesh constrained position, within a particular radius
  71203. * @param position world position
  71204. * @param maxRadius the maximum distance to the constrained world position
  71205. * @param result output the closest point to position constrained by the navigation mesh
  71206. */
  71207. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71208. /**
  71209. * Compute the final position from a segment made of destination-position
  71210. * @param position world position
  71211. * @param destination world position
  71212. * @returns the resulting point along the navmesh
  71213. */
  71214. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71215. /**
  71216. * Compute the final position from a segment made of destination-position
  71217. * @param position world position
  71218. * @param destination world position
  71219. * @param result output the resulting point along the navmesh
  71220. */
  71221. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71222. /**
  71223. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71224. * @param start world position
  71225. * @param end world position
  71226. * @returns array containing world position composing the path
  71227. */
  71228. computePath(start: Vector3, end: Vector3): Vector3[];
  71229. /**
  71230. * If this plugin is supported
  71231. * @returns true if plugin is supported
  71232. */
  71233. isSupported(): boolean;
  71234. /**
  71235. * Create a new Crowd so you can add agents
  71236. * @param maxAgents the maximum agent count in the crowd
  71237. * @param maxAgentRadius the maximum radius an agent can have
  71238. * @param scene to attach the crowd to
  71239. * @returns the crowd you can add agents to
  71240. */
  71241. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71242. /**
  71243. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71244. * The queries will try to find a solution within those bounds
  71245. * default is (1,1,1)
  71246. * @param extent x,y,z value that define the extent around the queries point of reference
  71247. */
  71248. setDefaultQueryExtent(extent: Vector3): void;
  71249. /**
  71250. * Get the Bounding box extent specified by setDefaultQueryExtent
  71251. * @returns the box extent values
  71252. */
  71253. getDefaultQueryExtent(): Vector3;
  71254. /**
  71255. * build the navmesh from a previously saved state using getNavmeshData
  71256. * @param data the Uint8Array returned by getNavmeshData
  71257. */
  71258. buildFromNavmeshData(data: Uint8Array): void;
  71259. /**
  71260. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71261. * @returns data the Uint8Array that can be saved and reused
  71262. */
  71263. getNavmeshData(): Uint8Array;
  71264. /**
  71265. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71266. * @param result output the box extent values
  71267. */
  71268. getDefaultQueryExtentToRef(result: Vector3): void;
  71269. /**
  71270. * Set the time step of the navigation tick update.
  71271. * Default is 1/60.
  71272. * A value of 0 will disable fixed time update
  71273. * @param newTimeStep the new timestep to apply to this world.
  71274. */
  71275. setTimeStep(newTimeStep: number): void;
  71276. /**
  71277. * Get the time step of the navigation tick update.
  71278. * @returns the current time step
  71279. */
  71280. getTimeStep(): number;
  71281. /**
  71282. * If delta time in navigation tick update is greater than the time step
  71283. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71284. * they will be discarded.
  71285. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71286. * @param newStepCount the maximum number of iterations
  71287. */
  71288. setMaximumSubStepCount(newStepCount: number): void;
  71289. /**
  71290. * Get the maximum number of iterations per navigation tick update
  71291. * @returns the maximum number of iterations
  71292. */
  71293. getMaximumSubStepCount(): number;
  71294. /**
  71295. * Release all resources
  71296. */
  71297. dispose(): void;
  71298. }
  71299. /**
  71300. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71301. */
  71302. export interface ICrowd {
  71303. /**
  71304. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71305. * You can attach anything to that node. The node position is updated in the scene update tick.
  71306. * @param pos world position that will be constrained by the navigation mesh
  71307. * @param parameters agent parameters
  71308. * @param transform hooked to the agent that will be update by the scene
  71309. * @returns agent index
  71310. */
  71311. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71312. /**
  71313. * Returns the agent position in world space
  71314. * @param index agent index returned by addAgent
  71315. * @returns world space position
  71316. */
  71317. getAgentPosition(index: number): Vector3;
  71318. /**
  71319. * Gets the agent position result in world space
  71320. * @param index agent index returned by addAgent
  71321. * @param result output world space position
  71322. */
  71323. getAgentPositionToRef(index: number, result: Vector3): void;
  71324. /**
  71325. * Gets the agent velocity in world space
  71326. * @param index agent index returned by addAgent
  71327. * @returns world space velocity
  71328. */
  71329. getAgentVelocity(index: number): Vector3;
  71330. /**
  71331. * Gets the agent velocity result in world space
  71332. * @param index agent index returned by addAgent
  71333. * @param result output world space velocity
  71334. */
  71335. getAgentVelocityToRef(index: number, result: Vector3): void;
  71336. /**
  71337. * Gets the agent next target point on the path
  71338. * @param index agent index returned by addAgent
  71339. * @returns world space position
  71340. */
  71341. getAgentNextTargetPath(index: number): Vector3;
  71342. /**
  71343. * Gets the agent state
  71344. * @param index agent index returned by addAgent
  71345. * @returns agent state
  71346. */
  71347. getAgentState(index: number): number;
  71348. /**
  71349. * returns true if the agent in over an off mesh link connection
  71350. * @param index agent index returned by addAgent
  71351. * @returns true if over an off mesh link connection
  71352. */
  71353. overOffmeshConnection(index: number): boolean;
  71354. /**
  71355. * Gets the agent next target point on the path
  71356. * @param index agent index returned by addAgent
  71357. * @param result output world space position
  71358. */
  71359. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71360. /**
  71361. * remove a particular agent previously created
  71362. * @param index agent index returned by addAgent
  71363. */
  71364. removeAgent(index: number): void;
  71365. /**
  71366. * get the list of all agents attached to this crowd
  71367. * @returns list of agent indices
  71368. */
  71369. getAgents(): number[];
  71370. /**
  71371. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71372. * @param deltaTime in seconds
  71373. */
  71374. update(deltaTime: number): void;
  71375. /**
  71376. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71377. * @param index agent index returned by addAgent
  71378. * @param destination targeted world position
  71379. */
  71380. agentGoto(index: number, destination: Vector3): void;
  71381. /**
  71382. * Teleport the agent to a new position
  71383. * @param index agent index returned by addAgent
  71384. * @param destination targeted world position
  71385. */
  71386. agentTeleport(index: number, destination: Vector3): void;
  71387. /**
  71388. * Update agent parameters
  71389. * @param index agent index returned by addAgent
  71390. * @param parameters agent parameters
  71391. */
  71392. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71393. /**
  71394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71395. * The queries will try to find a solution within those bounds
  71396. * default is (1,1,1)
  71397. * @param extent x,y,z value that define the extent around the queries point of reference
  71398. */
  71399. setDefaultQueryExtent(extent: Vector3): void;
  71400. /**
  71401. * Get the Bounding box extent specified by setDefaultQueryExtent
  71402. * @returns the box extent values
  71403. */
  71404. getDefaultQueryExtent(): Vector3;
  71405. /**
  71406. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71407. * @param result output the box extent values
  71408. */
  71409. getDefaultQueryExtentToRef(result: Vector3): void;
  71410. /**
  71411. * Release all resources
  71412. */
  71413. dispose(): void;
  71414. }
  71415. /**
  71416. * Configures an agent
  71417. */
  71418. export interface IAgentParameters {
  71419. /**
  71420. * Agent radius. [Limit: >= 0]
  71421. */
  71422. radius: number;
  71423. /**
  71424. * Agent height. [Limit: > 0]
  71425. */
  71426. height: number;
  71427. /**
  71428. * Maximum allowed acceleration. [Limit: >= 0]
  71429. */
  71430. maxAcceleration: number;
  71431. /**
  71432. * Maximum allowed speed. [Limit: >= 0]
  71433. */
  71434. maxSpeed: number;
  71435. /**
  71436. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71437. */
  71438. collisionQueryRange: number;
  71439. /**
  71440. * The path visibility optimization range. [Limit: > 0]
  71441. */
  71442. pathOptimizationRange: number;
  71443. /**
  71444. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71445. */
  71446. separationWeight: number;
  71447. }
  71448. /**
  71449. * Configures the navigation mesh creation
  71450. */
  71451. export interface INavMeshParameters {
  71452. /**
  71453. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71454. */
  71455. cs: number;
  71456. /**
  71457. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71458. */
  71459. ch: number;
  71460. /**
  71461. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71462. */
  71463. walkableSlopeAngle: number;
  71464. /**
  71465. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71466. * be considered walkable. [Limit: >= 3] [Units: vx]
  71467. */
  71468. walkableHeight: number;
  71469. /**
  71470. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71471. */
  71472. walkableClimb: number;
  71473. /**
  71474. * The distance to erode/shrink the walkable area of the heightfield away from
  71475. * obstructions. [Limit: >=0] [Units: vx]
  71476. */
  71477. walkableRadius: number;
  71478. /**
  71479. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71480. */
  71481. maxEdgeLen: number;
  71482. /**
  71483. * The maximum distance a simplfied contour's border edges should deviate
  71484. * the original raw contour. [Limit: >=0] [Units: vx]
  71485. */
  71486. maxSimplificationError: number;
  71487. /**
  71488. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71489. */
  71490. minRegionArea: number;
  71491. /**
  71492. * Any regions with a span count smaller than this value will, if possible,
  71493. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71494. */
  71495. mergeRegionArea: number;
  71496. /**
  71497. * The maximum number of vertices allowed for polygons generated during the
  71498. * contour to polygon conversion process. [Limit: >= 3]
  71499. */
  71500. maxVertsPerPoly: number;
  71501. /**
  71502. * Sets the sampling distance to use when generating the detail mesh.
  71503. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71504. */
  71505. detailSampleDist: number;
  71506. /**
  71507. * The maximum distance the detail mesh surface should deviate from heightfield
  71508. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71509. */
  71510. detailSampleMaxError: number;
  71511. }
  71512. }
  71513. declare module BABYLON {
  71514. /**
  71515. * RecastJS navigation plugin
  71516. */
  71517. export class RecastJSPlugin implements INavigationEnginePlugin {
  71518. /**
  71519. * Reference to the Recast library
  71520. */
  71521. bjsRECAST: any;
  71522. /**
  71523. * plugin name
  71524. */
  71525. name: string;
  71526. /**
  71527. * the first navmesh created. We might extend this to support multiple navmeshes
  71528. */
  71529. navMesh: any;
  71530. private _maximumSubStepCount;
  71531. private _timeStep;
  71532. /**
  71533. * Initializes the recastJS plugin
  71534. * @param recastInjection can be used to inject your own recast reference
  71535. */
  71536. constructor(recastInjection?: any);
  71537. /**
  71538. * Set the time step of the navigation tick update.
  71539. * Default is 1/60.
  71540. * A value of 0 will disable fixed time update
  71541. * @param newTimeStep the new timestep to apply to this world.
  71542. */
  71543. setTimeStep(newTimeStep?: number): void;
  71544. /**
  71545. * Get the time step of the navigation tick update.
  71546. * @returns the current time step
  71547. */
  71548. getTimeStep(): number;
  71549. /**
  71550. * If delta time in navigation tick update is greater than the time step
  71551. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71552. * they will be discarded.
  71553. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71554. * @param newStepCount the maximum number of iterations
  71555. */
  71556. setMaximumSubStepCount(newStepCount?: number): void;
  71557. /**
  71558. * Get the maximum number of iterations per navigation tick update
  71559. * @returns the maximum number of iterations
  71560. */
  71561. getMaximumSubStepCount(): number;
  71562. /**
  71563. * Creates a navigation mesh
  71564. * @param meshes array of all the geometry used to compute the navigatio mesh
  71565. * @param parameters bunch of parameters used to filter geometry
  71566. */
  71567. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71568. /**
  71569. * Create a navigation mesh debug mesh
  71570. * @param scene is where the mesh will be added
  71571. * @returns debug display mesh
  71572. */
  71573. createDebugNavMesh(scene: Scene): Mesh;
  71574. /**
  71575. * Get a navigation mesh constrained position, closest to the parameter position
  71576. * @param position world position
  71577. * @returns the closest point to position constrained by the navigation mesh
  71578. */
  71579. getClosestPoint(position: Vector3): Vector3;
  71580. /**
  71581. * Get a navigation mesh constrained position, closest to the parameter position
  71582. * @param position world position
  71583. * @param result output the closest point to position constrained by the navigation mesh
  71584. */
  71585. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71586. /**
  71587. * Get a navigation mesh constrained position, within a particular radius
  71588. * @param position world position
  71589. * @param maxRadius the maximum distance to the constrained world position
  71590. * @returns the closest point to position constrained by the navigation mesh
  71591. */
  71592. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71593. /**
  71594. * Get a navigation mesh constrained position, within a particular radius
  71595. * @param position world position
  71596. * @param maxRadius the maximum distance to the constrained world position
  71597. * @param result output the closest point to position constrained by the navigation mesh
  71598. */
  71599. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71600. /**
  71601. * Compute the final position from a segment made of destination-position
  71602. * @param position world position
  71603. * @param destination world position
  71604. * @returns the resulting point along the navmesh
  71605. */
  71606. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71607. /**
  71608. * Compute the final position from a segment made of destination-position
  71609. * @param position world position
  71610. * @param destination world position
  71611. * @param result output the resulting point along the navmesh
  71612. */
  71613. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71614. /**
  71615. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71616. * @param start world position
  71617. * @param end world position
  71618. * @returns array containing world position composing the path
  71619. */
  71620. computePath(start: Vector3, end: Vector3): Vector3[];
  71621. /**
  71622. * Create a new Crowd so you can add agents
  71623. * @param maxAgents the maximum agent count in the crowd
  71624. * @param maxAgentRadius the maximum radius an agent can have
  71625. * @param scene to attach the crowd to
  71626. * @returns the crowd you can add agents to
  71627. */
  71628. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71629. /**
  71630. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71631. * The queries will try to find a solution within those bounds
  71632. * default is (1,1,1)
  71633. * @param extent x,y,z value that define the extent around the queries point of reference
  71634. */
  71635. setDefaultQueryExtent(extent: Vector3): void;
  71636. /**
  71637. * Get the Bounding box extent specified by setDefaultQueryExtent
  71638. * @returns the box extent values
  71639. */
  71640. getDefaultQueryExtent(): Vector3;
  71641. /**
  71642. * build the navmesh from a previously saved state using getNavmeshData
  71643. * @param data the Uint8Array returned by getNavmeshData
  71644. */
  71645. buildFromNavmeshData(data: Uint8Array): void;
  71646. /**
  71647. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71648. * @returns data the Uint8Array that can be saved and reused
  71649. */
  71650. getNavmeshData(): Uint8Array;
  71651. /**
  71652. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71653. * @param result output the box extent values
  71654. */
  71655. getDefaultQueryExtentToRef(result: Vector3): void;
  71656. /**
  71657. * Disposes
  71658. */
  71659. dispose(): void;
  71660. /**
  71661. * If this plugin is supported
  71662. * @returns true if plugin is supported
  71663. */
  71664. isSupported(): boolean;
  71665. }
  71666. /**
  71667. * Recast detour crowd implementation
  71668. */
  71669. export class RecastJSCrowd implements ICrowd {
  71670. /**
  71671. * Recast/detour plugin
  71672. */
  71673. bjsRECASTPlugin: RecastJSPlugin;
  71674. /**
  71675. * Link to the detour crowd
  71676. */
  71677. recastCrowd: any;
  71678. /**
  71679. * One transform per agent
  71680. */
  71681. transforms: TransformNode[];
  71682. /**
  71683. * All agents created
  71684. */
  71685. agents: number[];
  71686. /**
  71687. * Link to the scene is kept to unregister the crowd from the scene
  71688. */
  71689. private _scene;
  71690. /**
  71691. * Observer for crowd updates
  71692. */
  71693. private _onBeforeAnimationsObserver;
  71694. /**
  71695. * Constructor
  71696. * @param plugin recastJS plugin
  71697. * @param maxAgents the maximum agent count in the crowd
  71698. * @param maxAgentRadius the maximum radius an agent can have
  71699. * @param scene to attach the crowd to
  71700. * @returns the crowd you can add agents to
  71701. */
  71702. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71703. /**
  71704. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71705. * You can attach anything to that node. The node position is updated in the scene update tick.
  71706. * @param pos world position that will be constrained by the navigation mesh
  71707. * @param parameters agent parameters
  71708. * @param transform hooked to the agent that will be update by the scene
  71709. * @returns agent index
  71710. */
  71711. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71712. /**
  71713. * Returns the agent position in world space
  71714. * @param index agent index returned by addAgent
  71715. * @returns world space position
  71716. */
  71717. getAgentPosition(index: number): Vector3;
  71718. /**
  71719. * Returns the agent position result in world space
  71720. * @param index agent index returned by addAgent
  71721. * @param result output world space position
  71722. */
  71723. getAgentPositionToRef(index: number, result: Vector3): void;
  71724. /**
  71725. * Returns the agent velocity in world space
  71726. * @param index agent index returned by addAgent
  71727. * @returns world space velocity
  71728. */
  71729. getAgentVelocity(index: number): Vector3;
  71730. /**
  71731. * Returns the agent velocity result in world space
  71732. * @param index agent index returned by addAgent
  71733. * @param result output world space velocity
  71734. */
  71735. getAgentVelocityToRef(index: number, result: Vector3): void;
  71736. /**
  71737. * Returns the agent next target point on the path
  71738. * @param index agent index returned by addAgent
  71739. * @returns world space position
  71740. */
  71741. getAgentNextTargetPath(index: number): Vector3;
  71742. /**
  71743. * Returns the agent next target point on the path
  71744. * @param index agent index returned by addAgent
  71745. * @param result output world space position
  71746. */
  71747. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71748. /**
  71749. * Gets the agent state
  71750. * @param index agent index returned by addAgent
  71751. * @returns agent state
  71752. */
  71753. getAgentState(index: number): number;
  71754. /**
  71755. * returns true if the agent in over an off mesh link connection
  71756. * @param index agent index returned by addAgent
  71757. * @returns true if over an off mesh link connection
  71758. */
  71759. overOffmeshConnection(index: number): boolean;
  71760. /**
  71761. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71762. * @param index agent index returned by addAgent
  71763. * @param destination targeted world position
  71764. */
  71765. agentGoto(index: number, destination: Vector3): void;
  71766. /**
  71767. * Teleport the agent to a new position
  71768. * @param index agent index returned by addAgent
  71769. * @param destination targeted world position
  71770. */
  71771. agentTeleport(index: number, destination: Vector3): void;
  71772. /**
  71773. * Update agent parameters
  71774. * @param index agent index returned by addAgent
  71775. * @param parameters agent parameters
  71776. */
  71777. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71778. /**
  71779. * remove a particular agent previously created
  71780. * @param index agent index returned by addAgent
  71781. */
  71782. removeAgent(index: number): void;
  71783. /**
  71784. * get the list of all agents attached to this crowd
  71785. * @returns list of agent indices
  71786. */
  71787. getAgents(): number[];
  71788. /**
  71789. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71790. * @param deltaTime in seconds
  71791. */
  71792. update(deltaTime: number): void;
  71793. /**
  71794. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71795. * The queries will try to find a solution within those bounds
  71796. * default is (1,1,1)
  71797. * @param extent x,y,z value that define the extent around the queries point of reference
  71798. */
  71799. setDefaultQueryExtent(extent: Vector3): void;
  71800. /**
  71801. * Get the Bounding box extent specified by setDefaultQueryExtent
  71802. * @returns the box extent values
  71803. */
  71804. getDefaultQueryExtent(): Vector3;
  71805. /**
  71806. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71807. * @param result output the box extent values
  71808. */
  71809. getDefaultQueryExtentToRef(result: Vector3): void;
  71810. /**
  71811. * Release all resources
  71812. */
  71813. dispose(): void;
  71814. }
  71815. }
  71816. declare module BABYLON {
  71817. /**
  71818. * Class used to enable access to IndexedDB
  71819. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71820. */
  71821. export class Database implements IOfflineProvider {
  71822. private _callbackManifestChecked;
  71823. private _currentSceneUrl;
  71824. private _db;
  71825. private _enableSceneOffline;
  71826. private _enableTexturesOffline;
  71827. private _manifestVersionFound;
  71828. private _mustUpdateRessources;
  71829. private _hasReachedQuota;
  71830. private _isSupported;
  71831. private _idbFactory;
  71832. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71833. private static IsUASupportingBlobStorage;
  71834. /**
  71835. * Gets a boolean indicating if Database storate is enabled (off by default)
  71836. */
  71837. static IDBStorageEnabled: boolean;
  71838. /**
  71839. * Gets a boolean indicating if scene must be saved in the database
  71840. */
  71841. get enableSceneOffline(): boolean;
  71842. /**
  71843. * Gets a boolean indicating if textures must be saved in the database
  71844. */
  71845. get enableTexturesOffline(): boolean;
  71846. /**
  71847. * Creates a new Database
  71848. * @param urlToScene defines the url to load the scene
  71849. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71850. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71851. */
  71852. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71853. private static _ParseURL;
  71854. private static _ReturnFullUrlLocation;
  71855. private _checkManifestFile;
  71856. /**
  71857. * Open the database and make it available
  71858. * @param successCallback defines the callback to call on success
  71859. * @param errorCallback defines the callback to call on error
  71860. */
  71861. open(successCallback: () => void, errorCallback: () => void): void;
  71862. /**
  71863. * Loads an image from the database
  71864. * @param url defines the url to load from
  71865. * @param image defines the target DOM image
  71866. */
  71867. loadImage(url: string, image: HTMLImageElement): void;
  71868. private _loadImageFromDBAsync;
  71869. private _saveImageIntoDBAsync;
  71870. private _checkVersionFromDB;
  71871. private _loadVersionFromDBAsync;
  71872. private _saveVersionIntoDBAsync;
  71873. /**
  71874. * Loads a file from database
  71875. * @param url defines the URL to load from
  71876. * @param sceneLoaded defines a callback to call on success
  71877. * @param progressCallBack defines a callback to call when progress changed
  71878. * @param errorCallback defines a callback to call on error
  71879. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71880. */
  71881. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71882. private _loadFileAsync;
  71883. private _saveFileAsync;
  71884. /**
  71885. * Validates if xhr data is correct
  71886. * @param xhr defines the request to validate
  71887. * @param dataType defines the expected data type
  71888. * @returns true if data is correct
  71889. */
  71890. private static _ValidateXHRData;
  71891. }
  71892. }
  71893. declare module BABYLON {
  71894. /** @hidden */
  71895. export var gpuUpdateParticlesPixelShader: {
  71896. name: string;
  71897. shader: string;
  71898. };
  71899. }
  71900. declare module BABYLON {
  71901. /** @hidden */
  71902. export var gpuUpdateParticlesVertexShader: {
  71903. name: string;
  71904. shader: string;
  71905. };
  71906. }
  71907. declare module BABYLON {
  71908. /** @hidden */
  71909. export var clipPlaneFragmentDeclaration2: {
  71910. name: string;
  71911. shader: string;
  71912. };
  71913. }
  71914. declare module BABYLON {
  71915. /** @hidden */
  71916. export var gpuRenderParticlesPixelShader: {
  71917. name: string;
  71918. shader: string;
  71919. };
  71920. }
  71921. declare module BABYLON {
  71922. /** @hidden */
  71923. export var clipPlaneVertexDeclaration2: {
  71924. name: string;
  71925. shader: string;
  71926. };
  71927. }
  71928. declare module BABYLON {
  71929. /** @hidden */
  71930. export var gpuRenderParticlesVertexShader: {
  71931. name: string;
  71932. shader: string;
  71933. };
  71934. }
  71935. declare module BABYLON {
  71936. /**
  71937. * This represents a GPU particle system in Babylon
  71938. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71939. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71940. */
  71941. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71942. /**
  71943. * The layer mask we are rendering the particles through.
  71944. */
  71945. layerMask: number;
  71946. private _capacity;
  71947. private _activeCount;
  71948. private _currentActiveCount;
  71949. private _accumulatedCount;
  71950. private _renderEffect;
  71951. private _updateEffect;
  71952. private _buffer0;
  71953. private _buffer1;
  71954. private _spriteBuffer;
  71955. private _updateVAO;
  71956. private _renderVAO;
  71957. private _targetIndex;
  71958. private _sourceBuffer;
  71959. private _targetBuffer;
  71960. private _currentRenderId;
  71961. private _started;
  71962. private _stopped;
  71963. private _timeDelta;
  71964. private _randomTexture;
  71965. private _randomTexture2;
  71966. private _attributesStrideSize;
  71967. private _updateEffectOptions;
  71968. private _randomTextureSize;
  71969. private _actualFrame;
  71970. private _customEffect;
  71971. private readonly _rawTextureWidth;
  71972. /**
  71973. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71974. */
  71975. static get IsSupported(): boolean;
  71976. /**
  71977. * An event triggered when the system is disposed.
  71978. */
  71979. onDisposeObservable: Observable<IParticleSystem>;
  71980. /**
  71981. * An event triggered when the system is stopped
  71982. */
  71983. onStoppedObservable: Observable<IParticleSystem>;
  71984. /**
  71985. * Gets the maximum number of particles active at the same time.
  71986. * @returns The max number of active particles.
  71987. */
  71988. getCapacity(): number;
  71989. /**
  71990. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71991. * to override the particles.
  71992. */
  71993. forceDepthWrite: boolean;
  71994. /**
  71995. * Gets or set the number of active particles
  71996. */
  71997. get activeParticleCount(): number;
  71998. set activeParticleCount(value: number);
  71999. private _preWarmDone;
  72000. /**
  72001. * Specifies if the particles are updated in emitter local space or world space.
  72002. */
  72003. isLocal: boolean;
  72004. /** Gets or sets a matrix to use to compute projection */
  72005. defaultProjectionMatrix: Matrix;
  72006. /**
  72007. * Is this system ready to be used/rendered
  72008. * @return true if the system is ready
  72009. */
  72010. isReady(): boolean;
  72011. /**
  72012. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72013. * @returns True if it has been started, otherwise false.
  72014. */
  72015. isStarted(): boolean;
  72016. /**
  72017. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72018. * @returns True if it has been stopped, otherwise false.
  72019. */
  72020. isStopped(): boolean;
  72021. /**
  72022. * Gets a boolean indicating that the system is stopping
  72023. * @returns true if the system is currently stopping
  72024. */
  72025. isStopping(): boolean;
  72026. /**
  72027. * Gets the number of particles active at the same time.
  72028. * @returns The number of active particles.
  72029. */
  72030. getActiveCount(): number;
  72031. /**
  72032. * Starts the particle system and begins to emit
  72033. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72034. */
  72035. start(delay?: number): void;
  72036. /**
  72037. * Stops the particle system.
  72038. */
  72039. stop(): void;
  72040. /**
  72041. * Remove all active particles
  72042. */
  72043. reset(): void;
  72044. /**
  72045. * Returns the string "GPUParticleSystem"
  72046. * @returns a string containing the class name
  72047. */
  72048. getClassName(): string;
  72049. /**
  72050. * Gets the custom effect used to render the particles
  72051. * @param blendMode Blend mode for which the effect should be retrieved
  72052. * @returns The effect
  72053. */
  72054. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72055. /**
  72056. * Sets the custom effect used to render the particles
  72057. * @param effect The effect to set
  72058. * @param blendMode Blend mode for which the effect should be set
  72059. */
  72060. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72061. /** @hidden */
  72062. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72063. /**
  72064. * Observable that will be called just before the particles are drawn
  72065. */
  72066. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72067. /**
  72068. * Gets the name of the particle vertex shader
  72069. */
  72070. get vertexShaderName(): string;
  72071. private _colorGradientsTexture;
  72072. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72073. /**
  72074. * Adds a new color gradient
  72075. * @param gradient defines the gradient to use (between 0 and 1)
  72076. * @param color1 defines the color to affect to the specified gradient
  72077. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72078. * @returns the current particle system
  72079. */
  72080. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72081. private _refreshColorGradient;
  72082. /** Force the system to rebuild all gradients that need to be resync */
  72083. forceRefreshGradients(): void;
  72084. /**
  72085. * Remove a specific color gradient
  72086. * @param gradient defines the gradient to remove
  72087. * @returns the current particle system
  72088. */
  72089. removeColorGradient(gradient: number): GPUParticleSystem;
  72090. private _angularSpeedGradientsTexture;
  72091. private _sizeGradientsTexture;
  72092. private _velocityGradientsTexture;
  72093. private _limitVelocityGradientsTexture;
  72094. private _dragGradientsTexture;
  72095. private _addFactorGradient;
  72096. /**
  72097. * Adds a new size gradient
  72098. * @param gradient defines the gradient to use (between 0 and 1)
  72099. * @param factor defines the size factor to affect to the specified gradient
  72100. * @returns the current particle system
  72101. */
  72102. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72103. /**
  72104. * Remove a specific size gradient
  72105. * @param gradient defines the gradient to remove
  72106. * @returns the current particle system
  72107. */
  72108. removeSizeGradient(gradient: number): GPUParticleSystem;
  72109. private _refreshFactorGradient;
  72110. /**
  72111. * Adds a new angular speed gradient
  72112. * @param gradient defines the gradient to use (between 0 and 1)
  72113. * @param factor defines the angular speed to affect to the specified gradient
  72114. * @returns the current particle system
  72115. */
  72116. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72117. /**
  72118. * Remove a specific angular speed gradient
  72119. * @param gradient defines the gradient to remove
  72120. * @returns the current particle system
  72121. */
  72122. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72123. /**
  72124. * Adds a new velocity gradient
  72125. * @param gradient defines the gradient to use (between 0 and 1)
  72126. * @param factor defines the velocity to affect to the specified gradient
  72127. * @returns the current particle system
  72128. */
  72129. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72130. /**
  72131. * Remove a specific velocity gradient
  72132. * @param gradient defines the gradient to remove
  72133. * @returns the current particle system
  72134. */
  72135. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72136. /**
  72137. * Adds a new limit velocity gradient
  72138. * @param gradient defines the gradient to use (between 0 and 1)
  72139. * @param factor defines the limit velocity value to affect to the specified gradient
  72140. * @returns the current particle system
  72141. */
  72142. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72143. /**
  72144. * Remove a specific limit velocity gradient
  72145. * @param gradient defines the gradient to remove
  72146. * @returns the current particle system
  72147. */
  72148. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72149. /**
  72150. * Adds a new drag gradient
  72151. * @param gradient defines the gradient to use (between 0 and 1)
  72152. * @param factor defines the drag value to affect to the specified gradient
  72153. * @returns the current particle system
  72154. */
  72155. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72156. /**
  72157. * Remove a specific drag gradient
  72158. * @param gradient defines the gradient to remove
  72159. * @returns the current particle system
  72160. */
  72161. removeDragGradient(gradient: number): GPUParticleSystem;
  72162. /**
  72163. * Not supported by GPUParticleSystem
  72164. * @param gradient defines the gradient to use (between 0 and 1)
  72165. * @param factor defines the emit rate value to affect to the specified gradient
  72166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72167. * @returns the current particle system
  72168. */
  72169. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72170. /**
  72171. * Not supported by GPUParticleSystem
  72172. * @param gradient defines the gradient to remove
  72173. * @returns the current particle system
  72174. */
  72175. removeEmitRateGradient(gradient: number): IParticleSystem;
  72176. /**
  72177. * Not supported by GPUParticleSystem
  72178. * @param gradient defines the gradient to use (between 0 and 1)
  72179. * @param factor defines the start size value to affect to the specified gradient
  72180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72181. * @returns the current particle system
  72182. */
  72183. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72184. /**
  72185. * Not supported by GPUParticleSystem
  72186. * @param gradient defines the gradient to remove
  72187. * @returns the current particle system
  72188. */
  72189. removeStartSizeGradient(gradient: number): IParticleSystem;
  72190. /**
  72191. * Not supported by GPUParticleSystem
  72192. * @param gradient defines the gradient to use (between 0 and 1)
  72193. * @param min defines the color remap minimal range
  72194. * @param max defines the color remap maximal range
  72195. * @returns the current particle system
  72196. */
  72197. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72198. /**
  72199. * Not supported by GPUParticleSystem
  72200. * @param gradient defines the gradient to remove
  72201. * @returns the current particle system
  72202. */
  72203. removeColorRemapGradient(): IParticleSystem;
  72204. /**
  72205. * Not supported by GPUParticleSystem
  72206. * @param gradient defines the gradient to use (between 0 and 1)
  72207. * @param min defines the alpha remap minimal range
  72208. * @param max defines the alpha remap maximal range
  72209. * @returns the current particle system
  72210. */
  72211. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72212. /**
  72213. * Not supported by GPUParticleSystem
  72214. * @param gradient defines the gradient to remove
  72215. * @returns the current particle system
  72216. */
  72217. removeAlphaRemapGradient(): IParticleSystem;
  72218. /**
  72219. * Not supported by GPUParticleSystem
  72220. * @param gradient defines the gradient to use (between 0 and 1)
  72221. * @param color defines the color to affect to the specified gradient
  72222. * @returns the current particle system
  72223. */
  72224. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72225. /**
  72226. * Not supported by GPUParticleSystem
  72227. * @param gradient defines the gradient to remove
  72228. * @returns the current particle system
  72229. */
  72230. removeRampGradient(): IParticleSystem;
  72231. /**
  72232. * Not supported by GPUParticleSystem
  72233. * @returns the list of ramp gradients
  72234. */
  72235. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72236. /**
  72237. * Not supported by GPUParticleSystem
  72238. * Gets or sets a boolean indicating that ramp gradients must be used
  72239. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72240. */
  72241. get useRampGradients(): boolean;
  72242. set useRampGradients(value: boolean);
  72243. /**
  72244. * Not supported by GPUParticleSystem
  72245. * @param gradient defines the gradient to use (between 0 and 1)
  72246. * @param factor defines the life time factor to affect to the specified gradient
  72247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72248. * @returns the current particle system
  72249. */
  72250. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72251. /**
  72252. * Not supported by GPUParticleSystem
  72253. * @param gradient defines the gradient to remove
  72254. * @returns the current particle system
  72255. */
  72256. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72257. /**
  72258. * Instantiates a GPU particle system.
  72259. * 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.
  72260. * @param name The name of the particle system
  72261. * @param options The options used to create the system
  72262. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72263. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72264. * @param customEffect a custom effect used to change the way particles are rendered by default
  72265. */
  72266. constructor(name: string, options: Partial<{
  72267. capacity: number;
  72268. randomTextureSize: number;
  72269. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72270. protected _reset(): void;
  72271. private _createUpdateVAO;
  72272. private _createRenderVAO;
  72273. private _initialize;
  72274. /** @hidden */
  72275. _recreateUpdateEffect(): void;
  72276. private _getEffect;
  72277. /**
  72278. * Fill the defines array according to the current settings of the particle system
  72279. * @param defines Array to be updated
  72280. * @param blendMode blend mode to take into account when updating the array
  72281. */
  72282. fillDefines(defines: Array<string>, blendMode?: number): void;
  72283. /**
  72284. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72285. * @param uniforms Uniforms array to fill
  72286. * @param attributes Attributes array to fill
  72287. * @param samplers Samplers array to fill
  72288. */
  72289. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72290. /** @hidden */
  72291. _recreateRenderEffect(): Effect;
  72292. /**
  72293. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72294. * @param preWarm defines if we are in the pre-warmimg phase
  72295. */
  72296. animate(preWarm?: boolean): void;
  72297. private _createFactorGradientTexture;
  72298. private _createSizeGradientTexture;
  72299. private _createAngularSpeedGradientTexture;
  72300. private _createVelocityGradientTexture;
  72301. private _createLimitVelocityGradientTexture;
  72302. private _createDragGradientTexture;
  72303. private _createColorGradientTexture;
  72304. /**
  72305. * Renders the particle system in its current state
  72306. * @param preWarm defines if the system should only update the particles but not render them
  72307. * @returns the current number of particles
  72308. */
  72309. render(preWarm?: boolean): number;
  72310. /**
  72311. * Rebuilds the particle system
  72312. */
  72313. rebuild(): void;
  72314. private _releaseBuffers;
  72315. private _releaseVAOs;
  72316. /**
  72317. * Disposes the particle system and free the associated resources
  72318. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72319. */
  72320. dispose(disposeTexture?: boolean): void;
  72321. /**
  72322. * Clones the particle system.
  72323. * @param name The name of the cloned object
  72324. * @param newEmitter The new emitter to use
  72325. * @returns the cloned particle system
  72326. */
  72327. clone(name: string, newEmitter: any): GPUParticleSystem;
  72328. /**
  72329. * Serializes the particle system to a JSON object
  72330. * @param serializeTexture defines if the texture must be serialized as well
  72331. * @returns the JSON object
  72332. */
  72333. serialize(serializeTexture?: boolean): any;
  72334. /**
  72335. * Parses a JSON object to create a GPU particle system.
  72336. * @param parsedParticleSystem The JSON object to parse
  72337. * @param sceneOrEngine The scene or the engine to create the particle system in
  72338. * @param rootUrl The root url to use to load external dependencies like texture
  72339. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72340. * @returns the parsed GPU particle system
  72341. */
  72342. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72343. }
  72344. }
  72345. declare module BABYLON {
  72346. /**
  72347. * Represents a set of particle systems working together to create a specific effect
  72348. */
  72349. export class ParticleSystemSet implements IDisposable {
  72350. /**
  72351. * Gets or sets base Assets URL
  72352. */
  72353. static BaseAssetsUrl: string;
  72354. private _emitterCreationOptions;
  72355. private _emitterNode;
  72356. /**
  72357. * Gets the particle system list
  72358. */
  72359. systems: IParticleSystem[];
  72360. /**
  72361. * Gets the emitter node used with this set
  72362. */
  72363. get emitterNode(): Nullable<TransformNode>;
  72364. /**
  72365. * Creates a new emitter mesh as a sphere
  72366. * @param options defines the options used to create the sphere
  72367. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72368. * @param scene defines the hosting scene
  72369. */
  72370. setEmitterAsSphere(options: {
  72371. diameter: number;
  72372. segments: number;
  72373. color: Color3;
  72374. }, renderingGroupId: number, scene: Scene): void;
  72375. /**
  72376. * Starts all particle systems of the set
  72377. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72378. */
  72379. start(emitter?: AbstractMesh): void;
  72380. /**
  72381. * Release all associated resources
  72382. */
  72383. dispose(): void;
  72384. /**
  72385. * Serialize the set into a JSON compatible object
  72386. * @param serializeTexture defines if the texture must be serialized as well
  72387. * @returns a JSON compatible representation of the set
  72388. */
  72389. serialize(serializeTexture?: boolean): any;
  72390. /**
  72391. * Parse a new ParticleSystemSet from a serialized source
  72392. * @param data defines a JSON compatible representation of the set
  72393. * @param scene defines the hosting scene
  72394. * @param gpu defines if we want GPU particles or CPU particles
  72395. * @returns a new ParticleSystemSet
  72396. */
  72397. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72398. }
  72399. }
  72400. declare module BABYLON {
  72401. /**
  72402. * This class is made for on one-liner static method to help creating particle system set.
  72403. */
  72404. export class ParticleHelper {
  72405. /**
  72406. * Gets or sets base Assets URL
  72407. */
  72408. static BaseAssetsUrl: string;
  72409. /** Define the Url to load snippets */
  72410. static SnippetUrl: string;
  72411. /**
  72412. * Create a default particle system that you can tweak
  72413. * @param emitter defines the emitter to use
  72414. * @param capacity defines the system capacity (default is 500 particles)
  72415. * @param scene defines the hosting scene
  72416. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72417. * @returns the new Particle system
  72418. */
  72419. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72420. /**
  72421. * This is the main static method (one-liner) of this helper to create different particle systems
  72422. * @param type This string represents the type to the particle system to create
  72423. * @param scene The scene where the particle system should live
  72424. * @param gpu If the system will use gpu
  72425. * @returns the ParticleSystemSet created
  72426. */
  72427. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72428. /**
  72429. * Static function used to export a particle system to a ParticleSystemSet variable.
  72430. * Please note that the emitter shape is not exported
  72431. * @param systems defines the particle systems to export
  72432. * @returns the created particle system set
  72433. */
  72434. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72435. /**
  72436. * Creates a particle system from a snippet saved in a remote file
  72437. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72438. * @param url defines the url to load from
  72439. * @param scene defines the hosting scene
  72440. * @param gpu If the system will use gpu
  72441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72442. * @returns a promise that will resolve to the new particle system
  72443. */
  72444. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72445. /**
  72446. * Creates a particle system from a snippet saved by the particle system editor
  72447. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72448. * @param scene defines the hosting scene
  72449. * @param gpu If the system will use gpu
  72450. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72451. * @returns a promise that will resolve to the new particle system
  72452. */
  72453. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72454. }
  72455. }
  72456. declare module BABYLON {
  72457. interface Engine {
  72458. /**
  72459. * Create an effect to use with particle systems.
  72460. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72461. * the particle system for which you want to create a custom effect in the last parameter
  72462. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72463. * @param uniformsNames defines a list of attribute names
  72464. * @param samplers defines an array of string used to represent textures
  72465. * @param defines defines the string containing the defines to use to compile the shaders
  72466. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72467. * @param onCompiled defines a function to call when the effect creation is successful
  72468. * @param onError defines a function to call when the effect creation has failed
  72469. * @param particleSystem the particle system you want to create the effect for
  72470. * @returns the new Effect
  72471. */
  72472. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72473. }
  72474. interface Mesh {
  72475. /**
  72476. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72477. * @returns an array of IParticleSystem
  72478. */
  72479. getEmittedParticleSystems(): IParticleSystem[];
  72480. /**
  72481. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72482. * @returns an array of IParticleSystem
  72483. */
  72484. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72485. }
  72486. }
  72487. declare module BABYLON {
  72488. /** Defines the 4 color options */
  72489. export enum PointColor {
  72490. /** color value */
  72491. Color = 2,
  72492. /** uv value */
  72493. UV = 1,
  72494. /** random value */
  72495. Random = 0,
  72496. /** stated value */
  72497. Stated = 3
  72498. }
  72499. /**
  72500. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72501. * 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.
  72502. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72503. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72504. *
  72505. * Full documentation here : TO BE ENTERED
  72506. */
  72507. export class PointsCloudSystem implements IDisposable {
  72508. /**
  72509. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72510. * Example : var p = SPS.particles[i];
  72511. */
  72512. particles: CloudPoint[];
  72513. /**
  72514. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72515. */
  72516. nbParticles: number;
  72517. /**
  72518. * This a counter for your own usage. It's not set by any SPS functions.
  72519. */
  72520. counter: number;
  72521. /**
  72522. * The PCS name. This name is also given to the underlying mesh.
  72523. */
  72524. name: string;
  72525. /**
  72526. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72527. */
  72528. mesh: Mesh;
  72529. /**
  72530. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72531. * Please read :
  72532. */
  72533. vars: any;
  72534. /**
  72535. * @hidden
  72536. */
  72537. _size: number;
  72538. private _scene;
  72539. private _promises;
  72540. private _positions;
  72541. private _indices;
  72542. private _normals;
  72543. private _colors;
  72544. private _uvs;
  72545. private _indices32;
  72546. private _positions32;
  72547. private _colors32;
  72548. private _uvs32;
  72549. private _updatable;
  72550. private _isVisibilityBoxLocked;
  72551. private _alwaysVisible;
  72552. private _groups;
  72553. private _groupCounter;
  72554. private _computeParticleColor;
  72555. private _computeParticleTexture;
  72556. private _computeParticleRotation;
  72557. private _computeBoundingBox;
  72558. private _isReady;
  72559. /**
  72560. * Creates a PCS (Points Cloud System) object
  72561. * @param name (String) is the PCS name, this will be the underlying mesh name
  72562. * @param pointSize (number) is the size for each point
  72563. * @param scene (Scene) is the scene in which the PCS is added
  72564. * @param options defines the options of the PCS e.g.
  72565. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72566. */
  72567. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72568. updatable?: boolean;
  72569. });
  72570. /**
  72571. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72572. * If no points were added to the PCS, the returned mesh is just a single point.
  72573. * @returns a promise for the created mesh
  72574. */
  72575. buildMeshAsync(): Promise<Mesh>;
  72576. /**
  72577. * @hidden
  72578. */
  72579. private _buildMesh;
  72580. private _addParticle;
  72581. private _randomUnitVector;
  72582. private _getColorIndicesForCoord;
  72583. private _setPointsColorOrUV;
  72584. private _colorFromTexture;
  72585. private _calculateDensity;
  72586. /**
  72587. * Adds points to the PCS in random positions within a unit sphere
  72588. * @param nb (positive integer) the number of particles to be created from this model
  72589. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72590. * @returns the number of groups in the system
  72591. */
  72592. addPoints(nb: number, pointFunction?: any): number;
  72593. /**
  72594. * Adds points to the PCS from the surface of the model shape
  72595. * @param mesh is any Mesh object that will be used as a surface model for the points
  72596. * @param nb (positive integer) the number of particles to be created from this model
  72597. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72598. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72599. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72600. * @returns the number of groups in the system
  72601. */
  72602. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72603. /**
  72604. * Adds points to the PCS inside the model shape
  72605. * @param mesh is any Mesh object that will be used as a surface model for the points
  72606. * @param nb (positive integer) the number of particles to be created from this model
  72607. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72608. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72609. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72610. * @returns the number of groups in the system
  72611. */
  72612. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72613. /**
  72614. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72615. * This method calls `updateParticle()` for each particle of the SPS.
  72616. * For an animated SPS, it is usually called within the render loop.
  72617. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72618. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72619. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72620. * @returns the PCS.
  72621. */
  72622. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72623. /**
  72624. * Disposes the PCS.
  72625. */
  72626. dispose(): void;
  72627. /**
  72628. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72629. * doc :
  72630. * @returns the PCS.
  72631. */
  72632. refreshVisibleSize(): PointsCloudSystem;
  72633. /**
  72634. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72635. * @param size the size (float) of the visibility box
  72636. * note : this doesn't lock the PCS mesh bounding box.
  72637. * doc :
  72638. */
  72639. setVisibilityBox(size: number): void;
  72640. /**
  72641. * Gets whether the PCS is always visible or not
  72642. * doc :
  72643. */
  72644. get isAlwaysVisible(): boolean;
  72645. /**
  72646. * Sets the PCS as always visible or not
  72647. * doc :
  72648. */
  72649. set isAlwaysVisible(val: boolean);
  72650. /**
  72651. * Tells to `setParticles()` to compute the particle rotations or not
  72652. * Default value : false. The PCS is faster when it's set to false
  72653. * Note : particle rotations are only applied to parent particles
  72654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72655. */
  72656. set computeParticleRotation(val: boolean);
  72657. /**
  72658. * Tells to `setParticles()` to compute the particle colors or not.
  72659. * Default value : true. The PCS is faster when it's set to false.
  72660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72661. */
  72662. set computeParticleColor(val: boolean);
  72663. set computeParticleTexture(val: boolean);
  72664. /**
  72665. * Gets if `setParticles()` computes the particle colors or not.
  72666. * Default value : false. The PCS is faster when it's set to false.
  72667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72668. */
  72669. get computeParticleColor(): boolean;
  72670. /**
  72671. * Gets if `setParticles()` computes the particle textures or not.
  72672. * Default value : false. The PCS is faster when it's set to false.
  72673. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72674. */
  72675. get computeParticleTexture(): boolean;
  72676. /**
  72677. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72678. */
  72679. set computeBoundingBox(val: boolean);
  72680. /**
  72681. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72682. */
  72683. get computeBoundingBox(): boolean;
  72684. /**
  72685. * This function does nothing. It may be overwritten to set all the particle first values.
  72686. * The PCS doesn't call this function, you may have to call it by your own.
  72687. * doc :
  72688. */
  72689. initParticles(): void;
  72690. /**
  72691. * This function does nothing. It may be overwritten to recycle a particle
  72692. * The PCS doesn't call this function, you can to call it
  72693. * doc :
  72694. * @param particle The particle to recycle
  72695. * @returns the recycled particle
  72696. */
  72697. recycleParticle(particle: CloudPoint): CloudPoint;
  72698. /**
  72699. * Updates a particle : this function should be overwritten by the user.
  72700. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72701. * doc :
  72702. * @example : just set a particle position or velocity and recycle conditions
  72703. * @param particle The particle to update
  72704. * @returns the updated particle
  72705. */
  72706. updateParticle(particle: CloudPoint): CloudPoint;
  72707. /**
  72708. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72709. * This does nothing and may be overwritten by the user.
  72710. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72711. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72712. * @param update the boolean update value actually passed to setParticles()
  72713. */
  72714. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72715. /**
  72716. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72717. * This will be passed three parameters.
  72718. * This does nothing and may be overwritten by the user.
  72719. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72721. * @param update the boolean update value actually passed to setParticles()
  72722. */
  72723. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72724. }
  72725. }
  72726. declare module BABYLON {
  72727. /**
  72728. * Represents one particle of a points cloud system.
  72729. */
  72730. export class CloudPoint {
  72731. /**
  72732. * particle global index
  72733. */
  72734. idx: number;
  72735. /**
  72736. * The color of the particle
  72737. */
  72738. color: Nullable<Color4>;
  72739. /**
  72740. * The world space position of the particle.
  72741. */
  72742. position: Vector3;
  72743. /**
  72744. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72745. */
  72746. rotation: Vector3;
  72747. /**
  72748. * The world space rotation quaternion of the particle.
  72749. */
  72750. rotationQuaternion: Nullable<Quaternion>;
  72751. /**
  72752. * The uv of the particle.
  72753. */
  72754. uv: Nullable<Vector2>;
  72755. /**
  72756. * The current speed of the particle.
  72757. */
  72758. velocity: Vector3;
  72759. /**
  72760. * The pivot point in the particle local space.
  72761. */
  72762. pivot: Vector3;
  72763. /**
  72764. * Must the particle be translated from its pivot point in its local space ?
  72765. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72766. * Default : false
  72767. */
  72768. translateFromPivot: boolean;
  72769. /**
  72770. * Index of this particle in the global "positions" array (Internal use)
  72771. * @hidden
  72772. */
  72773. _pos: number;
  72774. /**
  72775. * @hidden Index of this particle in the global "indices" array (Internal use)
  72776. */
  72777. _ind: number;
  72778. /**
  72779. * Group this particle belongs to
  72780. */
  72781. _group: PointsGroup;
  72782. /**
  72783. * Group id of this particle
  72784. */
  72785. groupId: number;
  72786. /**
  72787. * Index of the particle in its group id (Internal use)
  72788. */
  72789. idxInGroup: number;
  72790. /**
  72791. * @hidden Particle BoundingInfo object (Internal use)
  72792. */
  72793. _boundingInfo: BoundingInfo;
  72794. /**
  72795. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72796. */
  72797. _pcs: PointsCloudSystem;
  72798. /**
  72799. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72800. */
  72801. _stillInvisible: boolean;
  72802. /**
  72803. * @hidden Last computed particle rotation matrix
  72804. */
  72805. _rotationMatrix: number[];
  72806. /**
  72807. * Parent particle Id, if any.
  72808. * Default null.
  72809. */
  72810. parentId: Nullable<number>;
  72811. /**
  72812. * @hidden Internal global position in the PCS.
  72813. */
  72814. _globalPosition: Vector3;
  72815. /**
  72816. * Creates a Point Cloud object.
  72817. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72818. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72819. * @param group (PointsGroup) is the group the particle belongs to
  72820. * @param groupId (integer) is the group identifier in the PCS.
  72821. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72822. * @param pcs defines the PCS it is associated to
  72823. */
  72824. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72825. /**
  72826. * get point size
  72827. */
  72828. get size(): Vector3;
  72829. /**
  72830. * Set point size
  72831. */
  72832. set size(scale: Vector3);
  72833. /**
  72834. * Legacy support, changed quaternion to rotationQuaternion
  72835. */
  72836. get quaternion(): Nullable<Quaternion>;
  72837. /**
  72838. * Legacy support, changed quaternion to rotationQuaternion
  72839. */
  72840. set quaternion(q: Nullable<Quaternion>);
  72841. /**
  72842. * Returns a boolean. True if the particle intersects a mesh, else false
  72843. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72844. * @param target is the object (point or mesh) what the intersection is computed against
  72845. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72846. * @returns true if it intersects
  72847. */
  72848. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72849. /**
  72850. * get the rotation matrix of the particle
  72851. * @hidden
  72852. */
  72853. getRotationMatrix(m: Matrix): void;
  72854. }
  72855. /**
  72856. * Represents a group of points in a points cloud system
  72857. * * PCS internal tool, don't use it manually.
  72858. */
  72859. export class PointsGroup {
  72860. /**
  72861. * The group id
  72862. * @hidden
  72863. */
  72864. groupID: number;
  72865. /**
  72866. * image data for group (internal use)
  72867. * @hidden
  72868. */
  72869. _groupImageData: Nullable<ArrayBufferView>;
  72870. /**
  72871. * Image Width (internal use)
  72872. * @hidden
  72873. */
  72874. _groupImgWidth: number;
  72875. /**
  72876. * Image Height (internal use)
  72877. * @hidden
  72878. */
  72879. _groupImgHeight: number;
  72880. /**
  72881. * Custom position function (internal use)
  72882. * @hidden
  72883. */
  72884. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72885. /**
  72886. * density per facet for surface points
  72887. * @hidden
  72888. */
  72889. _groupDensity: number[];
  72890. /**
  72891. * Only when points are colored by texture carries pointer to texture list array
  72892. * @hidden
  72893. */
  72894. _textureNb: number;
  72895. /**
  72896. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72897. * PCS internal tool, don't use it manually.
  72898. * @hidden
  72899. */
  72900. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72901. }
  72902. }
  72903. declare module BABYLON {
  72904. interface Scene {
  72905. /** @hidden (Backing field) */
  72906. _physicsEngine: Nullable<IPhysicsEngine>;
  72907. /** @hidden */
  72908. _physicsTimeAccumulator: number;
  72909. /**
  72910. * Gets the current physics engine
  72911. * @returns a IPhysicsEngine or null if none attached
  72912. */
  72913. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72914. /**
  72915. * Enables physics to the current scene
  72916. * @param gravity defines the scene's gravity for the physics engine
  72917. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72918. * @return a boolean indicating if the physics engine was initialized
  72919. */
  72920. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72921. /**
  72922. * Disables and disposes the physics engine associated with the scene
  72923. */
  72924. disablePhysicsEngine(): void;
  72925. /**
  72926. * Gets a boolean indicating if there is an active physics engine
  72927. * @returns a boolean indicating if there is an active physics engine
  72928. */
  72929. isPhysicsEnabled(): boolean;
  72930. /**
  72931. * Deletes a physics compound impostor
  72932. * @param compound defines the compound to delete
  72933. */
  72934. deleteCompoundImpostor(compound: any): void;
  72935. /**
  72936. * An event triggered when physic simulation is about to be run
  72937. */
  72938. onBeforePhysicsObservable: Observable<Scene>;
  72939. /**
  72940. * An event triggered when physic simulation has been done
  72941. */
  72942. onAfterPhysicsObservable: Observable<Scene>;
  72943. }
  72944. interface AbstractMesh {
  72945. /** @hidden */
  72946. _physicsImpostor: Nullable<PhysicsImpostor>;
  72947. /**
  72948. * Gets or sets impostor used for physic simulation
  72949. * @see https://doc.babylonjs.com/features/physics_engine
  72950. */
  72951. physicsImpostor: Nullable<PhysicsImpostor>;
  72952. /**
  72953. * Gets the current physics impostor
  72954. * @see https://doc.babylonjs.com/features/physics_engine
  72955. * @returns a physics impostor or null
  72956. */
  72957. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72958. /** Apply a physic impulse to the mesh
  72959. * @param force defines the force to apply
  72960. * @param contactPoint defines where to apply the force
  72961. * @returns the current mesh
  72962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72963. */
  72964. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72965. /**
  72966. * Creates a physic joint between two meshes
  72967. * @param otherMesh defines the other mesh to use
  72968. * @param pivot1 defines the pivot to use on this mesh
  72969. * @param pivot2 defines the pivot to use on the other mesh
  72970. * @param options defines additional options (can be plugin dependent)
  72971. * @returns the current mesh
  72972. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72973. */
  72974. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72975. /** @hidden */
  72976. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72977. }
  72978. /**
  72979. * Defines the physics engine scene component responsible to manage a physics engine
  72980. */
  72981. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72982. /**
  72983. * The component name helpful to identify the component in the list of scene components.
  72984. */
  72985. readonly name: string;
  72986. /**
  72987. * The scene the component belongs to.
  72988. */
  72989. scene: Scene;
  72990. /**
  72991. * Creates a new instance of the component for the given scene
  72992. * @param scene Defines the scene to register the component in
  72993. */
  72994. constructor(scene: Scene);
  72995. /**
  72996. * Registers the component in a given scene
  72997. */
  72998. register(): void;
  72999. /**
  73000. * Rebuilds the elements related to this component in case of
  73001. * context lost for instance.
  73002. */
  73003. rebuild(): void;
  73004. /**
  73005. * Disposes the component and the associated ressources
  73006. */
  73007. dispose(): void;
  73008. }
  73009. }
  73010. declare module BABYLON {
  73011. /**
  73012. * A helper for physics simulations
  73013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73014. */
  73015. export class PhysicsHelper {
  73016. private _scene;
  73017. private _physicsEngine;
  73018. /**
  73019. * Initializes the Physics helper
  73020. * @param scene Babylon.js scene
  73021. */
  73022. constructor(scene: Scene);
  73023. /**
  73024. * Applies a radial explosion impulse
  73025. * @param origin the origin of the explosion
  73026. * @param radiusOrEventOptions the radius or the options of radial explosion
  73027. * @param strength the explosion strength
  73028. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73029. * @returns A physics radial explosion event, or null
  73030. */
  73031. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73032. /**
  73033. * Applies a radial explosion force
  73034. * @param origin the origin of the explosion
  73035. * @param radiusOrEventOptions the radius or the options of radial explosion
  73036. * @param strength the explosion strength
  73037. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73038. * @returns A physics radial explosion event, or null
  73039. */
  73040. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73041. /**
  73042. * Creates a gravitational field
  73043. * @param origin the origin of the explosion
  73044. * @param radiusOrEventOptions the radius or the options of radial explosion
  73045. * @param strength the explosion strength
  73046. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73047. * @returns A physics gravitational field event, or null
  73048. */
  73049. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73050. /**
  73051. * Creates a physics updraft event
  73052. * @param origin the origin of the updraft
  73053. * @param radiusOrEventOptions the radius or the options of the updraft
  73054. * @param strength the strength of the updraft
  73055. * @param height the height of the updraft
  73056. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73057. * @returns A physics updraft event, or null
  73058. */
  73059. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73060. /**
  73061. * Creates a physics vortex event
  73062. * @param origin the of the vortex
  73063. * @param radiusOrEventOptions the radius or the options of the vortex
  73064. * @param strength the strength of the vortex
  73065. * @param height the height of the vortex
  73066. * @returns a Physics vortex event, or null
  73067. * A physics vortex event or null
  73068. */
  73069. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73070. }
  73071. /**
  73072. * Represents a physics radial explosion event
  73073. */
  73074. class PhysicsRadialExplosionEvent {
  73075. private _scene;
  73076. private _options;
  73077. private _sphere;
  73078. private _dataFetched;
  73079. /**
  73080. * Initializes a radial explosioin event
  73081. * @param _scene BabylonJS scene
  73082. * @param _options The options for the vortex event
  73083. */
  73084. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73085. /**
  73086. * Returns the data related to the radial explosion event (sphere).
  73087. * @returns The radial explosion event data
  73088. */
  73089. getData(): PhysicsRadialExplosionEventData;
  73090. /**
  73091. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73092. * @param impostor A physics imposter
  73093. * @param origin the origin of the explosion
  73094. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73095. */
  73096. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73097. /**
  73098. * Triggers affecterd impostors callbacks
  73099. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73100. */
  73101. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73102. /**
  73103. * Disposes the sphere.
  73104. * @param force Specifies if the sphere should be disposed by force
  73105. */
  73106. dispose(force?: boolean): void;
  73107. /*** Helpers ***/
  73108. private _prepareSphere;
  73109. private _intersectsWithSphere;
  73110. }
  73111. /**
  73112. * Represents a gravitational field event
  73113. */
  73114. class PhysicsGravitationalFieldEvent {
  73115. private _physicsHelper;
  73116. private _scene;
  73117. private _origin;
  73118. private _options;
  73119. private _tickCallback;
  73120. private _sphere;
  73121. private _dataFetched;
  73122. /**
  73123. * Initializes the physics gravitational field event
  73124. * @param _physicsHelper A physics helper
  73125. * @param _scene BabylonJS scene
  73126. * @param _origin The origin position of the gravitational field event
  73127. * @param _options The options for the vortex event
  73128. */
  73129. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73130. /**
  73131. * Returns the data related to the gravitational field event (sphere).
  73132. * @returns A gravitational field event
  73133. */
  73134. getData(): PhysicsGravitationalFieldEventData;
  73135. /**
  73136. * Enables the gravitational field.
  73137. */
  73138. enable(): void;
  73139. /**
  73140. * Disables the gravitational field.
  73141. */
  73142. disable(): void;
  73143. /**
  73144. * Disposes the sphere.
  73145. * @param force The force to dispose from the gravitational field event
  73146. */
  73147. dispose(force?: boolean): void;
  73148. private _tick;
  73149. }
  73150. /**
  73151. * Represents a physics updraft event
  73152. */
  73153. class PhysicsUpdraftEvent {
  73154. private _scene;
  73155. private _origin;
  73156. private _options;
  73157. private _physicsEngine;
  73158. private _originTop;
  73159. private _originDirection;
  73160. private _tickCallback;
  73161. private _cylinder;
  73162. private _cylinderPosition;
  73163. private _dataFetched;
  73164. /**
  73165. * Initializes the physics updraft event
  73166. * @param _scene BabylonJS scene
  73167. * @param _origin The origin position of the updraft
  73168. * @param _options The options for the updraft event
  73169. */
  73170. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73171. /**
  73172. * Returns the data related to the updraft event (cylinder).
  73173. * @returns A physics updraft event
  73174. */
  73175. getData(): PhysicsUpdraftEventData;
  73176. /**
  73177. * Enables the updraft.
  73178. */
  73179. enable(): void;
  73180. /**
  73181. * Disables the updraft.
  73182. */
  73183. disable(): void;
  73184. /**
  73185. * Disposes the cylinder.
  73186. * @param force Specifies if the updraft should be disposed by force
  73187. */
  73188. dispose(force?: boolean): void;
  73189. private getImpostorHitData;
  73190. private _tick;
  73191. /*** Helpers ***/
  73192. private _prepareCylinder;
  73193. private _intersectsWithCylinder;
  73194. }
  73195. /**
  73196. * Represents a physics vortex event
  73197. */
  73198. class PhysicsVortexEvent {
  73199. private _scene;
  73200. private _origin;
  73201. private _options;
  73202. private _physicsEngine;
  73203. private _originTop;
  73204. private _tickCallback;
  73205. private _cylinder;
  73206. private _cylinderPosition;
  73207. private _dataFetched;
  73208. /**
  73209. * Initializes the physics vortex event
  73210. * @param _scene The BabylonJS scene
  73211. * @param _origin The origin position of the vortex
  73212. * @param _options The options for the vortex event
  73213. */
  73214. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73215. /**
  73216. * Returns the data related to the vortex event (cylinder).
  73217. * @returns The physics vortex event data
  73218. */
  73219. getData(): PhysicsVortexEventData;
  73220. /**
  73221. * Enables the vortex.
  73222. */
  73223. enable(): void;
  73224. /**
  73225. * Disables the cortex.
  73226. */
  73227. disable(): void;
  73228. /**
  73229. * Disposes the sphere.
  73230. * @param force
  73231. */
  73232. dispose(force?: boolean): void;
  73233. private getImpostorHitData;
  73234. private _tick;
  73235. /*** Helpers ***/
  73236. private _prepareCylinder;
  73237. private _intersectsWithCylinder;
  73238. }
  73239. /**
  73240. * Options fot the radial explosion event
  73241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73242. */
  73243. export class PhysicsRadialExplosionEventOptions {
  73244. /**
  73245. * The radius of the sphere for the radial explosion.
  73246. */
  73247. radius: number;
  73248. /**
  73249. * The strenth of the explosion.
  73250. */
  73251. strength: number;
  73252. /**
  73253. * The strenght of the force in correspondence to the distance of the affected object
  73254. */
  73255. falloff: PhysicsRadialImpulseFalloff;
  73256. /**
  73257. * Sphere options for the radial explosion.
  73258. */
  73259. sphere: {
  73260. segments: number;
  73261. diameter: number;
  73262. };
  73263. /**
  73264. * Sphere options for the radial explosion.
  73265. */
  73266. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73267. }
  73268. /**
  73269. * Options fot the updraft event
  73270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73271. */
  73272. export class PhysicsUpdraftEventOptions {
  73273. /**
  73274. * The radius of the cylinder for the vortex
  73275. */
  73276. radius: number;
  73277. /**
  73278. * The strenth of the updraft.
  73279. */
  73280. strength: number;
  73281. /**
  73282. * The height of the cylinder for the updraft.
  73283. */
  73284. height: number;
  73285. /**
  73286. * The mode for the the updraft.
  73287. */
  73288. updraftMode: PhysicsUpdraftMode;
  73289. }
  73290. /**
  73291. * Options fot the vortex event
  73292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73293. */
  73294. export class PhysicsVortexEventOptions {
  73295. /**
  73296. * The radius of the cylinder for the vortex
  73297. */
  73298. radius: number;
  73299. /**
  73300. * The strenth of the vortex.
  73301. */
  73302. strength: number;
  73303. /**
  73304. * The height of the cylinder for the vortex.
  73305. */
  73306. height: number;
  73307. /**
  73308. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73309. */
  73310. centripetalForceThreshold: number;
  73311. /**
  73312. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73313. */
  73314. centripetalForceMultiplier: number;
  73315. /**
  73316. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73317. */
  73318. centrifugalForceMultiplier: number;
  73319. /**
  73320. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73321. */
  73322. updraftForceMultiplier: number;
  73323. }
  73324. /**
  73325. * The strenght of the force in correspondence to the distance of the affected object
  73326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73327. */
  73328. export enum PhysicsRadialImpulseFalloff {
  73329. /** Defines that impulse is constant in strength across it's whole radius */
  73330. Constant = 0,
  73331. /** Defines that impulse gets weaker if it's further from the origin */
  73332. Linear = 1
  73333. }
  73334. /**
  73335. * The strength of the force in correspondence to the distance of the affected object
  73336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73337. */
  73338. export enum PhysicsUpdraftMode {
  73339. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73340. Center = 0,
  73341. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73342. Perpendicular = 1
  73343. }
  73344. /**
  73345. * Interface for a physics hit data
  73346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73347. */
  73348. export interface PhysicsHitData {
  73349. /**
  73350. * The force applied at the contact point
  73351. */
  73352. force: Vector3;
  73353. /**
  73354. * The contact point
  73355. */
  73356. contactPoint: Vector3;
  73357. /**
  73358. * The distance from the origin to the contact point
  73359. */
  73360. distanceFromOrigin: number;
  73361. }
  73362. /**
  73363. * Interface for radial explosion event data
  73364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73365. */
  73366. export interface PhysicsRadialExplosionEventData {
  73367. /**
  73368. * A sphere used for the radial explosion event
  73369. */
  73370. sphere: Mesh;
  73371. }
  73372. /**
  73373. * Interface for gravitational field event data
  73374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73375. */
  73376. export interface PhysicsGravitationalFieldEventData {
  73377. /**
  73378. * A sphere mesh used for the gravitational field event
  73379. */
  73380. sphere: Mesh;
  73381. }
  73382. /**
  73383. * Interface for updraft event data
  73384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73385. */
  73386. export interface PhysicsUpdraftEventData {
  73387. /**
  73388. * A cylinder used for the updraft event
  73389. */
  73390. cylinder: Mesh;
  73391. }
  73392. /**
  73393. * Interface for vortex event data
  73394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73395. */
  73396. export interface PhysicsVortexEventData {
  73397. /**
  73398. * A cylinder used for the vortex event
  73399. */
  73400. cylinder: Mesh;
  73401. }
  73402. /**
  73403. * Interface for an affected physics impostor
  73404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73405. */
  73406. export interface PhysicsAffectedImpostorWithData {
  73407. /**
  73408. * The impostor affected by the effect
  73409. */
  73410. impostor: PhysicsImpostor;
  73411. /**
  73412. * The data about the hit/horce from the explosion
  73413. */
  73414. hitData: PhysicsHitData;
  73415. }
  73416. }
  73417. declare module BABYLON {
  73418. /** @hidden */
  73419. export var blackAndWhitePixelShader: {
  73420. name: string;
  73421. shader: string;
  73422. };
  73423. }
  73424. declare module BABYLON {
  73425. /**
  73426. * Post process used to render in black and white
  73427. */
  73428. export class BlackAndWhitePostProcess extends PostProcess {
  73429. /**
  73430. * Linear about to convert he result to black and white (default: 1)
  73431. */
  73432. degree: number;
  73433. /**
  73434. * Gets a string identifying the name of the class
  73435. * @returns "BlackAndWhitePostProcess" string
  73436. */
  73437. getClassName(): string;
  73438. /**
  73439. * Creates a black and white post process
  73440. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73441. * @param name The name of the effect.
  73442. * @param options The required width/height ratio to downsize to before computing the render pass.
  73443. * @param camera The camera to apply the render pass to.
  73444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73445. * @param engine The engine which the post process will be applied. (default: current engine)
  73446. * @param reusable If the post process can be reused on the same frame. (default: false)
  73447. */
  73448. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73449. /** @hidden */
  73450. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73451. }
  73452. }
  73453. declare module BABYLON {
  73454. /**
  73455. * This represents a set of one or more post processes in Babylon.
  73456. * A post process can be used to apply a shader to a texture after it is rendered.
  73457. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73458. */
  73459. export class PostProcessRenderEffect {
  73460. private _postProcesses;
  73461. private _getPostProcesses;
  73462. private _singleInstance;
  73463. private _cameras;
  73464. private _indicesForCamera;
  73465. /**
  73466. * Name of the effect
  73467. * @hidden
  73468. */
  73469. _name: string;
  73470. /**
  73471. * Instantiates a post process render effect.
  73472. * A post process can be used to apply a shader to a texture after it is rendered.
  73473. * @param engine The engine the effect is tied to
  73474. * @param name The name of the effect
  73475. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73476. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73477. */
  73478. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73479. /**
  73480. * Checks if all the post processes in the effect are supported.
  73481. */
  73482. get isSupported(): boolean;
  73483. /**
  73484. * Updates the current state of the effect
  73485. * @hidden
  73486. */
  73487. _update(): void;
  73488. /**
  73489. * Attaches the effect on cameras
  73490. * @param cameras The camera to attach to.
  73491. * @hidden
  73492. */
  73493. _attachCameras(cameras: Camera): void;
  73494. /**
  73495. * Attaches the effect on cameras
  73496. * @param cameras The camera to attach to.
  73497. * @hidden
  73498. */
  73499. _attachCameras(cameras: Camera[]): void;
  73500. /**
  73501. * Detaches the effect on cameras
  73502. * @param cameras The camera to detatch from.
  73503. * @hidden
  73504. */
  73505. _detachCameras(cameras: Camera): void;
  73506. /**
  73507. * Detatches the effect on cameras
  73508. * @param cameras The camera to detatch from.
  73509. * @hidden
  73510. */
  73511. _detachCameras(cameras: Camera[]): void;
  73512. /**
  73513. * Enables the effect on given cameras
  73514. * @param cameras The camera to enable.
  73515. * @hidden
  73516. */
  73517. _enable(cameras: Camera): void;
  73518. /**
  73519. * Enables the effect on given cameras
  73520. * @param cameras The camera to enable.
  73521. * @hidden
  73522. */
  73523. _enable(cameras: Nullable<Camera[]>): void;
  73524. /**
  73525. * Disables the effect on the given cameras
  73526. * @param cameras The camera to disable.
  73527. * @hidden
  73528. */
  73529. _disable(cameras: Camera): void;
  73530. /**
  73531. * Disables the effect on the given cameras
  73532. * @param cameras The camera to disable.
  73533. * @hidden
  73534. */
  73535. _disable(cameras: Nullable<Camera[]>): void;
  73536. /**
  73537. * Gets a list of the post processes contained in the effect.
  73538. * @param camera The camera to get the post processes on.
  73539. * @returns The list of the post processes in the effect.
  73540. */
  73541. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73542. }
  73543. }
  73544. declare module BABYLON {
  73545. /** @hidden */
  73546. export var extractHighlightsPixelShader: {
  73547. name: string;
  73548. shader: string;
  73549. };
  73550. }
  73551. declare module BABYLON {
  73552. /**
  73553. * 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.
  73554. */
  73555. export class ExtractHighlightsPostProcess extends PostProcess {
  73556. /**
  73557. * The luminance threshold, pixels below this value will be set to black.
  73558. */
  73559. threshold: number;
  73560. /** @hidden */
  73561. _exposure: number;
  73562. /**
  73563. * Post process which has the input texture to be used when performing highlight extraction
  73564. * @hidden
  73565. */
  73566. _inputPostProcess: Nullable<PostProcess>;
  73567. /**
  73568. * Gets a string identifying the name of the class
  73569. * @returns "ExtractHighlightsPostProcess" string
  73570. */
  73571. getClassName(): string;
  73572. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73573. }
  73574. }
  73575. declare module BABYLON {
  73576. /** @hidden */
  73577. export var bloomMergePixelShader: {
  73578. name: string;
  73579. shader: string;
  73580. };
  73581. }
  73582. declare module BABYLON {
  73583. /**
  73584. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73585. */
  73586. export class BloomMergePostProcess extends PostProcess {
  73587. /** Weight of the bloom to be added to the original input. */
  73588. weight: number;
  73589. /**
  73590. * Gets a string identifying the name of the class
  73591. * @returns "BloomMergePostProcess" string
  73592. */
  73593. getClassName(): string;
  73594. /**
  73595. * Creates a new instance of @see BloomMergePostProcess
  73596. * @param name The name of the effect.
  73597. * @param originalFromInput Post process which's input will be used for the merge.
  73598. * @param blurred Blurred highlights post process which's output will be used.
  73599. * @param weight Weight of the bloom to be added to the original input.
  73600. * @param options The required width/height ratio to downsize to before computing the render pass.
  73601. * @param camera The camera to apply the render pass to.
  73602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73603. * @param engine The engine which the post process will be applied. (default: current engine)
  73604. * @param reusable If the post process can be reused on the same frame. (default: false)
  73605. * @param textureType Type of textures used when performing the post process. (default: 0)
  73606. * @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)
  73607. */
  73608. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73609. /** Weight of the bloom to be added to the original input. */
  73610. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73611. }
  73612. }
  73613. declare module BABYLON {
  73614. /**
  73615. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73616. */
  73617. export class BloomEffect extends PostProcessRenderEffect {
  73618. private bloomScale;
  73619. /**
  73620. * @hidden Internal
  73621. */
  73622. _effects: Array<PostProcess>;
  73623. /**
  73624. * @hidden Internal
  73625. */
  73626. _downscale: ExtractHighlightsPostProcess;
  73627. private _blurX;
  73628. private _blurY;
  73629. private _merge;
  73630. /**
  73631. * The luminance threshold to find bright areas of the image to bloom.
  73632. */
  73633. get threshold(): number;
  73634. set threshold(value: number);
  73635. /**
  73636. * The strength of the bloom.
  73637. */
  73638. get weight(): number;
  73639. set weight(value: number);
  73640. /**
  73641. * Specifies the size of the bloom blur kernel, relative to the final output size
  73642. */
  73643. get kernel(): number;
  73644. set kernel(value: number);
  73645. /**
  73646. * Creates a new instance of @see BloomEffect
  73647. * @param scene The scene the effect belongs to.
  73648. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73649. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73650. * @param bloomWeight The the strength of bloom.
  73651. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73652. * @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)
  73653. */
  73654. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73655. /**
  73656. * Disposes each of the internal effects for a given camera.
  73657. * @param camera The camera to dispose the effect on.
  73658. */
  73659. disposeEffects(camera: Camera): void;
  73660. /**
  73661. * @hidden Internal
  73662. */
  73663. _updateEffects(): void;
  73664. /**
  73665. * Internal
  73666. * @returns if all the contained post processes are ready.
  73667. * @hidden
  73668. */
  73669. _isReady(): boolean;
  73670. }
  73671. }
  73672. declare module BABYLON {
  73673. /** @hidden */
  73674. export var chromaticAberrationPixelShader: {
  73675. name: string;
  73676. shader: string;
  73677. };
  73678. }
  73679. declare module BABYLON {
  73680. /**
  73681. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73682. */
  73683. export class ChromaticAberrationPostProcess extends PostProcess {
  73684. /**
  73685. * The amount of seperation of rgb channels (default: 30)
  73686. */
  73687. aberrationAmount: number;
  73688. /**
  73689. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73690. */
  73691. radialIntensity: number;
  73692. /**
  73693. * 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))
  73694. */
  73695. direction: Vector2;
  73696. /**
  73697. * 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))
  73698. */
  73699. centerPosition: Vector2;
  73700. /** The width of the screen to apply the effect on */
  73701. screenWidth: number;
  73702. /** The height of the screen to apply the effect on */
  73703. screenHeight: number;
  73704. /**
  73705. * Gets a string identifying the name of the class
  73706. * @returns "ChromaticAberrationPostProcess" string
  73707. */
  73708. getClassName(): string;
  73709. /**
  73710. * Creates a new instance ChromaticAberrationPostProcess
  73711. * @param name The name of the effect.
  73712. * @param screenWidth The width of the screen to apply the effect on.
  73713. * @param screenHeight The height of the screen to apply the effect on.
  73714. * @param options The required width/height ratio to downsize to before computing the render pass.
  73715. * @param camera The camera to apply the render pass to.
  73716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73717. * @param engine The engine which the post process will be applied. (default: current engine)
  73718. * @param reusable If the post process can be reused on the same frame. (default: false)
  73719. * @param textureType Type of textures used when performing the post process. (default: 0)
  73720. * @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)
  73721. */
  73722. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73723. /** @hidden */
  73724. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73725. }
  73726. }
  73727. declare module BABYLON {
  73728. /** @hidden */
  73729. export var circleOfConfusionPixelShader: {
  73730. name: string;
  73731. shader: string;
  73732. };
  73733. }
  73734. declare module BABYLON {
  73735. /**
  73736. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73737. */
  73738. export class CircleOfConfusionPostProcess extends PostProcess {
  73739. /**
  73740. * 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.
  73741. */
  73742. lensSize: number;
  73743. /**
  73744. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73745. */
  73746. fStop: number;
  73747. /**
  73748. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73749. */
  73750. focusDistance: number;
  73751. /**
  73752. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73753. */
  73754. focalLength: number;
  73755. /**
  73756. * Gets a string identifying the name of the class
  73757. * @returns "CircleOfConfusionPostProcess" string
  73758. */
  73759. getClassName(): string;
  73760. private _depthTexture;
  73761. /**
  73762. * Creates a new instance CircleOfConfusionPostProcess
  73763. * @param name The name of the effect.
  73764. * @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.
  73765. * @param options The required width/height ratio to downsize to before computing the render pass.
  73766. * @param camera The camera to apply the render pass to.
  73767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73768. * @param engine The engine which the post process will be applied. (default: current engine)
  73769. * @param reusable If the post process can be reused on the same frame. (default: false)
  73770. * @param textureType Type of textures used when performing the post process. (default: 0)
  73771. * @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)
  73772. */
  73773. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73774. /**
  73775. * 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.
  73776. */
  73777. set depthTexture(value: RenderTargetTexture);
  73778. }
  73779. }
  73780. declare module BABYLON {
  73781. /** @hidden */
  73782. export var colorCorrectionPixelShader: {
  73783. name: string;
  73784. shader: string;
  73785. };
  73786. }
  73787. declare module BABYLON {
  73788. /**
  73789. *
  73790. * This post-process allows the modification of rendered colors by using
  73791. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73792. *
  73793. * The object needs to be provided an url to a texture containing the color
  73794. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73795. * Use an image editing software to tweak the LUT to match your needs.
  73796. *
  73797. * For an example of a color LUT, see here:
  73798. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73799. * For explanations on color grading, see here:
  73800. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73801. *
  73802. */
  73803. export class ColorCorrectionPostProcess extends PostProcess {
  73804. private _colorTableTexture;
  73805. /**
  73806. * Gets the color table url used to create the LUT texture
  73807. */
  73808. colorTableUrl: string;
  73809. /**
  73810. * Gets a string identifying the name of the class
  73811. * @returns "ColorCorrectionPostProcess" string
  73812. */
  73813. getClassName(): string;
  73814. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73815. /** @hidden */
  73816. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73817. }
  73818. }
  73819. declare module BABYLON {
  73820. /** @hidden */
  73821. export var convolutionPixelShader: {
  73822. name: string;
  73823. shader: string;
  73824. };
  73825. }
  73826. declare module BABYLON {
  73827. /**
  73828. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73829. * input texture to perform effects such as edge detection or sharpening
  73830. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73831. */
  73832. export class ConvolutionPostProcess extends PostProcess {
  73833. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73834. kernel: number[];
  73835. /**
  73836. * Gets a string identifying the name of the class
  73837. * @returns "ConvolutionPostProcess" string
  73838. */
  73839. getClassName(): string;
  73840. /**
  73841. * Creates a new instance ConvolutionPostProcess
  73842. * @param name The name of the effect.
  73843. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73844. * @param options The required width/height ratio to downsize to before computing the render pass.
  73845. * @param camera The camera to apply the render pass to.
  73846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73847. * @param engine The engine which the post process will be applied. (default: current engine)
  73848. * @param reusable If the post process can be reused on the same frame. (default: false)
  73849. * @param textureType Type of textures used when performing the post process. (default: 0)
  73850. */
  73851. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73852. /** @hidden */
  73853. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73854. /**
  73855. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73856. */
  73857. static EdgeDetect0Kernel: number[];
  73858. /**
  73859. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73860. */
  73861. static EdgeDetect1Kernel: number[];
  73862. /**
  73863. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73864. */
  73865. static EdgeDetect2Kernel: number[];
  73866. /**
  73867. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73868. */
  73869. static SharpenKernel: number[];
  73870. /**
  73871. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73872. */
  73873. static EmbossKernel: number[];
  73874. /**
  73875. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73876. */
  73877. static GaussianKernel: number[];
  73878. }
  73879. }
  73880. declare module BABYLON {
  73881. /**
  73882. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73883. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73884. * based on samples that have a large difference in distance than the center pixel.
  73885. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73886. */
  73887. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73888. /**
  73889. * The direction the blur should be applied
  73890. */
  73891. direction: Vector2;
  73892. /**
  73893. * Gets a string identifying the name of the class
  73894. * @returns "DepthOfFieldBlurPostProcess" string
  73895. */
  73896. getClassName(): string;
  73897. /**
  73898. * Creates a new instance CircleOfConfusionPostProcess
  73899. * @param name The name of the effect.
  73900. * @param scene The scene the effect belongs to.
  73901. * @param direction The direction the blur should be applied.
  73902. * @param kernel The size of the kernel used to blur.
  73903. * @param options The required width/height ratio to downsize to before computing the render pass.
  73904. * @param camera The camera to apply the render pass to.
  73905. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73906. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73908. * @param engine The engine which the post process will be applied. (default: current engine)
  73909. * @param reusable If the post process can be reused on the same frame. (default: false)
  73910. * @param textureType Type of textures used when performing the post process. (default: 0)
  73911. * @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)
  73912. */
  73913. 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);
  73914. }
  73915. }
  73916. declare module BABYLON {
  73917. /** @hidden */
  73918. export var depthOfFieldMergePixelShader: {
  73919. name: string;
  73920. shader: string;
  73921. };
  73922. }
  73923. declare module BABYLON {
  73924. /**
  73925. * Options to be set when merging outputs from the default pipeline.
  73926. */
  73927. export class DepthOfFieldMergePostProcessOptions {
  73928. /**
  73929. * The original image to merge on top of
  73930. */
  73931. originalFromInput: PostProcess;
  73932. /**
  73933. * Parameters to perform the merge of the depth of field effect
  73934. */
  73935. depthOfField?: {
  73936. circleOfConfusion: PostProcess;
  73937. blurSteps: Array<PostProcess>;
  73938. };
  73939. /**
  73940. * Parameters to perform the merge of bloom effect
  73941. */
  73942. bloom?: {
  73943. blurred: PostProcess;
  73944. weight: number;
  73945. };
  73946. }
  73947. /**
  73948. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73949. */
  73950. export class DepthOfFieldMergePostProcess extends PostProcess {
  73951. private blurSteps;
  73952. /**
  73953. * Gets a string identifying the name of the class
  73954. * @returns "DepthOfFieldMergePostProcess" string
  73955. */
  73956. getClassName(): string;
  73957. /**
  73958. * Creates a new instance of DepthOfFieldMergePostProcess
  73959. * @param name The name of the effect.
  73960. * @param originalFromInput Post process which's input will be used for the merge.
  73961. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73962. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73963. * @param options The required width/height ratio to downsize to before computing the render pass.
  73964. * @param camera The camera to apply the render pass to.
  73965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73966. * @param engine The engine which the post process will be applied. (default: current engine)
  73967. * @param reusable If the post process can be reused on the same frame. (default: false)
  73968. * @param textureType Type of textures used when performing the post process. (default: 0)
  73969. * @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)
  73970. */
  73971. 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);
  73972. /**
  73973. * Updates the effect with the current post process compile time values and recompiles the shader.
  73974. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73975. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73976. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73977. * @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
  73978. * @param onCompiled Called when the shader has been compiled.
  73979. * @param onError Called if there is an error when compiling a shader.
  73980. */
  73981. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73982. }
  73983. }
  73984. declare module BABYLON {
  73985. /**
  73986. * Specifies the level of max blur that should be applied when using the depth of field effect
  73987. */
  73988. export enum DepthOfFieldEffectBlurLevel {
  73989. /**
  73990. * Subtle blur
  73991. */
  73992. Low = 0,
  73993. /**
  73994. * Medium blur
  73995. */
  73996. Medium = 1,
  73997. /**
  73998. * Large blur
  73999. */
  74000. High = 2
  74001. }
  74002. /**
  74003. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74004. */
  74005. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74006. private _circleOfConfusion;
  74007. /**
  74008. * @hidden Internal, blurs from high to low
  74009. */
  74010. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74011. private _depthOfFieldBlurY;
  74012. private _dofMerge;
  74013. /**
  74014. * @hidden Internal post processes in depth of field effect
  74015. */
  74016. _effects: Array<PostProcess>;
  74017. /**
  74018. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74019. */
  74020. set focalLength(value: number);
  74021. get focalLength(): number;
  74022. /**
  74023. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74024. */
  74025. set fStop(value: number);
  74026. get fStop(): number;
  74027. /**
  74028. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74029. */
  74030. set focusDistance(value: number);
  74031. get focusDistance(): number;
  74032. /**
  74033. * 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.
  74034. */
  74035. set lensSize(value: number);
  74036. get lensSize(): number;
  74037. /**
  74038. * Creates a new instance DepthOfFieldEffect
  74039. * @param scene The scene the effect belongs to.
  74040. * @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.
  74041. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74042. * @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)
  74043. */
  74044. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74045. /**
  74046. * Get the current class name of the current effet
  74047. * @returns "DepthOfFieldEffect"
  74048. */
  74049. getClassName(): string;
  74050. /**
  74051. * 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.
  74052. */
  74053. set depthTexture(value: RenderTargetTexture);
  74054. /**
  74055. * Disposes each of the internal effects for a given camera.
  74056. * @param camera The camera to dispose the effect on.
  74057. */
  74058. disposeEffects(camera: Camera): void;
  74059. /**
  74060. * @hidden Internal
  74061. */
  74062. _updateEffects(): void;
  74063. /**
  74064. * Internal
  74065. * @returns if all the contained post processes are ready.
  74066. * @hidden
  74067. */
  74068. _isReady(): boolean;
  74069. }
  74070. }
  74071. declare module BABYLON {
  74072. /** @hidden */
  74073. export var displayPassPixelShader: {
  74074. name: string;
  74075. shader: string;
  74076. };
  74077. }
  74078. declare module BABYLON {
  74079. /**
  74080. * DisplayPassPostProcess which produces an output the same as it's input
  74081. */
  74082. export class DisplayPassPostProcess extends PostProcess {
  74083. /**
  74084. * Gets a string identifying the name of the class
  74085. * @returns "DisplayPassPostProcess" string
  74086. */
  74087. getClassName(): string;
  74088. /**
  74089. * Creates the DisplayPassPostProcess
  74090. * @param name The name of the effect.
  74091. * @param options The required width/height ratio to downsize to before computing the render pass.
  74092. * @param camera The camera to apply the render pass to.
  74093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74094. * @param engine The engine which the post process will be applied. (default: current engine)
  74095. * @param reusable If the post process can be reused on the same frame. (default: false)
  74096. */
  74097. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74098. /** @hidden */
  74099. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74100. }
  74101. }
  74102. declare module BABYLON {
  74103. /** @hidden */
  74104. export var filterPixelShader: {
  74105. name: string;
  74106. shader: string;
  74107. };
  74108. }
  74109. declare module BABYLON {
  74110. /**
  74111. * Applies a kernel filter to the image
  74112. */
  74113. export class FilterPostProcess extends PostProcess {
  74114. /** The matrix to be applied to the image */
  74115. kernelMatrix: Matrix;
  74116. /**
  74117. * Gets a string identifying the name of the class
  74118. * @returns "FilterPostProcess" string
  74119. */
  74120. getClassName(): string;
  74121. /**
  74122. *
  74123. * @param name The name of the effect.
  74124. * @param kernelMatrix The matrix to be applied to the image
  74125. * @param options The required width/height ratio to downsize to before computing the render pass.
  74126. * @param camera The camera to apply the render pass to.
  74127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74128. * @param engine The engine which the post process will be applied. (default: current engine)
  74129. * @param reusable If the post process can be reused on the same frame. (default: false)
  74130. */
  74131. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74132. /** @hidden */
  74133. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74134. }
  74135. }
  74136. declare module BABYLON {
  74137. /** @hidden */
  74138. export var fxaaPixelShader: {
  74139. name: string;
  74140. shader: string;
  74141. };
  74142. }
  74143. declare module BABYLON {
  74144. /** @hidden */
  74145. export var fxaaVertexShader: {
  74146. name: string;
  74147. shader: string;
  74148. };
  74149. }
  74150. declare module BABYLON {
  74151. /**
  74152. * Fxaa post process
  74153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74154. */
  74155. export class FxaaPostProcess extends PostProcess {
  74156. /**
  74157. * Gets a string identifying the name of the class
  74158. * @returns "FxaaPostProcess" string
  74159. */
  74160. getClassName(): string;
  74161. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74162. private _getDefines;
  74163. /** @hidden */
  74164. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74165. }
  74166. }
  74167. declare module BABYLON {
  74168. /** @hidden */
  74169. export var grainPixelShader: {
  74170. name: string;
  74171. shader: string;
  74172. };
  74173. }
  74174. declare module BABYLON {
  74175. /**
  74176. * The GrainPostProcess adds noise to the image at mid luminance levels
  74177. */
  74178. export class GrainPostProcess extends PostProcess {
  74179. /**
  74180. * The intensity of the grain added (default: 30)
  74181. */
  74182. intensity: number;
  74183. /**
  74184. * If the grain should be randomized on every frame
  74185. */
  74186. animated: boolean;
  74187. /**
  74188. * Gets a string identifying the name of the class
  74189. * @returns "GrainPostProcess" string
  74190. */
  74191. getClassName(): string;
  74192. /**
  74193. * Creates a new instance of @see GrainPostProcess
  74194. * @param name The name of the effect.
  74195. * @param options The required width/height ratio to downsize to before computing the render pass.
  74196. * @param camera The camera to apply the render pass to.
  74197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74198. * @param engine The engine which the post process will be applied. (default: current engine)
  74199. * @param reusable If the post process can be reused on the same frame. (default: false)
  74200. * @param textureType Type of textures used when performing the post process. (default: 0)
  74201. * @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)
  74202. */
  74203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74204. /** @hidden */
  74205. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74206. }
  74207. }
  74208. declare module BABYLON {
  74209. /** @hidden */
  74210. export var highlightsPixelShader: {
  74211. name: string;
  74212. shader: string;
  74213. };
  74214. }
  74215. declare module BABYLON {
  74216. /**
  74217. * Extracts highlights from the image
  74218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74219. */
  74220. export class HighlightsPostProcess extends PostProcess {
  74221. /**
  74222. * Gets a string identifying the name of the class
  74223. * @returns "HighlightsPostProcess" string
  74224. */
  74225. getClassName(): string;
  74226. /**
  74227. * Extracts highlights from the image
  74228. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74229. * @param name The name of the effect.
  74230. * @param options The required width/height ratio to downsize to before computing the render pass.
  74231. * @param camera The camera to apply the render pass to.
  74232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74233. * @param engine The engine which the post process will be applied. (default: current engine)
  74234. * @param reusable If the post process can be reused on the same frame. (default: false)
  74235. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74236. */
  74237. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74238. }
  74239. }
  74240. declare module BABYLON {
  74241. /**
  74242. * Contains all parameters needed for the prepass to perform
  74243. * motion blur
  74244. */
  74245. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74246. /**
  74247. * Is motion blur enabled
  74248. */
  74249. enabled: boolean;
  74250. /**
  74251. * Name of the configuration
  74252. */
  74253. name: string;
  74254. /**
  74255. * Textures that should be present in the MRT for this effect to work
  74256. */
  74257. readonly texturesRequired: number[];
  74258. }
  74259. }
  74260. declare module BABYLON {
  74261. interface Scene {
  74262. /** @hidden (Backing field) */
  74263. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74264. /**
  74265. * Gets or Sets the current geometry buffer associated to the scene.
  74266. */
  74267. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74268. /**
  74269. * Enables a GeometryBufferRender and associates it with the scene
  74270. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74271. * @returns the GeometryBufferRenderer
  74272. */
  74273. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74274. /**
  74275. * Disables the GeometryBufferRender associated with the scene
  74276. */
  74277. disableGeometryBufferRenderer(): void;
  74278. }
  74279. /**
  74280. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74281. * in several rendering techniques.
  74282. */
  74283. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74284. /**
  74285. * The component name helpful to identify the component in the list of scene components.
  74286. */
  74287. readonly name: string;
  74288. /**
  74289. * The scene the component belongs to.
  74290. */
  74291. scene: Scene;
  74292. /**
  74293. * Creates a new instance of the component for the given scene
  74294. * @param scene Defines the scene to register the component in
  74295. */
  74296. constructor(scene: Scene);
  74297. /**
  74298. * Registers the component in a given scene
  74299. */
  74300. register(): void;
  74301. /**
  74302. * Rebuilds the elements related to this component in case of
  74303. * context lost for instance.
  74304. */
  74305. rebuild(): void;
  74306. /**
  74307. * Disposes the component and the associated ressources
  74308. */
  74309. dispose(): void;
  74310. private _gatherRenderTargets;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /** @hidden */
  74315. export var motionBlurPixelShader: {
  74316. name: string;
  74317. shader: string;
  74318. };
  74319. }
  74320. declare module BABYLON {
  74321. /**
  74322. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74323. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74324. * As an example, all you have to do is to create the post-process:
  74325. * var mb = new BABYLON.MotionBlurPostProcess(
  74326. * 'mb', // The name of the effect.
  74327. * scene, // The scene containing the objects to blur according to their velocity.
  74328. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74329. * camera // The camera to apply the render pass to.
  74330. * );
  74331. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74332. */
  74333. export class MotionBlurPostProcess extends PostProcess {
  74334. /**
  74335. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74336. */
  74337. motionStrength: number;
  74338. /**
  74339. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74340. */
  74341. get motionBlurSamples(): number;
  74342. /**
  74343. * Sets the number of iterations to be used for motion blur quality
  74344. */
  74345. set motionBlurSamples(samples: number);
  74346. private _motionBlurSamples;
  74347. /**
  74348. * Gets wether or not the motion blur post-process is in object based mode.
  74349. */
  74350. get isObjectBased(): boolean;
  74351. /**
  74352. * Sets wether or not the motion blur post-process is in object based mode.
  74353. */
  74354. set isObjectBased(value: boolean);
  74355. private _isObjectBased;
  74356. private _forceGeometryBuffer;
  74357. private _geometryBufferRenderer;
  74358. private _prePassRenderer;
  74359. private _invViewProjection;
  74360. private _previousViewProjection;
  74361. /**
  74362. * Gets a string identifying the name of the class
  74363. * @returns "MotionBlurPostProcess" string
  74364. */
  74365. getClassName(): string;
  74366. /**
  74367. * Creates a new instance MotionBlurPostProcess
  74368. * @param name The name of the effect.
  74369. * @param scene The scene containing the objects to blur according to their velocity.
  74370. * @param options The required width/height ratio to downsize to before computing the render pass.
  74371. * @param camera The camera to apply the render pass to.
  74372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74373. * @param engine The engine which the post process will be applied. (default: current engine)
  74374. * @param reusable If the post process can be reused on the same frame. (default: false)
  74375. * @param textureType Type of textures used when performing the post process. (default: 0)
  74376. * @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)
  74377. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74378. */
  74379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74380. /**
  74381. * Excludes the given skinned mesh from computing bones velocities.
  74382. * 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.
  74383. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74384. */
  74385. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74386. /**
  74387. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74388. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74389. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74390. */
  74391. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74392. /**
  74393. * Disposes the post process.
  74394. * @param camera The camera to dispose the post process on.
  74395. */
  74396. dispose(camera?: Camera): void;
  74397. /**
  74398. * Called on the mode changed (object based or screen based).
  74399. */
  74400. private _applyMode;
  74401. /**
  74402. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74403. */
  74404. private _onApplyObjectBased;
  74405. /**
  74406. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74407. */
  74408. private _onApplyScreenBased;
  74409. /**
  74410. * Called on the effect must be updated (changed mode, samples count, etc.).
  74411. */
  74412. private _updateEffect;
  74413. /** @hidden */
  74414. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74415. }
  74416. }
  74417. declare module BABYLON {
  74418. /** @hidden */
  74419. export var refractionPixelShader: {
  74420. name: string;
  74421. shader: string;
  74422. };
  74423. }
  74424. declare module BABYLON {
  74425. /**
  74426. * Post process which applies a refractin texture
  74427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74428. */
  74429. export class RefractionPostProcess extends PostProcess {
  74430. private _refTexture;
  74431. private _ownRefractionTexture;
  74432. /** the base color of the refraction (used to taint the rendering) */
  74433. color: Color3;
  74434. /** simulated refraction depth */
  74435. depth: number;
  74436. /** the coefficient of the base color (0 to remove base color tainting) */
  74437. colorLevel: number;
  74438. /** Gets the url used to load the refraction texture */
  74439. refractionTextureUrl: string;
  74440. /**
  74441. * Gets or sets the refraction texture
  74442. * Please note that you are responsible for disposing the texture if you set it manually
  74443. */
  74444. get refractionTexture(): Texture;
  74445. set refractionTexture(value: Texture);
  74446. /**
  74447. * Gets a string identifying the name of the class
  74448. * @returns "RefractionPostProcess" string
  74449. */
  74450. getClassName(): string;
  74451. /**
  74452. * Initializes the RefractionPostProcess
  74453. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74454. * @param name The name of the effect.
  74455. * @param refractionTextureUrl Url of the refraction texture to use
  74456. * @param color the base color of the refraction (used to taint the rendering)
  74457. * @param depth simulated refraction depth
  74458. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74459. * @param camera The camera to apply the render pass to.
  74460. * @param options The required width/height ratio to downsize to before computing the render pass.
  74461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74462. * @param engine The engine which the post process will be applied. (default: current engine)
  74463. * @param reusable If the post process can be reused on the same frame. (default: false)
  74464. */
  74465. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74466. /**
  74467. * Disposes of the post process
  74468. * @param camera Camera to dispose post process on
  74469. */
  74470. dispose(camera: Camera): void;
  74471. /** @hidden */
  74472. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74473. }
  74474. }
  74475. declare module BABYLON {
  74476. /** @hidden */
  74477. export var sharpenPixelShader: {
  74478. name: string;
  74479. shader: string;
  74480. };
  74481. }
  74482. declare module BABYLON {
  74483. /**
  74484. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74485. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74486. */
  74487. export class SharpenPostProcess extends PostProcess {
  74488. /**
  74489. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74490. */
  74491. colorAmount: number;
  74492. /**
  74493. * How much sharpness should be applied (default: 0.3)
  74494. */
  74495. edgeAmount: number;
  74496. /**
  74497. * Gets a string identifying the name of the class
  74498. * @returns "SharpenPostProcess" string
  74499. */
  74500. getClassName(): string;
  74501. /**
  74502. * Creates a new instance ConvolutionPostProcess
  74503. * @param name The name of the effect.
  74504. * @param options The required width/height ratio to downsize to before computing the render pass.
  74505. * @param camera The camera to apply the render pass to.
  74506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74507. * @param engine The engine which the post process will be applied. (default: current engine)
  74508. * @param reusable If the post process can be reused on the same frame. (default: false)
  74509. * @param textureType Type of textures used when performing the post process. (default: 0)
  74510. * @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)
  74511. */
  74512. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74513. /** @hidden */
  74514. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74515. }
  74516. }
  74517. declare module BABYLON {
  74518. /**
  74519. * PostProcessRenderPipeline
  74520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74521. */
  74522. export class PostProcessRenderPipeline {
  74523. private engine;
  74524. private _renderEffects;
  74525. private _renderEffectsForIsolatedPass;
  74526. /**
  74527. * List of inspectable custom properties (used by the Inspector)
  74528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74529. */
  74530. inspectableCustomProperties: IInspectable[];
  74531. /**
  74532. * @hidden
  74533. */
  74534. protected _cameras: Camera[];
  74535. /** @hidden */
  74536. _name: string;
  74537. /**
  74538. * Gets pipeline name
  74539. */
  74540. get name(): string;
  74541. /** Gets the list of attached cameras */
  74542. get cameras(): Camera[];
  74543. /**
  74544. * Initializes a PostProcessRenderPipeline
  74545. * @param engine engine to add the pipeline to
  74546. * @param name name of the pipeline
  74547. */
  74548. constructor(engine: Engine, name: string);
  74549. /**
  74550. * Gets the class name
  74551. * @returns "PostProcessRenderPipeline"
  74552. */
  74553. getClassName(): string;
  74554. /**
  74555. * If all the render effects in the pipeline are supported
  74556. */
  74557. get isSupported(): boolean;
  74558. /**
  74559. * Adds an effect to the pipeline
  74560. * @param renderEffect the effect to add
  74561. */
  74562. addEffect(renderEffect: PostProcessRenderEffect): void;
  74563. /** @hidden */
  74564. _rebuild(): void;
  74565. /** @hidden */
  74566. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74567. /** @hidden */
  74568. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74569. /** @hidden */
  74570. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74571. /** @hidden */
  74572. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74573. /** @hidden */
  74574. _attachCameras(cameras: Camera, unique: boolean): void;
  74575. /** @hidden */
  74576. _attachCameras(cameras: Camera[], unique: boolean): void;
  74577. /** @hidden */
  74578. _detachCameras(cameras: Camera): void;
  74579. /** @hidden */
  74580. _detachCameras(cameras: Nullable<Camera[]>): void;
  74581. /** @hidden */
  74582. _update(): void;
  74583. /** @hidden */
  74584. _reset(): void;
  74585. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74586. /**
  74587. * Sets the required values to the prepass renderer.
  74588. * @param prePassRenderer defines the prepass renderer to setup.
  74589. * @returns true if the pre pass is needed.
  74590. */
  74591. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74592. /**
  74593. * Disposes of the pipeline
  74594. */
  74595. dispose(): void;
  74596. }
  74597. }
  74598. declare module BABYLON {
  74599. /**
  74600. * PostProcessRenderPipelineManager class
  74601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74602. */
  74603. export class PostProcessRenderPipelineManager {
  74604. private _renderPipelines;
  74605. /**
  74606. * Initializes a PostProcessRenderPipelineManager
  74607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74608. */
  74609. constructor();
  74610. /**
  74611. * Gets the list of supported render pipelines
  74612. */
  74613. get supportedPipelines(): PostProcessRenderPipeline[];
  74614. /**
  74615. * Adds a pipeline to the manager
  74616. * @param renderPipeline The pipeline to add
  74617. */
  74618. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74619. /**
  74620. * Attaches a camera to the pipeline
  74621. * @param renderPipelineName The name of the pipeline to attach to
  74622. * @param cameras the camera to attach
  74623. * @param unique if the camera can be attached multiple times to the pipeline
  74624. */
  74625. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74626. /**
  74627. * Detaches a camera from the pipeline
  74628. * @param renderPipelineName The name of the pipeline to detach from
  74629. * @param cameras the camera to detach
  74630. */
  74631. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74632. /**
  74633. * Enables an effect by name on a pipeline
  74634. * @param renderPipelineName the name of the pipeline to enable the effect in
  74635. * @param renderEffectName the name of the effect to enable
  74636. * @param cameras the cameras that the effect should be enabled on
  74637. */
  74638. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74639. /**
  74640. * Disables an effect by name on a pipeline
  74641. * @param renderPipelineName the name of the pipeline to disable the effect in
  74642. * @param renderEffectName the name of the effect to disable
  74643. * @param cameras the cameras that the effect should be disabled on
  74644. */
  74645. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74646. /**
  74647. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74648. */
  74649. update(): void;
  74650. /** @hidden */
  74651. _rebuild(): void;
  74652. /**
  74653. * Disposes of the manager and pipelines
  74654. */
  74655. dispose(): void;
  74656. }
  74657. }
  74658. declare module BABYLON {
  74659. interface Scene {
  74660. /** @hidden (Backing field) */
  74661. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74662. /**
  74663. * Gets the postprocess render pipeline manager
  74664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74665. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74666. */
  74667. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74668. }
  74669. /**
  74670. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74671. */
  74672. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74673. /**
  74674. * The component name helpfull to identify the component in the list of scene components.
  74675. */
  74676. readonly name: string;
  74677. /**
  74678. * The scene the component belongs to.
  74679. */
  74680. scene: Scene;
  74681. /**
  74682. * Creates a new instance of the component for the given scene
  74683. * @param scene Defines the scene to register the component in
  74684. */
  74685. constructor(scene: Scene);
  74686. /**
  74687. * Registers the component in a given scene
  74688. */
  74689. register(): void;
  74690. /**
  74691. * Rebuilds the elements related to this component in case of
  74692. * context lost for instance.
  74693. */
  74694. rebuild(): void;
  74695. /**
  74696. * Disposes the component and the associated ressources
  74697. */
  74698. dispose(): void;
  74699. private _gatherRenderTargets;
  74700. }
  74701. }
  74702. declare module BABYLON {
  74703. /**
  74704. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74705. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74706. */
  74707. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74708. private _scene;
  74709. private _camerasToBeAttached;
  74710. /**
  74711. * ID of the sharpen post process,
  74712. */
  74713. private readonly SharpenPostProcessId;
  74714. /**
  74715. * @ignore
  74716. * ID of the image processing post process;
  74717. */
  74718. readonly ImageProcessingPostProcessId: string;
  74719. /**
  74720. * @ignore
  74721. * ID of the Fast Approximate Anti-Aliasing post process;
  74722. */
  74723. readonly FxaaPostProcessId: string;
  74724. /**
  74725. * ID of the chromatic aberration post process,
  74726. */
  74727. private readonly ChromaticAberrationPostProcessId;
  74728. /**
  74729. * ID of the grain post process
  74730. */
  74731. private readonly GrainPostProcessId;
  74732. /**
  74733. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74734. */
  74735. sharpen: SharpenPostProcess;
  74736. private _sharpenEffect;
  74737. private bloom;
  74738. /**
  74739. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74740. */
  74741. depthOfField: DepthOfFieldEffect;
  74742. /**
  74743. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74744. */
  74745. fxaa: FxaaPostProcess;
  74746. /**
  74747. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74748. */
  74749. imageProcessing: ImageProcessingPostProcess;
  74750. /**
  74751. * Chromatic aberration post process which will shift rgb colors in the image
  74752. */
  74753. chromaticAberration: ChromaticAberrationPostProcess;
  74754. private _chromaticAberrationEffect;
  74755. /**
  74756. * Grain post process which add noise to the image
  74757. */
  74758. grain: GrainPostProcess;
  74759. private _grainEffect;
  74760. /**
  74761. * Glow post process which adds a glow to emissive areas of the image
  74762. */
  74763. private _glowLayer;
  74764. /**
  74765. * Animations which can be used to tweak settings over a period of time
  74766. */
  74767. animations: Animation[];
  74768. private _imageProcessingConfigurationObserver;
  74769. private _sharpenEnabled;
  74770. private _bloomEnabled;
  74771. private _depthOfFieldEnabled;
  74772. private _depthOfFieldBlurLevel;
  74773. private _fxaaEnabled;
  74774. private _imageProcessingEnabled;
  74775. private _defaultPipelineTextureType;
  74776. private _bloomScale;
  74777. private _chromaticAberrationEnabled;
  74778. private _grainEnabled;
  74779. private _buildAllowed;
  74780. /**
  74781. * This is triggered each time the pipeline has been built.
  74782. */
  74783. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74784. /**
  74785. * Gets active scene
  74786. */
  74787. get scene(): Scene;
  74788. /**
  74789. * Enable or disable the sharpen process from the pipeline
  74790. */
  74791. set sharpenEnabled(enabled: boolean);
  74792. get sharpenEnabled(): boolean;
  74793. private _resizeObserver;
  74794. private _hardwareScaleLevel;
  74795. private _bloomKernel;
  74796. /**
  74797. * Specifies the size of the bloom blur kernel, relative to the final output size
  74798. */
  74799. get bloomKernel(): number;
  74800. set bloomKernel(value: number);
  74801. /**
  74802. * Specifies the weight of the bloom in the final rendering
  74803. */
  74804. private _bloomWeight;
  74805. /**
  74806. * Specifies the luma threshold for the area that will be blurred by the bloom
  74807. */
  74808. private _bloomThreshold;
  74809. private _hdr;
  74810. /**
  74811. * The strength of the bloom.
  74812. */
  74813. set bloomWeight(value: number);
  74814. get bloomWeight(): number;
  74815. /**
  74816. * The strength of the bloom.
  74817. */
  74818. set bloomThreshold(value: number);
  74819. get bloomThreshold(): number;
  74820. /**
  74821. * The scale of the bloom, lower value will provide better performance.
  74822. */
  74823. set bloomScale(value: number);
  74824. get bloomScale(): number;
  74825. /**
  74826. * Enable or disable the bloom from the pipeline
  74827. */
  74828. set bloomEnabled(enabled: boolean);
  74829. get bloomEnabled(): boolean;
  74830. private _rebuildBloom;
  74831. /**
  74832. * If the depth of field is enabled.
  74833. */
  74834. get depthOfFieldEnabled(): boolean;
  74835. set depthOfFieldEnabled(enabled: boolean);
  74836. /**
  74837. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74838. */
  74839. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74840. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74841. /**
  74842. * If the anti aliasing is enabled.
  74843. */
  74844. set fxaaEnabled(enabled: boolean);
  74845. get fxaaEnabled(): boolean;
  74846. private _samples;
  74847. /**
  74848. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74849. */
  74850. set samples(sampleCount: number);
  74851. get samples(): number;
  74852. /**
  74853. * If image processing is enabled.
  74854. */
  74855. set imageProcessingEnabled(enabled: boolean);
  74856. get imageProcessingEnabled(): boolean;
  74857. /**
  74858. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74859. */
  74860. set glowLayerEnabled(enabled: boolean);
  74861. get glowLayerEnabled(): boolean;
  74862. /**
  74863. * Gets the glow layer (or null if not defined)
  74864. */
  74865. get glowLayer(): Nullable<GlowLayer>;
  74866. /**
  74867. * Enable or disable the chromaticAberration process from the pipeline
  74868. */
  74869. set chromaticAberrationEnabled(enabled: boolean);
  74870. get chromaticAberrationEnabled(): boolean;
  74871. /**
  74872. * Enable or disable the grain process from the pipeline
  74873. */
  74874. set grainEnabled(enabled: boolean);
  74875. get grainEnabled(): boolean;
  74876. /**
  74877. * @constructor
  74878. * @param name - The rendering pipeline name (default: "")
  74879. * @param hdr - If high dynamic range textures should be used (default: true)
  74880. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74881. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74882. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74883. */
  74884. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74885. /**
  74886. * Get the class name
  74887. * @returns "DefaultRenderingPipeline"
  74888. */
  74889. getClassName(): string;
  74890. /**
  74891. * Force the compilation of the entire pipeline.
  74892. */
  74893. prepare(): void;
  74894. private _hasCleared;
  74895. private _prevPostProcess;
  74896. private _prevPrevPostProcess;
  74897. private _setAutoClearAndTextureSharing;
  74898. private _depthOfFieldSceneObserver;
  74899. private _buildPipeline;
  74900. private _disposePostProcesses;
  74901. /**
  74902. * Adds a camera to the pipeline
  74903. * @param camera the camera to be added
  74904. */
  74905. addCamera(camera: Camera): void;
  74906. /**
  74907. * Removes a camera from the pipeline
  74908. * @param camera the camera to remove
  74909. */
  74910. removeCamera(camera: Camera): void;
  74911. /**
  74912. * Dispose of the pipeline and stop all post processes
  74913. */
  74914. dispose(): void;
  74915. /**
  74916. * Serialize the rendering pipeline (Used when exporting)
  74917. * @returns the serialized object
  74918. */
  74919. serialize(): any;
  74920. /**
  74921. * Parse the serialized pipeline
  74922. * @param source Source pipeline.
  74923. * @param scene The scene to load the pipeline to.
  74924. * @param rootUrl The URL of the serialized pipeline.
  74925. * @returns An instantiated pipeline from the serialized object.
  74926. */
  74927. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74928. }
  74929. }
  74930. declare module BABYLON {
  74931. /** @hidden */
  74932. export var lensHighlightsPixelShader: {
  74933. name: string;
  74934. shader: string;
  74935. };
  74936. }
  74937. declare module BABYLON {
  74938. /** @hidden */
  74939. export var depthOfFieldPixelShader: {
  74940. name: string;
  74941. shader: string;
  74942. };
  74943. }
  74944. declare module BABYLON {
  74945. /**
  74946. * BABYLON.JS Chromatic Aberration GLSL Shader
  74947. * Author: Olivier Guyot
  74948. * Separates very slightly R, G and B colors on the edges of the screen
  74949. * Inspired by Francois Tarlier & Martins Upitis
  74950. */
  74951. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74952. /**
  74953. * @ignore
  74954. * The chromatic aberration PostProcess id in the pipeline
  74955. */
  74956. LensChromaticAberrationEffect: string;
  74957. /**
  74958. * @ignore
  74959. * The highlights enhancing PostProcess id in the pipeline
  74960. */
  74961. HighlightsEnhancingEffect: string;
  74962. /**
  74963. * @ignore
  74964. * The depth-of-field PostProcess id in the pipeline
  74965. */
  74966. LensDepthOfFieldEffect: string;
  74967. private _scene;
  74968. private _depthTexture;
  74969. private _grainTexture;
  74970. private _chromaticAberrationPostProcess;
  74971. private _highlightsPostProcess;
  74972. private _depthOfFieldPostProcess;
  74973. private _edgeBlur;
  74974. private _grainAmount;
  74975. private _chromaticAberration;
  74976. private _distortion;
  74977. private _highlightsGain;
  74978. private _highlightsThreshold;
  74979. private _dofDistance;
  74980. private _dofAperture;
  74981. private _dofDarken;
  74982. private _dofPentagon;
  74983. private _blurNoise;
  74984. /**
  74985. * @constructor
  74986. *
  74987. * Effect parameters are as follow:
  74988. * {
  74989. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74990. * edge_blur: number; // from 0 to x (1 for realism)
  74991. * distortion: number; // from 0 to x (1 for realism)
  74992. * grain_amount: number; // from 0 to 1
  74993. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74994. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74995. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74996. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74997. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74998. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74999. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75000. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75001. * }
  75002. * Note: if an effect parameter is unset, effect is disabled
  75003. *
  75004. * @param name The rendering pipeline name
  75005. * @param parameters - An object containing all parameters (see above)
  75006. * @param scene The scene linked to this pipeline
  75007. * @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)
  75008. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75009. */
  75010. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75011. /**
  75012. * Get the class name
  75013. * @returns "LensRenderingPipeline"
  75014. */
  75015. getClassName(): string;
  75016. /**
  75017. * Gets associated scene
  75018. */
  75019. get scene(): Scene;
  75020. /**
  75021. * Gets or sets the edge blur
  75022. */
  75023. get edgeBlur(): number;
  75024. set edgeBlur(value: number);
  75025. /**
  75026. * Gets or sets the grain amount
  75027. */
  75028. get grainAmount(): number;
  75029. set grainAmount(value: number);
  75030. /**
  75031. * Gets or sets the chromatic aberration amount
  75032. */
  75033. get chromaticAberration(): number;
  75034. set chromaticAberration(value: number);
  75035. /**
  75036. * Gets or sets the depth of field aperture
  75037. */
  75038. get dofAperture(): number;
  75039. set dofAperture(value: number);
  75040. /**
  75041. * Gets or sets the edge distortion
  75042. */
  75043. get edgeDistortion(): number;
  75044. set edgeDistortion(value: number);
  75045. /**
  75046. * Gets or sets the depth of field distortion
  75047. */
  75048. get dofDistortion(): number;
  75049. set dofDistortion(value: number);
  75050. /**
  75051. * Gets or sets the darken out of focus amount
  75052. */
  75053. get darkenOutOfFocus(): number;
  75054. set darkenOutOfFocus(value: number);
  75055. /**
  75056. * Gets or sets a boolean indicating if blur noise is enabled
  75057. */
  75058. get blurNoise(): boolean;
  75059. set blurNoise(value: boolean);
  75060. /**
  75061. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75062. */
  75063. get pentagonBokeh(): boolean;
  75064. set pentagonBokeh(value: boolean);
  75065. /**
  75066. * Gets or sets the highlight grain amount
  75067. */
  75068. get highlightsGain(): number;
  75069. set highlightsGain(value: number);
  75070. /**
  75071. * Gets or sets the highlight threshold
  75072. */
  75073. get highlightsThreshold(): number;
  75074. set highlightsThreshold(value: number);
  75075. /**
  75076. * Sets the amount of blur at the edges
  75077. * @param amount blur amount
  75078. */
  75079. setEdgeBlur(amount: number): void;
  75080. /**
  75081. * Sets edge blur to 0
  75082. */
  75083. disableEdgeBlur(): void;
  75084. /**
  75085. * Sets the amout of grain
  75086. * @param amount Amount of grain
  75087. */
  75088. setGrainAmount(amount: number): void;
  75089. /**
  75090. * Set grain amount to 0
  75091. */
  75092. disableGrain(): void;
  75093. /**
  75094. * Sets the chromatic aberration amount
  75095. * @param amount amount of chromatic aberration
  75096. */
  75097. setChromaticAberration(amount: number): void;
  75098. /**
  75099. * Sets chromatic aberration amount to 0
  75100. */
  75101. disableChromaticAberration(): void;
  75102. /**
  75103. * Sets the EdgeDistortion amount
  75104. * @param amount amount of EdgeDistortion
  75105. */
  75106. setEdgeDistortion(amount: number): void;
  75107. /**
  75108. * Sets edge distortion to 0
  75109. */
  75110. disableEdgeDistortion(): void;
  75111. /**
  75112. * Sets the FocusDistance amount
  75113. * @param amount amount of FocusDistance
  75114. */
  75115. setFocusDistance(amount: number): void;
  75116. /**
  75117. * Disables depth of field
  75118. */
  75119. disableDepthOfField(): void;
  75120. /**
  75121. * Sets the Aperture amount
  75122. * @param amount amount of Aperture
  75123. */
  75124. setAperture(amount: number): void;
  75125. /**
  75126. * Sets the DarkenOutOfFocus amount
  75127. * @param amount amount of DarkenOutOfFocus
  75128. */
  75129. setDarkenOutOfFocus(amount: number): void;
  75130. private _pentagonBokehIsEnabled;
  75131. /**
  75132. * Creates a pentagon bokeh effect
  75133. */
  75134. enablePentagonBokeh(): void;
  75135. /**
  75136. * Disables the pentagon bokeh effect
  75137. */
  75138. disablePentagonBokeh(): void;
  75139. /**
  75140. * Enables noise blur
  75141. */
  75142. enableNoiseBlur(): void;
  75143. /**
  75144. * Disables noise blur
  75145. */
  75146. disableNoiseBlur(): void;
  75147. /**
  75148. * Sets the HighlightsGain amount
  75149. * @param amount amount of HighlightsGain
  75150. */
  75151. setHighlightsGain(amount: number): void;
  75152. /**
  75153. * Sets the HighlightsThreshold amount
  75154. * @param amount amount of HighlightsThreshold
  75155. */
  75156. setHighlightsThreshold(amount: number): void;
  75157. /**
  75158. * Disables highlights
  75159. */
  75160. disableHighlights(): void;
  75161. /**
  75162. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75163. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75164. */
  75165. dispose(disableDepthRender?: boolean): void;
  75166. private _createChromaticAberrationPostProcess;
  75167. private _createHighlightsPostProcess;
  75168. private _createDepthOfFieldPostProcess;
  75169. private _createGrainTexture;
  75170. }
  75171. }
  75172. declare module BABYLON {
  75173. /**
  75174. * Contains all parameters needed for the prepass to perform
  75175. * screen space subsurface scattering
  75176. */
  75177. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75178. /**
  75179. * Is subsurface enabled
  75180. */
  75181. enabled: boolean;
  75182. /**
  75183. * Name of the configuration
  75184. */
  75185. name: string;
  75186. /**
  75187. * Textures that should be present in the MRT for this effect to work
  75188. */
  75189. readonly texturesRequired: number[];
  75190. }
  75191. }
  75192. declare module BABYLON {
  75193. /** @hidden */
  75194. export var ssao2PixelShader: {
  75195. name: string;
  75196. shader: string;
  75197. };
  75198. }
  75199. declare module BABYLON {
  75200. /** @hidden */
  75201. export var ssaoCombinePixelShader: {
  75202. name: string;
  75203. shader: string;
  75204. };
  75205. }
  75206. declare module BABYLON {
  75207. /**
  75208. * Render pipeline to produce ssao effect
  75209. */
  75210. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75211. /**
  75212. * @ignore
  75213. * The PassPostProcess id in the pipeline that contains the original scene color
  75214. */
  75215. SSAOOriginalSceneColorEffect: string;
  75216. /**
  75217. * @ignore
  75218. * The SSAO PostProcess id in the pipeline
  75219. */
  75220. SSAORenderEffect: string;
  75221. /**
  75222. * @ignore
  75223. * The horizontal blur PostProcess id in the pipeline
  75224. */
  75225. SSAOBlurHRenderEffect: string;
  75226. /**
  75227. * @ignore
  75228. * The vertical blur PostProcess id in the pipeline
  75229. */
  75230. SSAOBlurVRenderEffect: string;
  75231. /**
  75232. * @ignore
  75233. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75234. */
  75235. SSAOCombineRenderEffect: string;
  75236. /**
  75237. * The output strength of the SSAO post-process. Default value is 1.0.
  75238. */
  75239. totalStrength: number;
  75240. /**
  75241. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75242. */
  75243. maxZ: number;
  75244. /**
  75245. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75246. */
  75247. minZAspect: number;
  75248. private _samples;
  75249. /**
  75250. * Number of samples used for the SSAO calculations. Default value is 8
  75251. */
  75252. set samples(n: number);
  75253. get samples(): number;
  75254. private _textureSamples;
  75255. /**
  75256. * Number of samples to use for antialiasing
  75257. */
  75258. set textureSamples(n: number);
  75259. get textureSamples(): number;
  75260. /**
  75261. * Force rendering the geometry through geometry buffer
  75262. */
  75263. private _forceGeometryBuffer;
  75264. /**
  75265. * Ratio object used for SSAO ratio and blur ratio
  75266. */
  75267. private _ratio;
  75268. /**
  75269. * Dynamically generated sphere sampler.
  75270. */
  75271. private _sampleSphere;
  75272. /**
  75273. * Blur filter offsets
  75274. */
  75275. private _samplerOffsets;
  75276. private _expensiveBlur;
  75277. /**
  75278. * If bilateral blur should be used
  75279. */
  75280. set expensiveBlur(b: boolean);
  75281. get expensiveBlur(): boolean;
  75282. /**
  75283. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75284. */
  75285. radius: number;
  75286. /**
  75287. * The base color of the SSAO post-process
  75288. * The final result is "base + ssao" between [0, 1]
  75289. */
  75290. base: number;
  75291. /**
  75292. * Support test.
  75293. */
  75294. static get IsSupported(): boolean;
  75295. private _scene;
  75296. private _randomTexture;
  75297. private _originalColorPostProcess;
  75298. private _ssaoPostProcess;
  75299. private _blurHPostProcess;
  75300. private _blurVPostProcess;
  75301. private _ssaoCombinePostProcess;
  75302. private _prePassRenderer;
  75303. /**
  75304. * Gets active scene
  75305. */
  75306. get scene(): Scene;
  75307. /**
  75308. * @constructor
  75309. * @param name The rendering pipeline name
  75310. * @param scene The scene linked to this pipeline
  75311. * @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 }
  75312. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75313. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75314. */
  75315. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75316. /**
  75317. * Get the class name
  75318. * @returns "SSAO2RenderingPipeline"
  75319. */
  75320. getClassName(): string;
  75321. /**
  75322. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75323. */
  75324. dispose(disableGeometryBufferRenderer?: boolean): void;
  75325. private _createBlurPostProcess;
  75326. /** @hidden */
  75327. _rebuild(): void;
  75328. private _bits;
  75329. private _radicalInverse_VdC;
  75330. private _hammersley;
  75331. private _hemisphereSample_uniform;
  75332. private _generateHemisphere;
  75333. private _getDefinesForSSAO;
  75334. private static readonly ORTHO_DEPTH_PROJECTION;
  75335. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75336. private _createSSAOPostProcess;
  75337. private _createSSAOCombinePostProcess;
  75338. private _createRandomTexture;
  75339. /**
  75340. * Serialize the rendering pipeline (Used when exporting)
  75341. * @returns the serialized object
  75342. */
  75343. serialize(): any;
  75344. /**
  75345. * Parse the serialized pipeline
  75346. * @param source Source pipeline.
  75347. * @param scene The scene to load the pipeline to.
  75348. * @param rootUrl The URL of the serialized pipeline.
  75349. * @returns An instantiated pipeline from the serialized object.
  75350. */
  75351. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75352. }
  75353. }
  75354. declare module BABYLON {
  75355. /** @hidden */
  75356. export var ssaoPixelShader: {
  75357. name: string;
  75358. shader: string;
  75359. };
  75360. }
  75361. declare module BABYLON {
  75362. /**
  75363. * Render pipeline to produce ssao effect
  75364. */
  75365. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75366. /**
  75367. * @ignore
  75368. * The PassPostProcess id in the pipeline that contains the original scene color
  75369. */
  75370. SSAOOriginalSceneColorEffect: string;
  75371. /**
  75372. * @ignore
  75373. * The SSAO PostProcess id in the pipeline
  75374. */
  75375. SSAORenderEffect: string;
  75376. /**
  75377. * @ignore
  75378. * The horizontal blur PostProcess id in the pipeline
  75379. */
  75380. SSAOBlurHRenderEffect: string;
  75381. /**
  75382. * @ignore
  75383. * The vertical blur PostProcess id in the pipeline
  75384. */
  75385. SSAOBlurVRenderEffect: string;
  75386. /**
  75387. * @ignore
  75388. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75389. */
  75390. SSAOCombineRenderEffect: string;
  75391. /**
  75392. * The output strength of the SSAO post-process. Default value is 1.0.
  75393. */
  75394. totalStrength: number;
  75395. /**
  75396. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75397. */
  75398. radius: number;
  75399. /**
  75400. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75401. * Must not be equal to fallOff and superior to fallOff.
  75402. * Default value is 0.0075
  75403. */
  75404. area: number;
  75405. /**
  75406. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75407. * Must not be equal to area and inferior to area.
  75408. * Default value is 0.000001
  75409. */
  75410. fallOff: number;
  75411. /**
  75412. * The base color of the SSAO post-process
  75413. * The final result is "base + ssao" between [0, 1]
  75414. */
  75415. base: number;
  75416. private _scene;
  75417. private _depthTexture;
  75418. private _randomTexture;
  75419. private _originalColorPostProcess;
  75420. private _ssaoPostProcess;
  75421. private _blurHPostProcess;
  75422. private _blurVPostProcess;
  75423. private _ssaoCombinePostProcess;
  75424. private _firstUpdate;
  75425. /**
  75426. * Gets active scene
  75427. */
  75428. get scene(): Scene;
  75429. /**
  75430. * @constructor
  75431. * @param name - The rendering pipeline name
  75432. * @param scene - The scene linked to this pipeline
  75433. * @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 }
  75434. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75435. */
  75436. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75437. /**
  75438. * Get the class name
  75439. * @returns "SSAORenderingPipeline"
  75440. */
  75441. getClassName(): string;
  75442. /**
  75443. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75444. */
  75445. dispose(disableDepthRender?: boolean): void;
  75446. private _createBlurPostProcess;
  75447. /** @hidden */
  75448. _rebuild(): void;
  75449. private _createSSAOPostProcess;
  75450. private _createSSAOCombinePostProcess;
  75451. private _createRandomTexture;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /**
  75456. * Contains all parameters needed for the prepass to perform
  75457. * screen space reflections
  75458. */
  75459. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75460. /**
  75461. * Is ssr enabled
  75462. */
  75463. enabled: boolean;
  75464. /**
  75465. * Name of the configuration
  75466. */
  75467. name: string;
  75468. /**
  75469. * Textures that should be present in the MRT for this effect to work
  75470. */
  75471. readonly texturesRequired: number[];
  75472. }
  75473. }
  75474. declare module BABYLON {
  75475. /** @hidden */
  75476. export var screenSpaceReflectionPixelShader: {
  75477. name: string;
  75478. shader: string;
  75479. };
  75480. }
  75481. declare module BABYLON {
  75482. /**
  75483. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75484. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75485. */
  75486. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75487. /**
  75488. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75489. */
  75490. threshold: number;
  75491. /**
  75492. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75493. */
  75494. strength: number;
  75495. /**
  75496. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75497. */
  75498. reflectionSpecularFalloffExponent: number;
  75499. /**
  75500. * 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]
  75501. */
  75502. step: number;
  75503. /**
  75504. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75505. */
  75506. roughnessFactor: number;
  75507. private _forceGeometryBuffer;
  75508. private _geometryBufferRenderer;
  75509. private _prePassRenderer;
  75510. private _enableSmoothReflections;
  75511. private _reflectionSamples;
  75512. private _smoothSteps;
  75513. /**
  75514. * Gets a string identifying the name of the class
  75515. * @returns "ScreenSpaceReflectionPostProcess" string
  75516. */
  75517. getClassName(): string;
  75518. /**
  75519. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75520. * @param name The name of the effect.
  75521. * @param scene The scene containing the objects to calculate reflections.
  75522. * @param options The required width/height ratio to downsize to before computing the render pass.
  75523. * @param camera The camera to apply the render pass to.
  75524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75525. * @param engine The engine which the post process will be applied. (default: current engine)
  75526. * @param reusable If the post process can be reused on the same frame. (default: false)
  75527. * @param textureType Type of textures used when performing the post process. (default: 0)
  75528. * @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)
  75529. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75530. */
  75531. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75532. /**
  75533. * Gets wether or not smoothing reflections is enabled.
  75534. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75535. */
  75536. get enableSmoothReflections(): boolean;
  75537. /**
  75538. * Sets wether or not smoothing reflections is enabled.
  75539. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75540. */
  75541. set enableSmoothReflections(enabled: boolean);
  75542. /**
  75543. * Gets the number of samples taken while computing reflections. More samples count is high,
  75544. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75545. */
  75546. get reflectionSamples(): number;
  75547. /**
  75548. * Sets the number of samples taken while computing reflections. More samples count is high,
  75549. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75550. */
  75551. set reflectionSamples(samples: number);
  75552. /**
  75553. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75554. * more the post-process will require GPU power and can generate a drop in FPS.
  75555. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75556. */
  75557. get smoothSteps(): number;
  75558. set smoothSteps(steps: number);
  75559. private _updateEffectDefines;
  75560. /** @hidden */
  75561. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75562. }
  75563. }
  75564. declare module BABYLON {
  75565. /** @hidden */
  75566. export var standardPixelShader: {
  75567. name: string;
  75568. shader: string;
  75569. };
  75570. }
  75571. declare module BABYLON {
  75572. /**
  75573. * Standard rendering pipeline
  75574. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75575. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75576. */
  75577. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75578. /**
  75579. * Public members
  75580. */
  75581. /**
  75582. * Post-process which contains the original scene color before the pipeline applies all the effects
  75583. */
  75584. originalPostProcess: Nullable<PostProcess>;
  75585. /**
  75586. * Post-process used to down scale an image x4
  75587. */
  75588. downSampleX4PostProcess: Nullable<PostProcess>;
  75589. /**
  75590. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75591. */
  75592. brightPassPostProcess: Nullable<PostProcess>;
  75593. /**
  75594. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75595. */
  75596. blurHPostProcesses: PostProcess[];
  75597. /**
  75598. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75599. */
  75600. blurVPostProcesses: PostProcess[];
  75601. /**
  75602. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75603. */
  75604. textureAdderPostProcess: Nullable<PostProcess>;
  75605. /**
  75606. * Post-process used to create volumetric lighting effect
  75607. */
  75608. volumetricLightPostProcess: Nullable<PostProcess>;
  75609. /**
  75610. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75611. */
  75612. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75613. /**
  75614. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75615. */
  75616. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75617. /**
  75618. * Post-process used to merge the volumetric light effect and the real scene color
  75619. */
  75620. volumetricLightMergePostProces: Nullable<PostProcess>;
  75621. /**
  75622. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75623. */
  75624. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75625. /**
  75626. * Base post-process used to calculate the average luminance of the final image for HDR
  75627. */
  75628. luminancePostProcess: Nullable<PostProcess>;
  75629. /**
  75630. * Post-processes used to create down sample post-processes in order to get
  75631. * the average luminance of the final image for HDR
  75632. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75633. */
  75634. luminanceDownSamplePostProcesses: PostProcess[];
  75635. /**
  75636. * Post-process used to create a HDR effect (light adaptation)
  75637. */
  75638. hdrPostProcess: Nullable<PostProcess>;
  75639. /**
  75640. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75641. */
  75642. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75643. /**
  75644. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75645. */
  75646. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75647. /**
  75648. * Post-process used to merge the final HDR post-process and the real scene color
  75649. */
  75650. hdrFinalPostProcess: Nullable<PostProcess>;
  75651. /**
  75652. * Post-process used to create a lens flare effect
  75653. */
  75654. lensFlarePostProcess: Nullable<PostProcess>;
  75655. /**
  75656. * Post-process that merges the result of the lens flare post-process and the real scene color
  75657. */
  75658. lensFlareComposePostProcess: Nullable<PostProcess>;
  75659. /**
  75660. * Post-process used to create a motion blur effect
  75661. */
  75662. motionBlurPostProcess: Nullable<PostProcess>;
  75663. /**
  75664. * Post-process used to create a depth of field effect
  75665. */
  75666. depthOfFieldPostProcess: Nullable<PostProcess>;
  75667. /**
  75668. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75669. */
  75670. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75671. /**
  75672. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75673. */
  75674. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75675. /**
  75676. * Represents the brightness threshold in order to configure the illuminated surfaces
  75677. */
  75678. brightThreshold: number;
  75679. /**
  75680. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75681. */
  75682. blurWidth: number;
  75683. /**
  75684. * Sets if the blur for highlighted surfaces must be only horizontal
  75685. */
  75686. horizontalBlur: boolean;
  75687. /**
  75688. * Gets the overall exposure used by the pipeline
  75689. */
  75690. get exposure(): number;
  75691. /**
  75692. * Sets the overall exposure used by the pipeline
  75693. */
  75694. set exposure(value: number);
  75695. /**
  75696. * Texture used typically to simulate "dirty" on camera lens
  75697. */
  75698. lensTexture: Nullable<Texture>;
  75699. /**
  75700. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75701. */
  75702. volumetricLightCoefficient: number;
  75703. /**
  75704. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75705. */
  75706. volumetricLightPower: number;
  75707. /**
  75708. * Used the set the blur intensity to smooth the volumetric lights
  75709. */
  75710. volumetricLightBlurScale: number;
  75711. /**
  75712. * Light (spot or directional) used to generate the volumetric lights rays
  75713. * The source light must have a shadow generate so the pipeline can get its
  75714. * depth map
  75715. */
  75716. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75717. /**
  75718. * For eye adaptation, represents the minimum luminance the eye can see
  75719. */
  75720. hdrMinimumLuminance: number;
  75721. /**
  75722. * For eye adaptation, represents the decrease luminance speed
  75723. */
  75724. hdrDecreaseRate: number;
  75725. /**
  75726. * For eye adaptation, represents the increase luminance speed
  75727. */
  75728. hdrIncreaseRate: number;
  75729. /**
  75730. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75731. */
  75732. get hdrAutoExposure(): boolean;
  75733. /**
  75734. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75735. */
  75736. set hdrAutoExposure(value: boolean);
  75737. /**
  75738. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75739. */
  75740. lensColorTexture: Nullable<Texture>;
  75741. /**
  75742. * The overall strengh for the lens flare effect
  75743. */
  75744. lensFlareStrength: number;
  75745. /**
  75746. * Dispersion coefficient for lens flare ghosts
  75747. */
  75748. lensFlareGhostDispersal: number;
  75749. /**
  75750. * Main lens flare halo width
  75751. */
  75752. lensFlareHaloWidth: number;
  75753. /**
  75754. * Based on the lens distortion effect, defines how much the lens flare result
  75755. * is distorted
  75756. */
  75757. lensFlareDistortionStrength: number;
  75758. /**
  75759. * Configures the blur intensity used for for lens flare (halo)
  75760. */
  75761. lensFlareBlurWidth: number;
  75762. /**
  75763. * Lens star texture must be used to simulate rays on the flares and is available
  75764. * in the documentation
  75765. */
  75766. lensStarTexture: Nullable<Texture>;
  75767. /**
  75768. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75769. * flare effect by taking account of the dirt texture
  75770. */
  75771. lensFlareDirtTexture: Nullable<Texture>;
  75772. /**
  75773. * Represents the focal length for the depth of field effect
  75774. */
  75775. depthOfFieldDistance: number;
  75776. /**
  75777. * Represents the blur intensity for the blurred part of the depth of field effect
  75778. */
  75779. depthOfFieldBlurWidth: number;
  75780. /**
  75781. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75782. */
  75783. get motionStrength(): number;
  75784. /**
  75785. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75786. */
  75787. set motionStrength(strength: number);
  75788. /**
  75789. * Gets wether or not the motion blur post-process is object based or screen based.
  75790. */
  75791. get objectBasedMotionBlur(): boolean;
  75792. /**
  75793. * Sets wether or not the motion blur post-process should be object based or screen based
  75794. */
  75795. set objectBasedMotionBlur(value: boolean);
  75796. /**
  75797. * List of animations for the pipeline (IAnimatable implementation)
  75798. */
  75799. animations: Animation[];
  75800. /**
  75801. * Private members
  75802. */
  75803. private _scene;
  75804. private _currentDepthOfFieldSource;
  75805. private _basePostProcess;
  75806. private _fixedExposure;
  75807. private _currentExposure;
  75808. private _hdrAutoExposure;
  75809. private _hdrCurrentLuminance;
  75810. private _motionStrength;
  75811. private _isObjectBasedMotionBlur;
  75812. private _floatTextureType;
  75813. private _camerasToBeAttached;
  75814. private _ratio;
  75815. private _bloomEnabled;
  75816. private _depthOfFieldEnabled;
  75817. private _vlsEnabled;
  75818. private _lensFlareEnabled;
  75819. private _hdrEnabled;
  75820. private _motionBlurEnabled;
  75821. private _fxaaEnabled;
  75822. private _screenSpaceReflectionsEnabled;
  75823. private _motionBlurSamples;
  75824. private _volumetricLightStepsCount;
  75825. private _samples;
  75826. /**
  75827. * @ignore
  75828. * Specifies if the bloom pipeline is enabled
  75829. */
  75830. get BloomEnabled(): boolean;
  75831. set BloomEnabled(enabled: boolean);
  75832. /**
  75833. * @ignore
  75834. * Specifies if the depth of field pipeline is enabed
  75835. */
  75836. get DepthOfFieldEnabled(): boolean;
  75837. set DepthOfFieldEnabled(enabled: boolean);
  75838. /**
  75839. * @ignore
  75840. * Specifies if the lens flare pipeline is enabed
  75841. */
  75842. get LensFlareEnabled(): boolean;
  75843. set LensFlareEnabled(enabled: boolean);
  75844. /**
  75845. * @ignore
  75846. * Specifies if the HDR pipeline is enabled
  75847. */
  75848. get HDREnabled(): boolean;
  75849. set HDREnabled(enabled: boolean);
  75850. /**
  75851. * @ignore
  75852. * Specifies if the volumetric lights scattering effect is enabled
  75853. */
  75854. get VLSEnabled(): boolean;
  75855. set VLSEnabled(enabled: boolean);
  75856. /**
  75857. * @ignore
  75858. * Specifies if the motion blur effect is enabled
  75859. */
  75860. get MotionBlurEnabled(): boolean;
  75861. set MotionBlurEnabled(enabled: boolean);
  75862. /**
  75863. * Specifies if anti-aliasing is enabled
  75864. */
  75865. get fxaaEnabled(): boolean;
  75866. set fxaaEnabled(enabled: boolean);
  75867. /**
  75868. * Specifies if screen space reflections are enabled.
  75869. */
  75870. get screenSpaceReflectionsEnabled(): boolean;
  75871. set screenSpaceReflectionsEnabled(enabled: boolean);
  75872. /**
  75873. * Specifies the number of steps used to calculate the volumetric lights
  75874. * Typically in interval [50, 200]
  75875. */
  75876. get volumetricLightStepsCount(): number;
  75877. set volumetricLightStepsCount(count: number);
  75878. /**
  75879. * Specifies the number of samples used for the motion blur effect
  75880. * Typically in interval [16, 64]
  75881. */
  75882. get motionBlurSamples(): number;
  75883. set motionBlurSamples(samples: number);
  75884. /**
  75885. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75886. */
  75887. get samples(): number;
  75888. set samples(sampleCount: number);
  75889. /**
  75890. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75891. * @constructor
  75892. * @param name The rendering pipeline name
  75893. * @param scene The scene linked to this pipeline
  75894. * @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)
  75895. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75896. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75897. */
  75898. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75899. private _buildPipeline;
  75900. private _createDownSampleX4PostProcess;
  75901. private _createBrightPassPostProcess;
  75902. private _createBlurPostProcesses;
  75903. private _createTextureAdderPostProcess;
  75904. private _createVolumetricLightPostProcess;
  75905. private _createLuminancePostProcesses;
  75906. private _createHdrPostProcess;
  75907. private _createLensFlarePostProcess;
  75908. private _createDepthOfFieldPostProcess;
  75909. private _createMotionBlurPostProcess;
  75910. private _getDepthTexture;
  75911. private _disposePostProcesses;
  75912. /**
  75913. * Dispose of the pipeline and stop all post processes
  75914. */
  75915. dispose(): void;
  75916. /**
  75917. * Serialize the rendering pipeline (Used when exporting)
  75918. * @returns the serialized object
  75919. */
  75920. serialize(): any;
  75921. /**
  75922. * Parse the serialized pipeline
  75923. * @param source Source pipeline.
  75924. * @param scene The scene to load the pipeline to.
  75925. * @param rootUrl The URL of the serialized pipeline.
  75926. * @returns An instantiated pipeline from the serialized object.
  75927. */
  75928. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75929. /**
  75930. * Luminance steps
  75931. */
  75932. static LuminanceSteps: number;
  75933. }
  75934. }
  75935. declare module BABYLON {
  75936. /** @hidden */
  75937. export var tonemapPixelShader: {
  75938. name: string;
  75939. shader: string;
  75940. };
  75941. }
  75942. declare module BABYLON {
  75943. /** Defines operator used for tonemapping */
  75944. export enum TonemappingOperator {
  75945. /** Hable */
  75946. Hable = 0,
  75947. /** Reinhard */
  75948. Reinhard = 1,
  75949. /** HejiDawson */
  75950. HejiDawson = 2,
  75951. /** Photographic */
  75952. Photographic = 3
  75953. }
  75954. /**
  75955. * Defines a post process to apply tone mapping
  75956. */
  75957. export class TonemapPostProcess extends PostProcess {
  75958. private _operator;
  75959. /** Defines the required exposure adjustement */
  75960. exposureAdjustment: number;
  75961. /**
  75962. * Gets a string identifying the name of the class
  75963. * @returns "TonemapPostProcess" string
  75964. */
  75965. getClassName(): string;
  75966. /**
  75967. * Creates a new TonemapPostProcess
  75968. * @param name defines the name of the postprocess
  75969. * @param _operator defines the operator to use
  75970. * @param exposureAdjustment defines the required exposure adjustement
  75971. * @param camera defines the camera to use (can be null)
  75972. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75973. * @param engine defines the hosting engine (can be ignore if camera is set)
  75974. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75975. */
  75976. constructor(name: string, _operator: TonemappingOperator,
  75977. /** Defines the required exposure adjustement */
  75978. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75979. }
  75980. }
  75981. declare module BABYLON {
  75982. /** @hidden */
  75983. export var volumetricLightScatteringPixelShader: {
  75984. name: string;
  75985. shader: string;
  75986. };
  75987. }
  75988. declare module BABYLON {
  75989. /** @hidden */
  75990. export var volumetricLightScatteringPassVertexShader: {
  75991. name: string;
  75992. shader: string;
  75993. };
  75994. }
  75995. declare module BABYLON {
  75996. /** @hidden */
  75997. export var volumetricLightScatteringPassPixelShader: {
  75998. name: string;
  75999. shader: string;
  76000. };
  76001. }
  76002. declare module BABYLON {
  76003. /**
  76004. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76005. */
  76006. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76007. private _volumetricLightScatteringPass;
  76008. private _volumetricLightScatteringRTT;
  76009. private _viewPort;
  76010. private _screenCoordinates;
  76011. private _cachedDefines;
  76012. /**
  76013. * If not undefined, the mesh position is computed from the attached node position
  76014. */
  76015. attachedNode: {
  76016. position: Vector3;
  76017. };
  76018. /**
  76019. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76020. */
  76021. customMeshPosition: Vector3;
  76022. /**
  76023. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76024. */
  76025. useCustomMeshPosition: boolean;
  76026. /**
  76027. * If the post-process should inverse the light scattering direction
  76028. */
  76029. invert: boolean;
  76030. /**
  76031. * The internal mesh used by the post-process
  76032. */
  76033. mesh: Mesh;
  76034. /**
  76035. * @hidden
  76036. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76037. */
  76038. get useDiffuseColor(): boolean;
  76039. set useDiffuseColor(useDiffuseColor: boolean);
  76040. /**
  76041. * Array containing the excluded meshes not rendered in the internal pass
  76042. */
  76043. excludedMeshes: AbstractMesh[];
  76044. /**
  76045. * Controls the overall intensity of the post-process
  76046. */
  76047. exposure: number;
  76048. /**
  76049. * Dissipates each sample's contribution in range [0, 1]
  76050. */
  76051. decay: number;
  76052. /**
  76053. * Controls the overall intensity of each sample
  76054. */
  76055. weight: number;
  76056. /**
  76057. * Controls the density of each sample
  76058. */
  76059. density: number;
  76060. /**
  76061. * @constructor
  76062. * @param name The post-process name
  76063. * @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)
  76064. * @param camera The camera that the post-process will be attached to
  76065. * @param mesh The mesh used to create the light scattering
  76066. * @param samples The post-process quality, default 100
  76067. * @param samplingModeThe post-process filtering mode
  76068. * @param engine The babylon engine
  76069. * @param reusable If the post-process is reusable
  76070. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76071. */
  76072. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76073. /**
  76074. * Returns the string "VolumetricLightScatteringPostProcess"
  76075. * @returns "VolumetricLightScatteringPostProcess"
  76076. */
  76077. getClassName(): string;
  76078. private _isReady;
  76079. /**
  76080. * Sets the new light position for light scattering effect
  76081. * @param position The new custom light position
  76082. */
  76083. setCustomMeshPosition(position: Vector3): void;
  76084. /**
  76085. * Returns the light position for light scattering effect
  76086. * @return Vector3 The custom light position
  76087. */
  76088. getCustomMeshPosition(): Vector3;
  76089. /**
  76090. * Disposes the internal assets and detaches the post-process from the camera
  76091. */
  76092. dispose(camera: Camera): void;
  76093. /**
  76094. * Returns the render target texture used by the post-process
  76095. * @return the render target texture used by the post-process
  76096. */
  76097. getPass(): RenderTargetTexture;
  76098. private _meshExcluded;
  76099. private _createPass;
  76100. private _updateMeshScreenCoordinates;
  76101. /**
  76102. * Creates a default mesh for the Volumeric Light Scattering post-process
  76103. * @param name The mesh name
  76104. * @param scene The scene where to create the mesh
  76105. * @return the default mesh
  76106. */
  76107. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76108. }
  76109. }
  76110. declare module BABYLON {
  76111. /** @hidden */
  76112. export var screenSpaceCurvaturePixelShader: {
  76113. name: string;
  76114. shader: string;
  76115. };
  76116. }
  76117. declare module BABYLON {
  76118. /**
  76119. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76120. */
  76121. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76122. /**
  76123. * Defines how much ridge the curvature effect displays.
  76124. */
  76125. ridge: number;
  76126. /**
  76127. * Defines how much valley the curvature effect displays.
  76128. */
  76129. valley: number;
  76130. private _geometryBufferRenderer;
  76131. /**
  76132. * Gets a string identifying the name of the class
  76133. * @returns "ScreenSpaceCurvaturePostProcess" string
  76134. */
  76135. getClassName(): string;
  76136. /**
  76137. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76138. * @param name The name of the effect.
  76139. * @param scene The scene containing the objects to blur according to their velocity.
  76140. * @param options The required width/height ratio to downsize to before computing the render pass.
  76141. * @param camera The camera to apply the render pass to.
  76142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76143. * @param engine The engine which the post process will be applied. (default: current engine)
  76144. * @param reusable If the post process can be reused on the same frame. (default: false)
  76145. * @param textureType Type of textures used when performing the post process. (default: 0)
  76146. * @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)
  76147. */
  76148. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76149. /**
  76150. * Support test.
  76151. */
  76152. static get IsSupported(): boolean;
  76153. /** @hidden */
  76154. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76155. }
  76156. }
  76157. declare module BABYLON {
  76158. interface Scene {
  76159. /** @hidden (Backing field) */
  76160. _boundingBoxRenderer: BoundingBoxRenderer;
  76161. /** @hidden (Backing field) */
  76162. _forceShowBoundingBoxes: boolean;
  76163. /**
  76164. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76165. */
  76166. forceShowBoundingBoxes: boolean;
  76167. /**
  76168. * Gets the bounding box renderer associated with the scene
  76169. * @returns a BoundingBoxRenderer
  76170. */
  76171. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76172. }
  76173. interface AbstractMesh {
  76174. /** @hidden (Backing field) */
  76175. _showBoundingBox: boolean;
  76176. /**
  76177. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76178. */
  76179. showBoundingBox: boolean;
  76180. }
  76181. /**
  76182. * Component responsible of rendering the bounding box of the meshes in a scene.
  76183. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76184. */
  76185. export class BoundingBoxRenderer implements ISceneComponent {
  76186. /**
  76187. * The component name helpfull to identify the component in the list of scene components.
  76188. */
  76189. readonly name: string;
  76190. /**
  76191. * The scene the component belongs to.
  76192. */
  76193. scene: Scene;
  76194. /**
  76195. * Color of the bounding box lines placed in front of an object
  76196. */
  76197. frontColor: Color3;
  76198. /**
  76199. * Color of the bounding box lines placed behind an object
  76200. */
  76201. backColor: Color3;
  76202. /**
  76203. * Defines if the renderer should show the back lines or not
  76204. */
  76205. showBackLines: boolean;
  76206. /**
  76207. * Observable raised before rendering a bounding box
  76208. */
  76209. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76210. /**
  76211. * Observable raised after rendering a bounding box
  76212. */
  76213. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76214. /**
  76215. * Observable raised after resources are created
  76216. */
  76217. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76218. /**
  76219. * When false, no bounding boxes will be rendered
  76220. */
  76221. enabled: boolean;
  76222. /**
  76223. * @hidden
  76224. */
  76225. renderList: SmartArray<BoundingBox>;
  76226. private _colorShader;
  76227. private _vertexBuffers;
  76228. private _indexBuffer;
  76229. private _fillIndexBuffer;
  76230. private _fillIndexData;
  76231. /**
  76232. * Instantiates a new bounding box renderer in a scene.
  76233. * @param scene the scene the renderer renders in
  76234. */
  76235. constructor(scene: Scene);
  76236. /**
  76237. * Registers the component in a given scene
  76238. */
  76239. register(): void;
  76240. private _evaluateSubMesh;
  76241. private _preActiveMesh;
  76242. private _prepareResources;
  76243. private _createIndexBuffer;
  76244. /**
  76245. * Rebuilds the elements related to this component in case of
  76246. * context lost for instance.
  76247. */
  76248. rebuild(): void;
  76249. /**
  76250. * @hidden
  76251. */
  76252. reset(): void;
  76253. /**
  76254. * Render the bounding boxes of a specific rendering group
  76255. * @param renderingGroupId defines the rendering group to render
  76256. */
  76257. render(renderingGroupId: number): void;
  76258. /**
  76259. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76260. * @param mesh Define the mesh to render the occlusion bounding box for
  76261. */
  76262. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76263. /**
  76264. * Dispose and release the resources attached to this renderer.
  76265. */
  76266. dispose(): void;
  76267. }
  76268. }
  76269. declare module BABYLON {
  76270. interface Scene {
  76271. /** @hidden (Backing field) */
  76272. _depthRenderer: {
  76273. [id: string]: DepthRenderer;
  76274. };
  76275. /**
  76276. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76277. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76278. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76279. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76280. * @returns the created depth renderer
  76281. */
  76282. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76283. /**
  76284. * Disables a depth renderer for a given camera
  76285. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76286. */
  76287. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76288. }
  76289. /**
  76290. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76291. * in several rendering techniques.
  76292. */
  76293. export class DepthRendererSceneComponent implements ISceneComponent {
  76294. /**
  76295. * The component name helpfull to identify the component in the list of scene components.
  76296. */
  76297. readonly name: string;
  76298. /**
  76299. * The scene the component belongs to.
  76300. */
  76301. scene: Scene;
  76302. /**
  76303. * Creates a new instance of the component for the given scene
  76304. * @param scene Defines the scene to register the component in
  76305. */
  76306. constructor(scene: Scene);
  76307. /**
  76308. * Registers the component in a given scene
  76309. */
  76310. register(): void;
  76311. /**
  76312. * Rebuilds the elements related to this component in case of
  76313. * context lost for instance.
  76314. */
  76315. rebuild(): void;
  76316. /**
  76317. * Disposes the component and the associated ressources
  76318. */
  76319. dispose(): void;
  76320. private _gatherRenderTargets;
  76321. private _gatherActiveCameraRenderTargets;
  76322. }
  76323. }
  76324. declare module BABYLON {
  76325. interface AbstractScene {
  76326. /** @hidden (Backing field) */
  76327. _prePassRenderer: Nullable<PrePassRenderer>;
  76328. /**
  76329. * Gets or Sets the current prepass renderer associated to the scene.
  76330. */
  76331. prePassRenderer: Nullable<PrePassRenderer>;
  76332. /**
  76333. * Enables the prepass and associates it with the scene
  76334. * @returns the PrePassRenderer
  76335. */
  76336. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76337. /**
  76338. * Disables the prepass associated with the scene
  76339. */
  76340. disablePrePassRenderer(): void;
  76341. }
  76342. /**
  76343. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76344. * in several rendering techniques.
  76345. */
  76346. export class PrePassRendererSceneComponent implements ISceneComponent {
  76347. /**
  76348. * The component name helpful to identify the component in the list of scene components.
  76349. */
  76350. readonly name: string;
  76351. /**
  76352. * The scene the component belongs to.
  76353. */
  76354. scene: Scene;
  76355. /**
  76356. * Creates a new instance of the component for the given scene
  76357. * @param scene Defines the scene to register the component in
  76358. */
  76359. constructor(scene: Scene);
  76360. /**
  76361. * Registers the component in a given scene
  76362. */
  76363. register(): void;
  76364. private _beforeCameraDraw;
  76365. private _afterCameraDraw;
  76366. private _beforeClearStage;
  76367. private _beforeRenderingMeshStage;
  76368. private _afterRenderingMeshStage;
  76369. /**
  76370. * Rebuilds the elements related to this component in case of
  76371. * context lost for instance.
  76372. */
  76373. rebuild(): void;
  76374. /**
  76375. * Disposes the component and the associated ressources
  76376. */
  76377. dispose(): void;
  76378. }
  76379. }
  76380. declare module BABYLON {
  76381. /** @hidden */
  76382. export var fibonacci: {
  76383. name: string;
  76384. shader: string;
  76385. };
  76386. }
  76387. declare module BABYLON {
  76388. /** @hidden */
  76389. export var diffusionProfile: {
  76390. name: string;
  76391. shader: string;
  76392. };
  76393. }
  76394. declare module BABYLON {
  76395. /** @hidden */
  76396. export var subSurfaceScatteringPixelShader: {
  76397. name: string;
  76398. shader: string;
  76399. };
  76400. }
  76401. declare module BABYLON {
  76402. /**
  76403. * Sub surface scattering post process
  76404. */
  76405. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76406. /**
  76407. * Gets a string identifying the name of the class
  76408. * @returns "SubSurfaceScatteringPostProcess" string
  76409. */
  76410. getClassName(): string;
  76411. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76412. }
  76413. }
  76414. declare module BABYLON {
  76415. /**
  76416. * Contains all parameters needed for the prepass to perform
  76417. * screen space subsurface scattering
  76418. */
  76419. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76420. /** @hidden */
  76421. static _SceneComponentInitialization: (scene: Scene) => void;
  76422. private _ssDiffusionS;
  76423. private _ssFilterRadii;
  76424. private _ssDiffusionD;
  76425. /**
  76426. * Post process to attach for screen space subsurface scattering
  76427. */
  76428. postProcess: SubSurfaceScatteringPostProcess;
  76429. /**
  76430. * Diffusion profile color for subsurface scattering
  76431. */
  76432. get ssDiffusionS(): number[];
  76433. /**
  76434. * Diffusion profile max color channel value for subsurface scattering
  76435. */
  76436. get ssDiffusionD(): number[];
  76437. /**
  76438. * Diffusion profile filter radius for subsurface scattering
  76439. */
  76440. get ssFilterRadii(): number[];
  76441. /**
  76442. * Is subsurface enabled
  76443. */
  76444. enabled: boolean;
  76445. /**
  76446. * Name of the configuration
  76447. */
  76448. name: string;
  76449. /**
  76450. * Diffusion profile colors for subsurface scattering
  76451. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76452. * See ...
  76453. * Note that you can only store up to 5 of them
  76454. */
  76455. ssDiffusionProfileColors: Color3[];
  76456. /**
  76457. * Defines the ratio real world => scene units.
  76458. * Used for subsurface scattering
  76459. */
  76460. metersPerUnit: number;
  76461. /**
  76462. * Textures that should be present in the MRT for this effect to work
  76463. */
  76464. readonly texturesRequired: number[];
  76465. private _scene;
  76466. /**
  76467. * Builds a subsurface configuration object
  76468. * @param scene The scene
  76469. */
  76470. constructor(scene: Scene);
  76471. /**
  76472. * Adds a new diffusion profile.
  76473. * Useful for more realistic subsurface scattering on diverse materials.
  76474. * @param color The color of the diffusion profile. Should be the average color of the material.
  76475. * @return The index of the diffusion profile for the material subsurface configuration
  76476. */
  76477. addDiffusionProfile(color: Color3): number;
  76478. /**
  76479. * Creates the sss post process
  76480. * @return The created post process
  76481. */
  76482. createPostProcess(): SubSurfaceScatteringPostProcess;
  76483. /**
  76484. * Deletes all diffusion profiles.
  76485. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76486. */
  76487. clearAllDiffusionProfiles(): void;
  76488. /**
  76489. * Disposes this object
  76490. */
  76491. dispose(): void;
  76492. /**
  76493. * @hidden
  76494. * https://zero-radiance.github.io/post/sampling-diffusion/
  76495. *
  76496. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76497. * ------------------------------------------------------------------------------------
  76498. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76499. * PDF[r, phi, s] = r * R[r, phi, s]
  76500. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76501. * ------------------------------------------------------------------------------------
  76502. * We importance sample the color channel with the widest scattering distance.
  76503. */
  76504. getDiffusionProfileParameters(color: Color3): number;
  76505. /**
  76506. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76507. * 'u' is the random number (the value of the CDF): [0, 1).
  76508. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76509. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76510. */
  76511. private _sampleBurleyDiffusionProfile;
  76512. }
  76513. }
  76514. declare module BABYLON {
  76515. interface AbstractScene {
  76516. /** @hidden (Backing field) */
  76517. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76518. /**
  76519. * Gets or Sets the current prepass renderer associated to the scene.
  76520. */
  76521. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76522. /**
  76523. * Enables the subsurface effect for prepass
  76524. * @returns the SubSurfaceConfiguration
  76525. */
  76526. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76527. /**
  76528. * Disables the subsurface effect for prepass
  76529. */
  76530. disableSubSurfaceForPrePass(): void;
  76531. }
  76532. /**
  76533. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76534. * in several rendering techniques.
  76535. */
  76536. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76537. /**
  76538. * The component name helpful to identify the component in the list of scene components.
  76539. */
  76540. readonly name: string;
  76541. /**
  76542. * The scene the component belongs to.
  76543. */
  76544. scene: Scene;
  76545. /**
  76546. * Creates a new instance of the component for the given scene
  76547. * @param scene Defines the scene to register the component in
  76548. */
  76549. constructor(scene: Scene);
  76550. /**
  76551. * Registers the component in a given scene
  76552. */
  76553. register(): void;
  76554. /**
  76555. * Serializes the component data to the specified json object
  76556. * @param serializationObject The object to serialize to
  76557. */
  76558. serialize(serializationObject: any): void;
  76559. /**
  76560. * Adds all the elements from the container to the scene
  76561. * @param container the container holding the elements
  76562. */
  76563. addFromContainer(container: AbstractScene): void;
  76564. /**
  76565. * Removes all the elements in the container from the scene
  76566. * @param container contains the elements to remove
  76567. * @param dispose if the removed element should be disposed (default: false)
  76568. */
  76569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76570. /**
  76571. * Rebuilds the elements related to this component in case of
  76572. * context lost for instance.
  76573. */
  76574. rebuild(): void;
  76575. /**
  76576. * Disposes the component and the associated ressources
  76577. */
  76578. dispose(): void;
  76579. }
  76580. }
  76581. declare module BABYLON {
  76582. /** @hidden */
  76583. export var outlinePixelShader: {
  76584. name: string;
  76585. shader: string;
  76586. };
  76587. }
  76588. declare module BABYLON {
  76589. /** @hidden */
  76590. export var outlineVertexShader: {
  76591. name: string;
  76592. shader: string;
  76593. };
  76594. }
  76595. declare module BABYLON {
  76596. interface Scene {
  76597. /** @hidden */
  76598. _outlineRenderer: OutlineRenderer;
  76599. /**
  76600. * Gets the outline renderer associated with the scene
  76601. * @returns a OutlineRenderer
  76602. */
  76603. getOutlineRenderer(): OutlineRenderer;
  76604. }
  76605. interface AbstractMesh {
  76606. /** @hidden (Backing field) */
  76607. _renderOutline: boolean;
  76608. /**
  76609. * Gets or sets a boolean indicating if the outline must be rendered as well
  76610. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76611. */
  76612. renderOutline: boolean;
  76613. /** @hidden (Backing field) */
  76614. _renderOverlay: boolean;
  76615. /**
  76616. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76617. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76618. */
  76619. renderOverlay: boolean;
  76620. }
  76621. /**
  76622. * This class is responsible to draw bothe outline/overlay of meshes.
  76623. * It should not be used directly but through the available method on mesh.
  76624. */
  76625. export class OutlineRenderer implements ISceneComponent {
  76626. /**
  76627. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76628. */
  76629. private static _StencilReference;
  76630. /**
  76631. * The name of the component. Each component must have a unique name.
  76632. */
  76633. name: string;
  76634. /**
  76635. * The scene the component belongs to.
  76636. */
  76637. scene: Scene;
  76638. /**
  76639. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76640. */
  76641. zOffset: number;
  76642. private _engine;
  76643. private _effect;
  76644. private _cachedDefines;
  76645. private _savedDepthWrite;
  76646. /**
  76647. * Instantiates a new outline renderer. (There could be only one per scene).
  76648. * @param scene Defines the scene it belongs to
  76649. */
  76650. constructor(scene: Scene);
  76651. /**
  76652. * Register the component to one instance of a scene.
  76653. */
  76654. register(): void;
  76655. /**
  76656. * Rebuilds the elements related to this component in case of
  76657. * context lost for instance.
  76658. */
  76659. rebuild(): void;
  76660. /**
  76661. * Disposes the component and the associated ressources.
  76662. */
  76663. dispose(): void;
  76664. /**
  76665. * Renders the outline in the canvas.
  76666. * @param subMesh Defines the sumesh to render
  76667. * @param batch Defines the batch of meshes in case of instances
  76668. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76669. */
  76670. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76671. /**
  76672. * Returns whether or not the outline renderer is ready for a given submesh.
  76673. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76674. * @param subMesh Defines the submesh to check readyness for
  76675. * @param useInstances Defines wheter wee are trying to render instances or not
  76676. * @returns true if ready otherwise false
  76677. */
  76678. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76679. private _beforeRenderingMesh;
  76680. private _afterRenderingMesh;
  76681. }
  76682. }
  76683. declare module BABYLON {
  76684. /**
  76685. * Defines the basic options interface of a Sprite Frame Source Size.
  76686. */
  76687. export interface ISpriteJSONSpriteSourceSize {
  76688. /**
  76689. * number of the original width of the Frame
  76690. */
  76691. w: number;
  76692. /**
  76693. * number of the original height of the Frame
  76694. */
  76695. h: number;
  76696. }
  76697. /**
  76698. * Defines the basic options interface of a Sprite Frame Data.
  76699. */
  76700. export interface ISpriteJSONSpriteFrameData {
  76701. /**
  76702. * number of the x offset of the Frame
  76703. */
  76704. x: number;
  76705. /**
  76706. * number of the y offset of the Frame
  76707. */
  76708. y: number;
  76709. /**
  76710. * number of the width of the Frame
  76711. */
  76712. w: number;
  76713. /**
  76714. * number of the height of the Frame
  76715. */
  76716. h: number;
  76717. }
  76718. /**
  76719. * Defines the basic options interface of a JSON Sprite.
  76720. */
  76721. export interface ISpriteJSONSprite {
  76722. /**
  76723. * string name of the Frame
  76724. */
  76725. filename: string;
  76726. /**
  76727. * ISpriteJSONSpriteFrame basic object of the frame data
  76728. */
  76729. frame: ISpriteJSONSpriteFrameData;
  76730. /**
  76731. * boolean to flag is the frame was rotated.
  76732. */
  76733. rotated: boolean;
  76734. /**
  76735. * boolean to flag is the frame was trimmed.
  76736. */
  76737. trimmed: boolean;
  76738. /**
  76739. * ISpriteJSONSpriteFrame basic object of the source data
  76740. */
  76741. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76742. /**
  76743. * ISpriteJSONSpriteFrame basic object of the source data
  76744. */
  76745. sourceSize: ISpriteJSONSpriteSourceSize;
  76746. }
  76747. /**
  76748. * Defines the basic options interface of a JSON atlas.
  76749. */
  76750. export interface ISpriteJSONAtlas {
  76751. /**
  76752. * Array of objects that contain the frame data.
  76753. */
  76754. frames: Array<ISpriteJSONSprite>;
  76755. /**
  76756. * object basic object containing the sprite meta data.
  76757. */
  76758. meta?: object;
  76759. }
  76760. }
  76761. declare module BABYLON {
  76762. /** @hidden */
  76763. export var spriteMapPixelShader: {
  76764. name: string;
  76765. shader: string;
  76766. };
  76767. }
  76768. declare module BABYLON {
  76769. /** @hidden */
  76770. export var spriteMapVertexShader: {
  76771. name: string;
  76772. shader: string;
  76773. };
  76774. }
  76775. declare module BABYLON {
  76776. /**
  76777. * Defines the basic options interface of a SpriteMap
  76778. */
  76779. export interface ISpriteMapOptions {
  76780. /**
  76781. * Vector2 of the number of cells in the grid.
  76782. */
  76783. stageSize?: Vector2;
  76784. /**
  76785. * Vector2 of the size of the output plane in World Units.
  76786. */
  76787. outputSize?: Vector2;
  76788. /**
  76789. * Vector3 of the position of the output plane in World Units.
  76790. */
  76791. outputPosition?: Vector3;
  76792. /**
  76793. * Vector3 of the rotation of the output plane.
  76794. */
  76795. outputRotation?: Vector3;
  76796. /**
  76797. * number of layers that the system will reserve in resources.
  76798. */
  76799. layerCount?: number;
  76800. /**
  76801. * number of max animation frames a single cell will reserve in resources.
  76802. */
  76803. maxAnimationFrames?: number;
  76804. /**
  76805. * number cell index of the base tile when the system compiles.
  76806. */
  76807. baseTile?: number;
  76808. /**
  76809. * boolean flip the sprite after its been repositioned by the framing data.
  76810. */
  76811. flipU?: boolean;
  76812. /**
  76813. * Vector3 scalar of the global RGB values of the SpriteMap.
  76814. */
  76815. colorMultiply?: Vector3;
  76816. }
  76817. /**
  76818. * Defines the IDisposable interface in order to be cleanable from resources.
  76819. */
  76820. export interface ISpriteMap extends IDisposable {
  76821. /**
  76822. * String name of the SpriteMap.
  76823. */
  76824. name: string;
  76825. /**
  76826. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76827. */
  76828. atlasJSON: ISpriteJSONAtlas;
  76829. /**
  76830. * Texture of the SpriteMap.
  76831. */
  76832. spriteSheet: Texture;
  76833. /**
  76834. * The parameters to initialize the SpriteMap with.
  76835. */
  76836. options: ISpriteMapOptions;
  76837. }
  76838. /**
  76839. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76840. */
  76841. export class SpriteMap implements ISpriteMap {
  76842. /** The Name of the spriteMap */
  76843. name: string;
  76844. /** The JSON file with the frame and meta data */
  76845. atlasJSON: ISpriteJSONAtlas;
  76846. /** The systems Sprite Sheet Texture */
  76847. spriteSheet: Texture;
  76848. /** Arguments passed with the Constructor */
  76849. options: ISpriteMapOptions;
  76850. /** Public Sprite Storage array, parsed from atlasJSON */
  76851. sprites: Array<ISpriteJSONSprite>;
  76852. /** Returns the Number of Sprites in the System */
  76853. get spriteCount(): number;
  76854. /** Returns the Position of Output Plane*/
  76855. get position(): Vector3;
  76856. /** Returns the Position of Output Plane*/
  76857. set position(v: Vector3);
  76858. /** Returns the Rotation of Output Plane*/
  76859. get rotation(): Vector3;
  76860. /** Returns the Rotation of Output Plane*/
  76861. set rotation(v: Vector3);
  76862. /** Sets the AnimationMap*/
  76863. get animationMap(): RawTexture;
  76864. /** Sets the AnimationMap*/
  76865. set animationMap(v: RawTexture);
  76866. /** Scene that the SpriteMap was created in */
  76867. private _scene;
  76868. /** Texture Buffer of Float32 that holds tile frame data*/
  76869. private _frameMap;
  76870. /** Texture Buffers of Float32 that holds tileMap data*/
  76871. private _tileMaps;
  76872. /** Texture Buffer of Float32 that holds Animation Data*/
  76873. private _animationMap;
  76874. /** Custom ShaderMaterial Central to the System*/
  76875. private _material;
  76876. /** Custom ShaderMaterial Central to the System*/
  76877. private _output;
  76878. /** Systems Time Ticker*/
  76879. private _time;
  76880. /**
  76881. * Creates a new SpriteMap
  76882. * @param name defines the SpriteMaps Name
  76883. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76884. * @param spriteSheet is the Texture that the Sprites are on.
  76885. * @param options a basic deployment configuration
  76886. * @param scene The Scene that the map is deployed on
  76887. */
  76888. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76889. /**
  76890. * Returns tileID location
  76891. * @returns Vector2 the cell position ID
  76892. */
  76893. getTileID(): Vector2;
  76894. /**
  76895. * Gets the UV location of the mouse over the SpriteMap.
  76896. * @returns Vector2 the UV position of the mouse interaction
  76897. */
  76898. getMousePosition(): Vector2;
  76899. /**
  76900. * Creates the "frame" texture Buffer
  76901. * -------------------------------------
  76902. * Structure of frames
  76903. * "filename": "Falling-Water-2.png",
  76904. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76905. * "rotated": true,
  76906. * "trimmed": true,
  76907. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76908. * "sourceSize": {"w":32,"h":32}
  76909. * @returns RawTexture of the frameMap
  76910. */
  76911. private _createFrameBuffer;
  76912. /**
  76913. * Creates the tileMap texture Buffer
  76914. * @param buffer normally and array of numbers, or a false to generate from scratch
  76915. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76916. * @returns RawTexture of the tileMap
  76917. */
  76918. private _createTileBuffer;
  76919. /**
  76920. * Modifies the data of the tileMaps
  76921. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76922. * @param pos is the iVector2 Coordinates of the Tile
  76923. * @param tile The SpriteIndex of the new Tile
  76924. */
  76925. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76926. /**
  76927. * Creates the animationMap texture Buffer
  76928. * @param buffer normally and array of numbers, or a false to generate from scratch
  76929. * @returns RawTexture of the animationMap
  76930. */
  76931. private _createTileAnimationBuffer;
  76932. /**
  76933. * Modifies the data of the animationMap
  76934. * @param cellID is the Index of the Sprite
  76935. * @param _frame is the target Animation frame
  76936. * @param toCell is the Target Index of the next frame of the animation
  76937. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76938. * @param speed is a global scalar of the time variable on the map.
  76939. */
  76940. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76941. /**
  76942. * Exports the .tilemaps file
  76943. */
  76944. saveTileMaps(): void;
  76945. /**
  76946. * Imports the .tilemaps file
  76947. * @param url of the .tilemaps file
  76948. */
  76949. loadTileMaps(url: string): void;
  76950. /**
  76951. * Release associated resources
  76952. */
  76953. dispose(): void;
  76954. }
  76955. }
  76956. declare module BABYLON {
  76957. /**
  76958. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76959. * @see https://doc.babylonjs.com/babylon101/sprites
  76960. */
  76961. export class SpritePackedManager extends SpriteManager {
  76962. /** defines the packed manager's name */
  76963. name: string;
  76964. /**
  76965. * Creates a new sprite manager from a packed sprite sheet
  76966. * @param name defines the manager's name
  76967. * @param imgUrl defines the sprite sheet url
  76968. * @param capacity defines the maximum allowed number of sprites
  76969. * @param scene defines the hosting scene
  76970. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76971. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76972. * @param samplingMode defines the smapling mode to use with spritesheet
  76973. * @param fromPacked set to true; do not alter
  76974. */
  76975. constructor(
  76976. /** defines the packed manager's name */
  76977. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76978. }
  76979. }
  76980. declare module BABYLON {
  76981. /**
  76982. * Defines the list of states available for a task inside a AssetsManager
  76983. */
  76984. export enum AssetTaskState {
  76985. /**
  76986. * Initialization
  76987. */
  76988. INIT = 0,
  76989. /**
  76990. * Running
  76991. */
  76992. RUNNING = 1,
  76993. /**
  76994. * Done
  76995. */
  76996. DONE = 2,
  76997. /**
  76998. * Error
  76999. */
  77000. ERROR = 3
  77001. }
  77002. /**
  77003. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77004. */
  77005. export abstract class AbstractAssetTask {
  77006. /**
  77007. * Task name
  77008. */ name: string;
  77009. /**
  77010. * Callback called when the task is successful
  77011. */
  77012. onSuccess: (task: any) => void;
  77013. /**
  77014. * Callback called when the task is not successful
  77015. */
  77016. onError: (task: any, message?: string, exception?: any) => void;
  77017. /**
  77018. * Creates a new AssetsManager
  77019. * @param name defines the name of the task
  77020. */
  77021. constructor(
  77022. /**
  77023. * Task name
  77024. */ name: string);
  77025. private _isCompleted;
  77026. private _taskState;
  77027. private _errorObject;
  77028. /**
  77029. * Get if the task is completed
  77030. */
  77031. get isCompleted(): boolean;
  77032. /**
  77033. * Gets the current state of the task
  77034. */
  77035. get taskState(): AssetTaskState;
  77036. /**
  77037. * Gets the current error object (if task is in error)
  77038. */
  77039. get errorObject(): {
  77040. message?: string;
  77041. exception?: any;
  77042. };
  77043. /**
  77044. * Internal only
  77045. * @hidden
  77046. */
  77047. _setErrorObject(message?: string, exception?: any): void;
  77048. /**
  77049. * Execute the current task
  77050. * @param scene defines the scene where you want your assets to be loaded
  77051. * @param onSuccess is a callback called when the task is successfully executed
  77052. * @param onError is a callback called if an error occurs
  77053. */
  77054. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77055. /**
  77056. * Execute the current task
  77057. * @param scene defines the scene where you want your assets to be loaded
  77058. * @param onSuccess is a callback called when the task is successfully executed
  77059. * @param onError is a callback called if an error occurs
  77060. */
  77061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77062. /**
  77063. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77064. * This can be used with failed tasks that have the reason for failure fixed.
  77065. */
  77066. reset(): void;
  77067. private onErrorCallback;
  77068. private onDoneCallback;
  77069. }
  77070. /**
  77071. * Define the interface used by progress events raised during assets loading
  77072. */
  77073. export interface IAssetsProgressEvent {
  77074. /**
  77075. * Defines the number of remaining tasks to process
  77076. */
  77077. remainingCount: number;
  77078. /**
  77079. * Defines the total number of tasks
  77080. */
  77081. totalCount: number;
  77082. /**
  77083. * Defines the task that was just processed
  77084. */
  77085. task: AbstractAssetTask;
  77086. }
  77087. /**
  77088. * Class used to share progress information about assets loading
  77089. */
  77090. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77091. /**
  77092. * Defines the number of remaining tasks to process
  77093. */
  77094. remainingCount: number;
  77095. /**
  77096. * Defines the total number of tasks
  77097. */
  77098. totalCount: number;
  77099. /**
  77100. * Defines the task that was just processed
  77101. */
  77102. task: AbstractAssetTask;
  77103. /**
  77104. * Creates a AssetsProgressEvent
  77105. * @param remainingCount defines the number of remaining tasks to process
  77106. * @param totalCount defines the total number of tasks
  77107. * @param task defines the task that was just processed
  77108. */
  77109. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77110. }
  77111. /**
  77112. * Define a task used by AssetsManager to load assets into a container
  77113. */
  77114. export class ContainerAssetTask extends AbstractAssetTask {
  77115. /**
  77116. * Defines the name of the task
  77117. */
  77118. name: string;
  77119. /**
  77120. * Defines the list of mesh's names you want to load
  77121. */
  77122. meshesNames: any;
  77123. /**
  77124. * Defines the root url to use as a base to load your meshes and associated resources
  77125. */
  77126. rootUrl: string;
  77127. /**
  77128. * Defines the filename or File of the scene to load from
  77129. */
  77130. sceneFilename: string | File;
  77131. /**
  77132. * Get the loaded asset container
  77133. */
  77134. loadedContainer: AssetContainer;
  77135. /**
  77136. * Gets the list of loaded meshes
  77137. */
  77138. loadedMeshes: Array<AbstractMesh>;
  77139. /**
  77140. * Gets the list of loaded particle systems
  77141. */
  77142. loadedParticleSystems: Array<IParticleSystem>;
  77143. /**
  77144. * Gets the list of loaded skeletons
  77145. */
  77146. loadedSkeletons: Array<Skeleton>;
  77147. /**
  77148. * Gets the list of loaded animation groups
  77149. */
  77150. loadedAnimationGroups: Array<AnimationGroup>;
  77151. /**
  77152. * Callback called when the task is successful
  77153. */
  77154. onSuccess: (task: ContainerAssetTask) => void;
  77155. /**
  77156. * Callback called when the task is successful
  77157. */
  77158. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77159. /**
  77160. * Creates a new ContainerAssetTask
  77161. * @param name defines the name of the task
  77162. * @param meshesNames defines the list of mesh's names you want to load
  77163. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77164. * @param sceneFilename defines the filename or File of the scene to load from
  77165. */
  77166. constructor(
  77167. /**
  77168. * Defines the name of the task
  77169. */
  77170. name: string,
  77171. /**
  77172. * Defines the list of mesh's names you want to load
  77173. */
  77174. meshesNames: any,
  77175. /**
  77176. * Defines the root url to use as a base to load your meshes and associated resources
  77177. */
  77178. rootUrl: string,
  77179. /**
  77180. * Defines the filename or File of the scene to load from
  77181. */
  77182. sceneFilename: string | File);
  77183. /**
  77184. * Execute the current task
  77185. * @param scene defines the scene where you want your assets to be loaded
  77186. * @param onSuccess is a callback called when the task is successfully executed
  77187. * @param onError is a callback called if an error occurs
  77188. */
  77189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77190. }
  77191. /**
  77192. * Define a task used by AssetsManager to load meshes
  77193. */
  77194. export class MeshAssetTask extends AbstractAssetTask {
  77195. /**
  77196. * Defines the name of the task
  77197. */
  77198. name: string;
  77199. /**
  77200. * Defines the list of mesh's names you want to load
  77201. */
  77202. meshesNames: any;
  77203. /**
  77204. * Defines the root url to use as a base to load your meshes and associated resources
  77205. */
  77206. rootUrl: string;
  77207. /**
  77208. * Defines the filename or File of the scene to load from
  77209. */
  77210. sceneFilename: string | File;
  77211. /**
  77212. * Gets the list of loaded meshes
  77213. */
  77214. loadedMeshes: Array<AbstractMesh>;
  77215. /**
  77216. * Gets the list of loaded particle systems
  77217. */
  77218. loadedParticleSystems: Array<IParticleSystem>;
  77219. /**
  77220. * Gets the list of loaded skeletons
  77221. */
  77222. loadedSkeletons: Array<Skeleton>;
  77223. /**
  77224. * Gets the list of loaded animation groups
  77225. */
  77226. loadedAnimationGroups: Array<AnimationGroup>;
  77227. /**
  77228. * Callback called when the task is successful
  77229. */
  77230. onSuccess: (task: MeshAssetTask) => void;
  77231. /**
  77232. * Callback called when the task is successful
  77233. */
  77234. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77235. /**
  77236. * Creates a new MeshAssetTask
  77237. * @param name defines the name of the task
  77238. * @param meshesNames defines the list of mesh's names you want to load
  77239. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77240. * @param sceneFilename defines the filename or File of the scene to load from
  77241. */
  77242. constructor(
  77243. /**
  77244. * Defines the name of the task
  77245. */
  77246. name: string,
  77247. /**
  77248. * Defines the list of mesh's names you want to load
  77249. */
  77250. meshesNames: any,
  77251. /**
  77252. * Defines the root url to use as a base to load your meshes and associated resources
  77253. */
  77254. rootUrl: string,
  77255. /**
  77256. * Defines the filename or File of the scene to load from
  77257. */
  77258. sceneFilename: string | File);
  77259. /**
  77260. * Execute the current task
  77261. * @param scene defines the scene where you want your assets to be loaded
  77262. * @param onSuccess is a callback called when the task is successfully executed
  77263. * @param onError is a callback called if an error occurs
  77264. */
  77265. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77266. }
  77267. /**
  77268. * Define a task used by AssetsManager to load text content
  77269. */
  77270. export class TextFileAssetTask extends AbstractAssetTask {
  77271. /**
  77272. * Defines the name of the task
  77273. */
  77274. name: string;
  77275. /**
  77276. * Defines the location of the file to load
  77277. */
  77278. url: string;
  77279. /**
  77280. * Gets the loaded text string
  77281. */
  77282. text: string;
  77283. /**
  77284. * Callback called when the task is successful
  77285. */
  77286. onSuccess: (task: TextFileAssetTask) => void;
  77287. /**
  77288. * Callback called when the task is successful
  77289. */
  77290. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77291. /**
  77292. * Creates a new TextFileAssetTask object
  77293. * @param name defines the name of the task
  77294. * @param url defines the location of the file to load
  77295. */
  77296. constructor(
  77297. /**
  77298. * Defines the name of the task
  77299. */
  77300. name: string,
  77301. /**
  77302. * Defines the location of the file to load
  77303. */
  77304. url: string);
  77305. /**
  77306. * Execute the current task
  77307. * @param scene defines the scene where you want your assets to be loaded
  77308. * @param onSuccess is a callback called when the task is successfully executed
  77309. * @param onError is a callback called if an error occurs
  77310. */
  77311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77312. }
  77313. /**
  77314. * Define a task used by AssetsManager to load binary data
  77315. */
  77316. export class BinaryFileAssetTask extends AbstractAssetTask {
  77317. /**
  77318. * Defines the name of the task
  77319. */
  77320. name: string;
  77321. /**
  77322. * Defines the location of the file to load
  77323. */
  77324. url: string;
  77325. /**
  77326. * Gets the lodaded data (as an array buffer)
  77327. */
  77328. data: ArrayBuffer;
  77329. /**
  77330. * Callback called when the task is successful
  77331. */
  77332. onSuccess: (task: BinaryFileAssetTask) => void;
  77333. /**
  77334. * Callback called when the task is successful
  77335. */
  77336. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77337. /**
  77338. * Creates a new BinaryFileAssetTask object
  77339. * @param name defines the name of the new task
  77340. * @param url defines the location of the file to load
  77341. */
  77342. constructor(
  77343. /**
  77344. * Defines the name of the task
  77345. */
  77346. name: string,
  77347. /**
  77348. * Defines the location of the file to load
  77349. */
  77350. url: string);
  77351. /**
  77352. * Execute the current task
  77353. * @param scene defines the scene where you want your assets to be loaded
  77354. * @param onSuccess is a callback called when the task is successfully executed
  77355. * @param onError is a callback called if an error occurs
  77356. */
  77357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77358. }
  77359. /**
  77360. * Define a task used by AssetsManager to load images
  77361. */
  77362. export class ImageAssetTask extends AbstractAssetTask {
  77363. /**
  77364. * Defines the name of the task
  77365. */
  77366. name: string;
  77367. /**
  77368. * Defines the location of the image to load
  77369. */
  77370. url: string;
  77371. /**
  77372. * Gets the loaded images
  77373. */
  77374. image: HTMLImageElement;
  77375. /**
  77376. * Callback called when the task is successful
  77377. */
  77378. onSuccess: (task: ImageAssetTask) => void;
  77379. /**
  77380. * Callback called when the task is successful
  77381. */
  77382. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77383. /**
  77384. * Creates a new ImageAssetTask
  77385. * @param name defines the name of the task
  77386. * @param url defines the location of the image to load
  77387. */
  77388. constructor(
  77389. /**
  77390. * Defines the name of the task
  77391. */
  77392. name: string,
  77393. /**
  77394. * Defines the location of the image to load
  77395. */
  77396. url: string);
  77397. /**
  77398. * Execute the current task
  77399. * @param scene defines the scene where you want your assets to be loaded
  77400. * @param onSuccess is a callback called when the task is successfully executed
  77401. * @param onError is a callback called if an error occurs
  77402. */
  77403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77404. }
  77405. /**
  77406. * Defines the interface used by texture loading tasks
  77407. */
  77408. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77409. /**
  77410. * Gets the loaded texture
  77411. */
  77412. texture: TEX;
  77413. }
  77414. /**
  77415. * Define a task used by AssetsManager to load 2D textures
  77416. */
  77417. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  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 if mipmap should not be generated (default is false)
  77428. */
  77429. noMipmap?: boolean | undefined;
  77430. /**
  77431. * Defines if texture must be inverted on Y axis (default is true)
  77432. */
  77433. invertY: boolean;
  77434. /**
  77435. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77436. */
  77437. samplingMode: number;
  77438. /**
  77439. * Gets the loaded texture
  77440. */
  77441. texture: Texture;
  77442. /**
  77443. * Callback called when the task is successful
  77444. */
  77445. onSuccess: (task: TextureAssetTask) => void;
  77446. /**
  77447. * Callback called when the task is successful
  77448. */
  77449. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77450. /**
  77451. * Creates a new TextureAssetTask object
  77452. * @param name defines the name of the task
  77453. * @param url defines the location of the file to load
  77454. * @param noMipmap defines if mipmap should not be generated (default is false)
  77455. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77456. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77457. */
  77458. constructor(
  77459. /**
  77460. * Defines the name of the task
  77461. */
  77462. name: string,
  77463. /**
  77464. * Defines the location of the file to load
  77465. */
  77466. url: string,
  77467. /**
  77468. * Defines if mipmap should not be generated (default is false)
  77469. */
  77470. noMipmap?: boolean | undefined,
  77471. /**
  77472. * Defines if texture must be inverted on Y axis (default is true)
  77473. */
  77474. invertY?: boolean,
  77475. /**
  77476. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77477. */
  77478. samplingMode?: number);
  77479. /**
  77480. * Execute the current task
  77481. * @param scene defines the scene where you want your assets to be loaded
  77482. * @param onSuccess is a callback called when the task is successfully executed
  77483. * @param onError is a callback called if an error occurs
  77484. */
  77485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77486. }
  77487. /**
  77488. * Define a task used by AssetsManager to load cube textures
  77489. */
  77490. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77491. /**
  77492. * Defines the name of the task
  77493. */
  77494. name: string;
  77495. /**
  77496. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77497. */
  77498. url: string;
  77499. /**
  77500. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77501. */
  77502. extensions?: string[] | undefined;
  77503. /**
  77504. * Defines if mipmaps should not be generated (default is false)
  77505. */
  77506. noMipmap?: boolean | undefined;
  77507. /**
  77508. * Defines the explicit list of files (undefined by default)
  77509. */
  77510. files?: string[] | undefined;
  77511. /**
  77512. * Gets the loaded texture
  77513. */
  77514. texture: CubeTexture;
  77515. /**
  77516. * Callback called when the task is successful
  77517. */
  77518. onSuccess: (task: CubeTextureAssetTask) => void;
  77519. /**
  77520. * Callback called when the task is successful
  77521. */
  77522. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77523. /**
  77524. * Creates a new CubeTextureAssetTask
  77525. * @param name defines the name of the task
  77526. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77527. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77528. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77529. * @param files defines the explicit list of files (undefined by default)
  77530. */
  77531. constructor(
  77532. /**
  77533. * Defines the name of the task
  77534. */
  77535. name: string,
  77536. /**
  77537. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77538. */
  77539. url: string,
  77540. /**
  77541. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77542. */
  77543. extensions?: string[] | undefined,
  77544. /**
  77545. * Defines if mipmaps should not be generated (default is false)
  77546. */
  77547. noMipmap?: boolean | undefined,
  77548. /**
  77549. * Defines the explicit list of files (undefined by default)
  77550. */
  77551. files?: string[] | undefined);
  77552. /**
  77553. * Execute the current task
  77554. * @param scene defines the scene where you want your assets to be loaded
  77555. * @param onSuccess is a callback called when the task is successfully executed
  77556. * @param onError is a callback called if an error occurs
  77557. */
  77558. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77559. }
  77560. /**
  77561. * Define a task used by AssetsManager to load HDR cube textures
  77562. */
  77563. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77564. /**
  77565. * Defines the name of the task
  77566. */
  77567. name: string;
  77568. /**
  77569. * Defines the location of the file to load
  77570. */
  77571. url: string;
  77572. /**
  77573. * Defines the desired size (the more it increases the longer the generation will be)
  77574. */
  77575. size: number;
  77576. /**
  77577. * Defines if mipmaps should not be generated (default is false)
  77578. */
  77579. noMipmap: boolean;
  77580. /**
  77581. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77582. */
  77583. generateHarmonics: boolean;
  77584. /**
  77585. * 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)
  77586. */
  77587. gammaSpace: boolean;
  77588. /**
  77589. * Internal Use Only
  77590. */
  77591. reserved: boolean;
  77592. /**
  77593. * Gets the loaded texture
  77594. */
  77595. texture: HDRCubeTexture;
  77596. /**
  77597. * Callback called when the task is successful
  77598. */
  77599. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77600. /**
  77601. * Callback called when the task is successful
  77602. */
  77603. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77604. /**
  77605. * Creates a new HDRCubeTextureAssetTask object
  77606. * @param name defines the name of the task
  77607. * @param url defines the location of the file to load
  77608. * @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.
  77609. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77610. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77611. * @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)
  77612. * @param reserved Internal use only
  77613. */
  77614. constructor(
  77615. /**
  77616. * Defines the name of the task
  77617. */
  77618. name: string,
  77619. /**
  77620. * Defines the location of the file to load
  77621. */
  77622. url: string,
  77623. /**
  77624. * Defines the desired size (the more it increases the longer the generation will be)
  77625. */
  77626. size: number,
  77627. /**
  77628. * Defines if mipmaps should not be generated (default is false)
  77629. */
  77630. noMipmap?: boolean,
  77631. /**
  77632. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77633. */
  77634. generateHarmonics?: boolean,
  77635. /**
  77636. * 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)
  77637. */
  77638. gammaSpace?: boolean,
  77639. /**
  77640. * Internal Use Only
  77641. */
  77642. reserved?: boolean);
  77643. /**
  77644. * Execute the current task
  77645. * @param scene defines the scene where you want your assets to be loaded
  77646. * @param onSuccess is a callback called when the task is successfully executed
  77647. * @param onError is a callback called if an error occurs
  77648. */
  77649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77650. }
  77651. /**
  77652. * Define a task used by AssetsManager to load Equirectangular cube textures
  77653. */
  77654. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77655. /**
  77656. * Defines the name of the task
  77657. */
  77658. name: string;
  77659. /**
  77660. * Defines the location of the file to load
  77661. */
  77662. url: string;
  77663. /**
  77664. * Defines the desired size (the more it increases the longer the generation will be)
  77665. */
  77666. size: number;
  77667. /**
  77668. * Defines if mipmaps should not be generated (default is false)
  77669. */
  77670. noMipmap: boolean;
  77671. /**
  77672. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77673. * but the standard material would require them in Gamma space) (default is true)
  77674. */
  77675. gammaSpace: boolean;
  77676. /**
  77677. * Gets the loaded texture
  77678. */
  77679. texture: EquiRectangularCubeTexture;
  77680. /**
  77681. * Callback called when the task is successful
  77682. */
  77683. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77684. /**
  77685. * Callback called when the task is successful
  77686. */
  77687. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77688. /**
  77689. * Creates a new EquiRectangularCubeTextureAssetTask object
  77690. * @param name defines the name of the task
  77691. * @param url defines the location of the file to load
  77692. * @param size defines the desired size (the more it increases the longer the generation will be)
  77693. * If the size is omitted this implies you are using a preprocessed cubemap.
  77694. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77695. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77696. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77697. * (default is true)
  77698. */
  77699. constructor(
  77700. /**
  77701. * Defines the name of the task
  77702. */
  77703. name: string,
  77704. /**
  77705. * Defines the location of the file to load
  77706. */
  77707. url: string,
  77708. /**
  77709. * Defines the desired size (the more it increases the longer the generation will be)
  77710. */
  77711. size: number,
  77712. /**
  77713. * Defines if mipmaps should not be generated (default is false)
  77714. */
  77715. noMipmap?: boolean,
  77716. /**
  77717. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77718. * but the standard material would require them in Gamma space) (default is true)
  77719. */
  77720. gammaSpace?: boolean);
  77721. /**
  77722. * Execute the current task
  77723. * @param scene defines the scene where you want your assets to be loaded
  77724. * @param onSuccess is a callback called when the task is successfully executed
  77725. * @param onError is a callback called if an error occurs
  77726. */
  77727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77728. }
  77729. /**
  77730. * This class can be used to easily import assets into a scene
  77731. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77732. */
  77733. export class AssetsManager {
  77734. private _scene;
  77735. private _isLoading;
  77736. protected _tasks: AbstractAssetTask[];
  77737. protected _waitingTasksCount: number;
  77738. protected _totalTasksCount: number;
  77739. /**
  77740. * Callback called when all tasks are processed
  77741. */
  77742. onFinish: (tasks: AbstractAssetTask[]) => void;
  77743. /**
  77744. * Callback called when a task is successful
  77745. */
  77746. onTaskSuccess: (task: AbstractAssetTask) => void;
  77747. /**
  77748. * Callback called when a task had an error
  77749. */
  77750. onTaskError: (task: AbstractAssetTask) => void;
  77751. /**
  77752. * Callback called when a task is done (whatever the result is)
  77753. */
  77754. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77755. /**
  77756. * Observable called when all tasks are processed
  77757. */
  77758. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77759. /**
  77760. * Observable called when a task had an error
  77761. */
  77762. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77763. /**
  77764. * Observable called when all tasks were executed
  77765. */
  77766. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77767. /**
  77768. * Observable called when a task is done (whatever the result is)
  77769. */
  77770. onProgressObservable: Observable<IAssetsProgressEvent>;
  77771. /**
  77772. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77773. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77774. */
  77775. useDefaultLoadingScreen: boolean;
  77776. /**
  77777. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77778. * when all assets have been downloaded.
  77779. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77780. */
  77781. autoHideLoadingUI: boolean;
  77782. /**
  77783. * Creates a new AssetsManager
  77784. * @param scene defines the scene to work on
  77785. */
  77786. constructor(scene: Scene);
  77787. /**
  77788. * Add a ContainerAssetTask to the list of active tasks
  77789. * @param taskName defines the name of the new task
  77790. * @param meshesNames defines the name of meshes to load
  77791. * @param rootUrl defines the root url to use to locate files
  77792. * @param sceneFilename defines the filename of the scene file
  77793. * @returns a new ContainerAssetTask object
  77794. */
  77795. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77796. /**
  77797. * Add a MeshAssetTask to the list of active tasks
  77798. * @param taskName defines the name of the new task
  77799. * @param meshesNames defines the name of meshes to load
  77800. * @param rootUrl defines the root url to use to locate files
  77801. * @param sceneFilename defines the filename of the scene file
  77802. * @returns a new MeshAssetTask object
  77803. */
  77804. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77805. /**
  77806. * Add a TextFileAssetTask to the list of active tasks
  77807. * @param taskName defines the name of the new task
  77808. * @param url defines the url of the file to load
  77809. * @returns a new TextFileAssetTask object
  77810. */
  77811. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77812. /**
  77813. * Add a BinaryFileAssetTask to the list of active tasks
  77814. * @param taskName defines the name of the new task
  77815. * @param url defines the url of the file to load
  77816. * @returns a new BinaryFileAssetTask object
  77817. */
  77818. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77819. /**
  77820. * Add a ImageAssetTask to the list of active tasks
  77821. * @param taskName defines the name of the new task
  77822. * @param url defines the url of the file to load
  77823. * @returns a new ImageAssetTask object
  77824. */
  77825. addImageTask(taskName: string, url: string): ImageAssetTask;
  77826. /**
  77827. * Add a TextureAssetTask to the list of active tasks
  77828. * @param taskName defines the name of the new task
  77829. * @param url defines the url of the file to load
  77830. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77831. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77832. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77833. * @returns a new TextureAssetTask object
  77834. */
  77835. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77836. /**
  77837. * Add a CubeTextureAssetTask to the list of active tasks
  77838. * @param taskName defines the name of the new task
  77839. * @param url defines the url of the file to load
  77840. * @param extensions defines the extension to use to load the cube map (can be null)
  77841. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77842. * @param files defines the list of files to load (can be null)
  77843. * @returns a new CubeTextureAssetTask object
  77844. */
  77845. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77846. /**
  77847. *
  77848. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77849. * @param taskName defines the name of the new task
  77850. * @param url defines the url of the file to load
  77851. * @param size defines the size you want for the cubemap (can be null)
  77852. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77853. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77854. * @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)
  77855. * @param reserved Internal use only
  77856. * @returns a new HDRCubeTextureAssetTask object
  77857. */
  77858. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77859. /**
  77860. *
  77861. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77862. * @param taskName defines the name of the new task
  77863. * @param url defines the url of the file to load
  77864. * @param size defines the size you want for the cubemap (can be null)
  77865. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77866. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77867. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77868. * @returns a new EquiRectangularCubeTextureAssetTask object
  77869. */
  77870. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77871. /**
  77872. * Remove a task from the assets manager.
  77873. * @param task the task to remove
  77874. */
  77875. removeTask(task: AbstractAssetTask): void;
  77876. private _decreaseWaitingTasksCount;
  77877. private _runTask;
  77878. /**
  77879. * Reset the AssetsManager and remove all tasks
  77880. * @return the current instance of the AssetsManager
  77881. */
  77882. reset(): AssetsManager;
  77883. /**
  77884. * Start the loading process
  77885. * @return the current instance of the AssetsManager
  77886. */
  77887. load(): AssetsManager;
  77888. /**
  77889. * Start the loading process as an async operation
  77890. * @return a promise returning the list of failed tasks
  77891. */
  77892. loadAsync(): Promise<void>;
  77893. }
  77894. }
  77895. declare module BABYLON {
  77896. /**
  77897. * Wrapper class for promise with external resolve and reject.
  77898. */
  77899. export class Deferred<T> {
  77900. /**
  77901. * The promise associated with this deferred object.
  77902. */
  77903. readonly promise: Promise<T>;
  77904. private _resolve;
  77905. private _reject;
  77906. /**
  77907. * The resolve method of the promise associated with this deferred object.
  77908. */
  77909. get resolve(): (value: T | PromiseLike<T>) => void;
  77910. /**
  77911. * The reject method of the promise associated with this deferred object.
  77912. */
  77913. get reject(): (reason?: any) => void;
  77914. /**
  77915. * Constructor for this deferred object.
  77916. */
  77917. constructor();
  77918. }
  77919. }
  77920. declare module BABYLON {
  77921. /**
  77922. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77923. */
  77924. export class MeshExploder {
  77925. private _centerMesh;
  77926. private _meshes;
  77927. private _meshesOrigins;
  77928. private _toCenterVectors;
  77929. private _scaledDirection;
  77930. private _newPosition;
  77931. private _centerPosition;
  77932. /**
  77933. * Explodes meshes from a center mesh.
  77934. * @param meshes The meshes to explode.
  77935. * @param centerMesh The mesh to be center of explosion.
  77936. */
  77937. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77938. private _setCenterMesh;
  77939. /**
  77940. * Get class name
  77941. * @returns "MeshExploder"
  77942. */
  77943. getClassName(): string;
  77944. /**
  77945. * "Exploded meshes"
  77946. * @returns Array of meshes with the centerMesh at index 0.
  77947. */
  77948. getMeshes(): Array<Mesh>;
  77949. /**
  77950. * Explodes meshes giving a specific direction
  77951. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77952. */
  77953. explode(direction?: number): void;
  77954. }
  77955. }
  77956. declare module BABYLON {
  77957. /**
  77958. * Class used to help managing file picking and drag'n'drop
  77959. */
  77960. export class FilesInput {
  77961. /**
  77962. * List of files ready to be loaded
  77963. */
  77964. static get FilesToLoad(): {
  77965. [key: string]: File;
  77966. };
  77967. /**
  77968. * Callback called when a file is processed
  77969. */
  77970. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77971. /**
  77972. * Function used when loading the scene file
  77973. */
  77974. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77975. private _engine;
  77976. private _currentScene;
  77977. private _sceneLoadedCallback;
  77978. private _progressCallback;
  77979. private _additionalRenderLoopLogicCallback;
  77980. private _textureLoadingCallback;
  77981. private _startingProcessingFilesCallback;
  77982. private _onReloadCallback;
  77983. private _errorCallback;
  77984. private _elementToMonitor;
  77985. private _sceneFileToLoad;
  77986. private _filesToLoad;
  77987. /**
  77988. * Creates a new FilesInput
  77989. * @param engine defines the rendering engine
  77990. * @param scene defines the hosting scene
  77991. * @param sceneLoadedCallback callback called when scene is loaded
  77992. * @param progressCallback callback called to track progress
  77993. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77994. * @param textureLoadingCallback callback called when a texture is loading
  77995. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77996. * @param onReloadCallback callback called when a reload is requested
  77997. * @param errorCallback callback call if an error occurs
  77998. */
  77999. 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>);
  78000. private _dragEnterHandler;
  78001. private _dragOverHandler;
  78002. private _dropHandler;
  78003. /**
  78004. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78005. * @param elementToMonitor defines the DOM element to track
  78006. */
  78007. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78008. /** Gets the current list of files to load */
  78009. get filesToLoad(): File[];
  78010. /**
  78011. * Release all associated resources
  78012. */
  78013. dispose(): void;
  78014. private renderFunction;
  78015. private drag;
  78016. private drop;
  78017. private _traverseFolder;
  78018. private _processFiles;
  78019. /**
  78020. * Load files from a drop event
  78021. * @param event defines the drop event to use as source
  78022. */
  78023. loadFiles(event: any): void;
  78024. private _processReload;
  78025. /**
  78026. * Reload the current scene from the loaded files
  78027. */
  78028. reload(): void;
  78029. }
  78030. }
  78031. declare module BABYLON {
  78032. /**
  78033. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78034. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78035. */
  78036. export class SceneOptimization {
  78037. /**
  78038. * Defines the priority of this optimization (0 by default which means first in the list)
  78039. */
  78040. priority: number;
  78041. /**
  78042. * Gets a string describing the action executed by the current optimization
  78043. * @returns description string
  78044. */
  78045. getDescription(): string;
  78046. /**
  78047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78048. * @param scene defines the current scene where to apply this optimization
  78049. * @param optimizer defines the current optimizer
  78050. * @returns true if everything that can be done was applied
  78051. */
  78052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78053. /**
  78054. * Creates the SceneOptimization object
  78055. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78056. * @param desc defines the description associated with the optimization
  78057. */
  78058. constructor(
  78059. /**
  78060. * Defines the priority of this optimization (0 by default which means first in the list)
  78061. */
  78062. priority?: number);
  78063. }
  78064. /**
  78065. * Defines an optimization used to reduce the size of render target textures
  78066. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78067. */
  78068. export class TextureOptimization extends SceneOptimization {
  78069. /**
  78070. * Defines the priority of this optimization (0 by default which means first in the list)
  78071. */
  78072. priority: number;
  78073. /**
  78074. * 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
  78075. */
  78076. maximumSize: number;
  78077. /**
  78078. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78079. */
  78080. step: number;
  78081. /**
  78082. * Gets a string describing the action executed by the current optimization
  78083. * @returns description string
  78084. */
  78085. getDescription(): string;
  78086. /**
  78087. * Creates the TextureOptimization object
  78088. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78089. * @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
  78090. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78091. */
  78092. constructor(
  78093. /**
  78094. * Defines the priority of this optimization (0 by default which means first in the list)
  78095. */
  78096. priority?: number,
  78097. /**
  78098. * 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
  78099. */
  78100. maximumSize?: number,
  78101. /**
  78102. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78103. */
  78104. step?: number);
  78105. /**
  78106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78107. * @param scene defines the current scene where to apply this optimization
  78108. * @param optimizer defines the current optimizer
  78109. * @returns true if everything that can be done was applied
  78110. */
  78111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78112. }
  78113. /**
  78114. * Defines an optimization used to increase or decrease the rendering resolution
  78115. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78116. */
  78117. export class HardwareScalingOptimization extends SceneOptimization {
  78118. /**
  78119. * Defines the priority of this optimization (0 by default which means first in the list)
  78120. */
  78121. priority: number;
  78122. /**
  78123. * Defines the maximum scale to use (2 by default)
  78124. */
  78125. maximumScale: number;
  78126. /**
  78127. * Defines the step to use between two passes (0.5 by default)
  78128. */
  78129. step: number;
  78130. private _currentScale;
  78131. private _directionOffset;
  78132. /**
  78133. * Gets a string describing the action executed by the current optimization
  78134. * @return description string
  78135. */
  78136. getDescription(): string;
  78137. /**
  78138. * Creates the HardwareScalingOptimization object
  78139. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78140. * @param maximumScale defines the maximum scale to use (2 by default)
  78141. * @param step defines the step to use between two passes (0.5 by default)
  78142. */
  78143. constructor(
  78144. /**
  78145. * Defines the priority of this optimization (0 by default which means first in the list)
  78146. */
  78147. priority?: number,
  78148. /**
  78149. * Defines the maximum scale to use (2 by default)
  78150. */
  78151. maximumScale?: number,
  78152. /**
  78153. * Defines the step to use between two passes (0.5 by default)
  78154. */
  78155. step?: number);
  78156. /**
  78157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78158. * @param scene defines the current scene where to apply this optimization
  78159. * @param optimizer defines the current optimizer
  78160. * @returns true if everything that can be done was applied
  78161. */
  78162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78163. }
  78164. /**
  78165. * Defines an optimization used to remove shadows
  78166. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78167. */
  78168. export class ShadowsOptimization extends SceneOptimization {
  78169. /**
  78170. * Gets a string describing the action executed by the current optimization
  78171. * @return description string
  78172. */
  78173. getDescription(): string;
  78174. /**
  78175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78176. * @param scene defines the current scene where to apply this optimization
  78177. * @param optimizer defines the current optimizer
  78178. * @returns true if everything that can be done was applied
  78179. */
  78180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78181. }
  78182. /**
  78183. * Defines an optimization used to turn post-processes off
  78184. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78185. */
  78186. export class PostProcessesOptimization extends SceneOptimization {
  78187. /**
  78188. * Gets a string describing the action executed by the current optimization
  78189. * @return description string
  78190. */
  78191. getDescription(): string;
  78192. /**
  78193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78194. * @param scene defines the current scene where to apply this optimization
  78195. * @param optimizer defines the current optimizer
  78196. * @returns true if everything that can be done was applied
  78197. */
  78198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78199. }
  78200. /**
  78201. * Defines an optimization used to turn lens flares off
  78202. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78203. */
  78204. export class LensFlaresOptimization extends SceneOptimization {
  78205. /**
  78206. * Gets a string describing the action executed by the current optimization
  78207. * @return description string
  78208. */
  78209. getDescription(): string;
  78210. /**
  78211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78212. * @param scene defines the current scene where to apply this optimization
  78213. * @param optimizer defines the current optimizer
  78214. * @returns true if everything that can be done was applied
  78215. */
  78216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78217. }
  78218. /**
  78219. * Defines an optimization based on user defined callback.
  78220. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78221. */
  78222. export class CustomOptimization extends SceneOptimization {
  78223. /**
  78224. * Callback called to apply the custom optimization.
  78225. */
  78226. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78227. /**
  78228. * Callback called to get custom description
  78229. */
  78230. onGetDescription: () => string;
  78231. /**
  78232. * Gets a string describing the action executed by the current optimization
  78233. * @returns description string
  78234. */
  78235. getDescription(): string;
  78236. /**
  78237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78238. * @param scene defines the current scene where to apply this optimization
  78239. * @param optimizer defines the current optimizer
  78240. * @returns true if everything that can be done was applied
  78241. */
  78242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78243. }
  78244. /**
  78245. * Defines an optimization used to turn particles off
  78246. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78247. */
  78248. export class ParticlesOptimization extends SceneOptimization {
  78249. /**
  78250. * Gets a string describing the action executed by the current optimization
  78251. * @return description string
  78252. */
  78253. getDescription(): string;
  78254. /**
  78255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78256. * @param scene defines the current scene where to apply this optimization
  78257. * @param optimizer defines the current optimizer
  78258. * @returns true if everything that can be done was applied
  78259. */
  78260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78261. }
  78262. /**
  78263. * Defines an optimization used to turn render targets off
  78264. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78265. */
  78266. export class RenderTargetsOptimization extends SceneOptimization {
  78267. /**
  78268. * Gets a string describing the action executed by the current optimization
  78269. * @return description string
  78270. */
  78271. getDescription(): string;
  78272. /**
  78273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78274. * @param scene defines the current scene where to apply this optimization
  78275. * @param optimizer defines the current optimizer
  78276. * @returns true if everything that can be done was applied
  78277. */
  78278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78279. }
  78280. /**
  78281. * Defines an optimization used to merge meshes with compatible materials
  78282. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78283. */
  78284. export class MergeMeshesOptimization extends SceneOptimization {
  78285. private static _UpdateSelectionTree;
  78286. /**
  78287. * Gets or sets a boolean which defines if optimization octree has to be updated
  78288. */
  78289. static get UpdateSelectionTree(): boolean;
  78290. /**
  78291. * Gets or sets a boolean which defines if optimization octree has to be updated
  78292. */
  78293. static set UpdateSelectionTree(value: boolean);
  78294. /**
  78295. * Gets a string describing the action executed by the current optimization
  78296. * @return description string
  78297. */
  78298. getDescription(): string;
  78299. private _canBeMerged;
  78300. /**
  78301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78302. * @param scene defines the current scene where to apply this optimization
  78303. * @param optimizer defines the current optimizer
  78304. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78305. * @returns true if everything that can be done was applied
  78306. */
  78307. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78308. }
  78309. /**
  78310. * Defines a list of options used by SceneOptimizer
  78311. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78312. */
  78313. export class SceneOptimizerOptions {
  78314. /**
  78315. * Defines the target frame rate to reach (60 by default)
  78316. */
  78317. targetFrameRate: number;
  78318. /**
  78319. * Defines the interval between two checkes (2000ms by default)
  78320. */
  78321. trackerDuration: number;
  78322. /**
  78323. * Gets the list of optimizations to apply
  78324. */
  78325. optimizations: SceneOptimization[];
  78326. /**
  78327. * Creates a new list of options used by SceneOptimizer
  78328. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78329. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78330. */
  78331. constructor(
  78332. /**
  78333. * Defines the target frame rate to reach (60 by default)
  78334. */
  78335. targetFrameRate?: number,
  78336. /**
  78337. * Defines the interval between two checkes (2000ms by default)
  78338. */
  78339. trackerDuration?: number);
  78340. /**
  78341. * Add a new optimization
  78342. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78343. * @returns the current SceneOptimizerOptions
  78344. */
  78345. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78346. /**
  78347. * Add a new custom optimization
  78348. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78349. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78350. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78351. * @returns the current SceneOptimizerOptions
  78352. */
  78353. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78354. /**
  78355. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78356. * @param targetFrameRate defines the target frame rate (60 by default)
  78357. * @returns a SceneOptimizerOptions object
  78358. */
  78359. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78360. /**
  78361. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78362. * @param targetFrameRate defines the target frame rate (60 by default)
  78363. * @returns a SceneOptimizerOptions object
  78364. */
  78365. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78366. /**
  78367. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78368. * @param targetFrameRate defines the target frame rate (60 by default)
  78369. * @returns a SceneOptimizerOptions object
  78370. */
  78371. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78372. }
  78373. /**
  78374. * Class used to run optimizations in order to reach a target frame rate
  78375. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78376. */
  78377. export class SceneOptimizer implements IDisposable {
  78378. private _isRunning;
  78379. private _options;
  78380. private _scene;
  78381. private _currentPriorityLevel;
  78382. private _targetFrameRate;
  78383. private _trackerDuration;
  78384. private _currentFrameRate;
  78385. private _sceneDisposeObserver;
  78386. private _improvementMode;
  78387. /**
  78388. * Defines an observable called when the optimizer reaches the target frame rate
  78389. */
  78390. onSuccessObservable: Observable<SceneOptimizer>;
  78391. /**
  78392. * Defines an observable called when the optimizer enables an optimization
  78393. */
  78394. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78395. /**
  78396. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78397. */
  78398. onFailureObservable: Observable<SceneOptimizer>;
  78399. /**
  78400. * Gets a boolean indicating if the optimizer is in improvement mode
  78401. */
  78402. get isInImprovementMode(): boolean;
  78403. /**
  78404. * Gets the current priority level (0 at start)
  78405. */
  78406. get currentPriorityLevel(): number;
  78407. /**
  78408. * Gets the current frame rate checked by the SceneOptimizer
  78409. */
  78410. get currentFrameRate(): number;
  78411. /**
  78412. * Gets or sets the current target frame rate (60 by default)
  78413. */
  78414. get targetFrameRate(): number;
  78415. /**
  78416. * Gets or sets the current target frame rate (60 by default)
  78417. */
  78418. set targetFrameRate(value: number);
  78419. /**
  78420. * Gets or sets the current interval between two checks (every 2000ms by default)
  78421. */
  78422. get trackerDuration(): number;
  78423. /**
  78424. * Gets or sets the current interval between two checks (every 2000ms by default)
  78425. */
  78426. set trackerDuration(value: number);
  78427. /**
  78428. * Gets the list of active optimizations
  78429. */
  78430. get optimizations(): SceneOptimization[];
  78431. /**
  78432. * Creates a new SceneOptimizer
  78433. * @param scene defines the scene to work on
  78434. * @param options defines the options to use with the SceneOptimizer
  78435. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78436. * @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)
  78437. */
  78438. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78439. /**
  78440. * Stops the current optimizer
  78441. */
  78442. stop(): void;
  78443. /**
  78444. * Reset the optimizer to initial step (current priority level = 0)
  78445. */
  78446. reset(): void;
  78447. /**
  78448. * Start the optimizer. By default it will try to reach a specific framerate
  78449. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78450. */
  78451. start(): void;
  78452. private _checkCurrentState;
  78453. /**
  78454. * Release all resources
  78455. */
  78456. dispose(): void;
  78457. /**
  78458. * Helper function to create a SceneOptimizer with one single line of code
  78459. * @param scene defines the scene to work on
  78460. * @param options defines the options to use with the SceneOptimizer
  78461. * @param onSuccess defines a callback to call on success
  78462. * @param onFailure defines a callback to call on failure
  78463. * @returns the new SceneOptimizer object
  78464. */
  78465. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78466. }
  78467. }
  78468. declare module BABYLON {
  78469. /**
  78470. * Class used to serialize a scene into a string
  78471. */
  78472. export class SceneSerializer {
  78473. /**
  78474. * Clear cache used by a previous serialization
  78475. */
  78476. static ClearCache(): void;
  78477. /**
  78478. * Serialize a scene into a JSON compatible object
  78479. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78480. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78481. * @param scene defines the scene to serialize
  78482. * @returns a JSON compatible object
  78483. */
  78484. static Serialize(scene: Scene): any;
  78485. private static _Serialize;
  78486. /**
  78487. * Serialize a scene into a JSON compatible object
  78488. * @param scene defines the scene to serialize
  78489. * @returns a JSON promise compatible object
  78490. */
  78491. static SerializeAsync(scene: Scene): Promise<any>;
  78492. private static _CollectPromises;
  78493. /**
  78494. * Serialize a mesh into a JSON compatible object
  78495. * @param toSerialize defines the mesh to serialize
  78496. * @param withParents defines if parents must be serialized as well
  78497. * @param withChildren defines if children must be serialized as well
  78498. * @returns a JSON compatible object
  78499. */
  78500. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78501. }
  78502. }
  78503. declare module BABYLON {
  78504. /**
  78505. * This represents the different options available for the video capture.
  78506. */
  78507. export interface VideoRecorderOptions {
  78508. /** Defines the mime type of the video. */
  78509. mimeType: string;
  78510. /** Defines the FPS the video should be recorded at. */
  78511. fps: number;
  78512. /** Defines the chunk size for the recording data. */
  78513. recordChunckSize: number;
  78514. /** The audio tracks to attach to the recording. */
  78515. audioTracks?: MediaStreamTrack[];
  78516. }
  78517. /**
  78518. * This can help with recording videos from BabylonJS.
  78519. * This is based on the available WebRTC functionalities of the browser.
  78520. *
  78521. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78522. */
  78523. export class VideoRecorder {
  78524. private static readonly _defaultOptions;
  78525. /**
  78526. * Returns whether or not the VideoRecorder is available in your browser.
  78527. * @param engine Defines the Babylon Engine.
  78528. * @returns true if supported otherwise false.
  78529. */
  78530. static IsSupported(engine: Engine): boolean;
  78531. private readonly _options;
  78532. private _canvas;
  78533. private _mediaRecorder;
  78534. private _recordedChunks;
  78535. private _fileName;
  78536. private _resolve;
  78537. private _reject;
  78538. /**
  78539. * True when a recording is already in progress.
  78540. */
  78541. get isRecording(): boolean;
  78542. /**
  78543. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78544. * @param engine Defines the BabylonJS Engine you wish to record.
  78545. * @param options Defines options that can be used to customize the capture.
  78546. */
  78547. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78548. /**
  78549. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78550. */
  78551. stopRecording(): void;
  78552. /**
  78553. * Starts recording the canvas for a max duration specified in parameters.
  78554. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78555. * If null no automatic download will start and you can rely on the promise to get the data back.
  78556. * @param maxDuration Defines the maximum recording time in seconds.
  78557. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78558. * @return A promise callback at the end of the recording with the video data in Blob.
  78559. */
  78560. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78561. /**
  78562. * Releases internal resources used during the recording.
  78563. */
  78564. dispose(): void;
  78565. private _handleDataAvailable;
  78566. private _handleError;
  78567. private _handleStop;
  78568. }
  78569. }
  78570. declare module BABYLON {
  78571. /**
  78572. * Class containing a set of static utilities functions for screenshots
  78573. */
  78574. export class ScreenshotTools {
  78575. /**
  78576. * Captures a screenshot of the current rendering
  78577. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78578. * @param engine defines the rendering engine
  78579. * @param camera defines the source camera
  78580. * @param size This parameter can be set to a single number or to an object with the
  78581. * following (optional) properties: precision, width, height. If a single number is passed,
  78582. * it will be used for both width and height. If an object is passed, the screenshot size
  78583. * will be derived from the parameters. The precision property is a multiplier allowing
  78584. * rendering at a higher or lower resolution
  78585. * @param successCallback defines the callback receives a single parameter which contains the
  78586. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78587. * src parameter of an <img> to display it
  78588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78589. * Check your browser for supported MIME types
  78590. * @param forceDownload force the system to download the image even if a successCallback is provided
  78591. */
  78592. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78593. /**
  78594. * Captures a screenshot of the current rendering
  78595. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78596. * @param engine defines the rendering engine
  78597. * @param camera defines the source camera
  78598. * @param size This parameter can be set to a single number or to an object with the
  78599. * following (optional) properties: precision, width, height. If a single number is passed,
  78600. * it will be used for both width and height. If an object is passed, the screenshot size
  78601. * will be derived from the parameters. The precision property is a multiplier allowing
  78602. * rendering at a higher or lower resolution
  78603. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78604. * Check your browser for supported MIME types
  78605. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78606. * to the src parameter of an <img> to display it
  78607. */
  78608. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78609. /**
  78610. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  78611. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78612. * @param engine defines the rendering engine
  78613. * @param camera defines the source camera
  78614. * @param width defines the expected width
  78615. * @param height defines the expected height
  78616. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78617. * Check your browser for supported MIME types
  78618. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78619. * to the src parameter of an <img> to display it
  78620. */
  78621. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78622. /**
  78623. * Generates an image screenshot from the specified camera.
  78624. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78625. * @param engine The engine to use for rendering
  78626. * @param camera The camera to use for rendering
  78627. * @param size This parameter can be set to a single number or to an object with the
  78628. * following (optional) properties: precision, width, height. If a single number is passed,
  78629. * it will be used for both width and height. If an object is passed, the screenshot size
  78630. * will be derived from the parameters. The precision property is a multiplier allowing
  78631. * rendering at a higher or lower resolution
  78632. * @param successCallback The callback receives a single parameter which contains the
  78633. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78634. * src parameter of an <img> to display it
  78635. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78636. * Check your browser for supported MIME types
  78637. * @param samples Texture samples (default: 1)
  78638. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78639. * @param fileName A name for for the downloaded file.
  78640. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78641. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78642. */
  78643. 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;
  78644. /**
  78645. * Generates an image screenshot from the specified camera.
  78646. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78647. * @param engine The engine to use for rendering
  78648. * @param camera The camera to use for rendering
  78649. * @param size This parameter can be set to a single number or to an object with the
  78650. * following (optional) properties: precision, width, height. If a single number is passed,
  78651. * it will be used for both width and height. If an object is passed, the screenshot size
  78652. * will be derived from the parameters. The precision property is a multiplier allowing
  78653. * rendering at a higher or lower resolution
  78654. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78655. * Check your browser for supported MIME types
  78656. * @param samples Texture samples (default: 1)
  78657. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78658. * @param fileName A name for for the downloaded file.
  78659. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78660. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78661. * to the src parameter of an <img> to display it
  78662. */
  78663. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78664. /**
  78665. * Gets height and width for screenshot size
  78666. * @private
  78667. */
  78668. private static _getScreenshotSize;
  78669. }
  78670. }
  78671. declare module BABYLON {
  78672. /**
  78673. * Interface for a data buffer
  78674. */
  78675. export interface IDataBuffer {
  78676. /**
  78677. * Reads bytes from the data buffer.
  78678. * @param byteOffset The byte offset to read
  78679. * @param byteLength The byte length to read
  78680. * @returns A promise that resolves when the bytes are read
  78681. */
  78682. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78683. /**
  78684. * The byte length of the buffer.
  78685. */
  78686. readonly byteLength: number;
  78687. }
  78688. /**
  78689. * Utility class for reading from a data buffer
  78690. */
  78691. export class DataReader {
  78692. /**
  78693. * The data buffer associated with this data reader.
  78694. */
  78695. readonly buffer: IDataBuffer;
  78696. /**
  78697. * The current byte offset from the beginning of the data buffer.
  78698. */
  78699. byteOffset: number;
  78700. private _dataView;
  78701. private _dataByteOffset;
  78702. /**
  78703. * Constructor
  78704. * @param buffer The buffer to read
  78705. */
  78706. constructor(buffer: IDataBuffer);
  78707. /**
  78708. * Loads the given byte length.
  78709. * @param byteLength The byte length to load
  78710. * @returns A promise that resolves when the load is complete
  78711. */
  78712. loadAsync(byteLength: number): Promise<void>;
  78713. /**
  78714. * Read a unsigned 32-bit integer from the currently loaded data range.
  78715. * @returns The 32-bit integer read
  78716. */
  78717. readUint32(): number;
  78718. /**
  78719. * Read a byte array from the currently loaded data range.
  78720. * @param byteLength The byte length to read
  78721. * @returns The byte array read
  78722. */
  78723. readUint8Array(byteLength: number): Uint8Array;
  78724. /**
  78725. * Read a string from the currently loaded data range.
  78726. * @param byteLength The byte length to read
  78727. * @returns The string read
  78728. */
  78729. readString(byteLength: number): string;
  78730. /**
  78731. * Skips the given byte length the currently loaded data range.
  78732. * @param byteLength The byte length to skip
  78733. */
  78734. skipBytes(byteLength: number): void;
  78735. }
  78736. }
  78737. declare module BABYLON {
  78738. /**
  78739. * Class for storing data to local storage if available or in-memory storage otherwise
  78740. */
  78741. export class DataStorage {
  78742. private static _Storage;
  78743. private static _GetStorage;
  78744. /**
  78745. * Reads a string from the data storage
  78746. * @param key The key to read
  78747. * @param defaultValue The value if the key doesn't exist
  78748. * @returns The string value
  78749. */
  78750. static ReadString(key: string, defaultValue: string): string;
  78751. /**
  78752. * Writes a string to the data storage
  78753. * @param key The key to write
  78754. * @param value The value to write
  78755. */
  78756. static WriteString(key: string, value: string): void;
  78757. /**
  78758. * Reads a boolean from the data storage
  78759. * @param key The key to read
  78760. * @param defaultValue The value if the key doesn't exist
  78761. * @returns The boolean value
  78762. */
  78763. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78764. /**
  78765. * Writes a boolean to the data storage
  78766. * @param key The key to write
  78767. * @param value The value to write
  78768. */
  78769. static WriteBoolean(key: string, value: boolean): void;
  78770. /**
  78771. * Reads a number from the data storage
  78772. * @param key The key to read
  78773. * @param defaultValue The value if the key doesn't exist
  78774. * @returns The number value
  78775. */
  78776. static ReadNumber(key: string, defaultValue: number): number;
  78777. /**
  78778. * Writes a number to the data storage
  78779. * @param key The key to write
  78780. * @param value The value to write
  78781. */
  78782. static WriteNumber(key: string, value: number): void;
  78783. }
  78784. }
  78785. declare module BABYLON {
  78786. /**
  78787. * Class used to record delta files between 2 scene states
  78788. */
  78789. export class SceneRecorder {
  78790. private _trackedScene;
  78791. private _savedJSON;
  78792. /**
  78793. * Track a given scene. This means the current scene state will be considered the original state
  78794. * @param scene defines the scene to track
  78795. */
  78796. track(scene: Scene): void;
  78797. /**
  78798. * Get the delta between current state and original state
  78799. * @returns a any containing the delta
  78800. */
  78801. getDelta(): any;
  78802. private _compareArray;
  78803. private _compareObjects;
  78804. private _compareCollections;
  78805. private static GetShadowGeneratorById;
  78806. /**
  78807. * Apply a given delta to a given scene
  78808. * @param deltaJSON defines the JSON containing the delta
  78809. * @param scene defines the scene to apply the delta to
  78810. */
  78811. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78812. private static _ApplyPropertiesToEntity;
  78813. private static _ApplyDeltaForEntity;
  78814. }
  78815. }
  78816. declare module BABYLON {
  78817. /**
  78818. * A 3D trajectory consisting of an order list of vectors describing a
  78819. * path of motion through 3D space.
  78820. */
  78821. export class Trajectory {
  78822. private _points;
  78823. private readonly _segmentLength;
  78824. /**
  78825. * Serialize to JSON.
  78826. * @returns serialized JSON string
  78827. */
  78828. serialize(): string;
  78829. /**
  78830. * Deserialize from JSON.
  78831. * @param json serialized JSON string
  78832. * @returns deserialized Trajectory
  78833. */
  78834. static Deserialize(json: string): Trajectory;
  78835. /**
  78836. * Create a new empty Trajectory.
  78837. * @param segmentLength radius of discretization for Trajectory points
  78838. */
  78839. constructor(segmentLength?: number);
  78840. /**
  78841. * Get the length of the Trajectory.
  78842. * @returns length of the Trajectory
  78843. */
  78844. getLength(): number;
  78845. /**
  78846. * Append a new point to the Trajectory.
  78847. * NOTE: This implementation has many allocations.
  78848. * @param point point to append to the Trajectory
  78849. */
  78850. add(point: DeepImmutable<Vector3>): void;
  78851. /**
  78852. * Create a new Trajectory with a segment length chosen to make it
  78853. * probable that the new Trajectory will have a specified number of
  78854. * segments. This operation is imprecise.
  78855. * @param targetResolution number of segments desired
  78856. * @returns new Trajectory with approximately the requested number of segments
  78857. */
  78858. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78859. /**
  78860. * Convert Trajectory segments into tokenized representation. This
  78861. * representation is an array of numbers where each nth number is the
  78862. * index of the token which is most similar to the nth segment of the
  78863. * Trajectory.
  78864. * @param tokens list of vectors which serve as discrete tokens
  78865. * @returns list of indices of most similar token per segment
  78866. */
  78867. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78868. private static _forwardDir;
  78869. private static _inverseFromVec;
  78870. private static _upDir;
  78871. private static _fromToVec;
  78872. private static _lookMatrix;
  78873. /**
  78874. * Transform the rotation (i.e., direction) of a segment to isolate
  78875. * the relative transformation represented by the segment. This operation
  78876. * may or may not succeed due to singularities in the equations that define
  78877. * motion relativity in this context.
  78878. * @param priorVec the origin of the prior segment
  78879. * @param fromVec the origin of the current segment
  78880. * @param toVec the destination of the current segment
  78881. * @param result reference to output variable
  78882. * @returns whether or not transformation was successful
  78883. */
  78884. private static _transformSegmentDirToRef;
  78885. private static _bestMatch;
  78886. private static _score;
  78887. private static _bestScore;
  78888. /**
  78889. * Determine which token vector is most similar to the
  78890. * segment vector.
  78891. * @param segment segment vector
  78892. * @param tokens token vector list
  78893. * @returns index of the most similar token to the segment
  78894. */
  78895. private static _tokenizeSegment;
  78896. }
  78897. /**
  78898. * Class representing a set of known, named trajectories to which Trajectories can be
  78899. * added and using which Trajectories can be recognized.
  78900. */
  78901. export class TrajectoryClassifier {
  78902. private _maximumAllowableMatchCost;
  78903. private _vector3Alphabet;
  78904. private _levenshteinAlphabet;
  78905. private _nameToDescribedTrajectory;
  78906. /**
  78907. * Serialize to JSON.
  78908. * @returns JSON serialization
  78909. */
  78910. serialize(): string;
  78911. /**
  78912. * Deserialize from JSON.
  78913. * @param json JSON serialization
  78914. * @returns deserialized TrajectorySet
  78915. */
  78916. static Deserialize(json: string): TrajectoryClassifier;
  78917. /**
  78918. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78919. * VERY naive, need to be generating these things from known
  78920. * sets. Better version later, probably eliminating this one.
  78921. * @returns auto-generated TrajectorySet
  78922. */
  78923. static Generate(): TrajectoryClassifier;
  78924. private constructor();
  78925. /**
  78926. * Add a new Trajectory to the set with a given name.
  78927. * @param trajectory new Trajectory to be added
  78928. * @param classification name to which to add the Trajectory
  78929. */
  78930. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78931. /**
  78932. * Remove a known named trajectory and all Trajectories associated with it.
  78933. * @param classification name to remove
  78934. * @returns whether anything was removed
  78935. */
  78936. deleteClassification(classification: string): boolean;
  78937. /**
  78938. * Attempt to recognize a Trajectory from among all the classifications
  78939. * already known to the classifier.
  78940. * @param trajectory Trajectory to be recognized
  78941. * @returns classification of Trajectory if recognized, null otherwise
  78942. */
  78943. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78944. }
  78945. }
  78946. declare module BABYLON {
  78947. /**
  78948. * An interface for all Hit test features
  78949. */
  78950. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78951. /**
  78952. * Triggered when new babylon (transformed) hit test results are available
  78953. */
  78954. onHitTestResultObservable: Observable<T[]>;
  78955. }
  78956. /**
  78957. * Options used for hit testing
  78958. */
  78959. export interface IWebXRLegacyHitTestOptions {
  78960. /**
  78961. * Only test when user interacted with the scene. Default - hit test every frame
  78962. */
  78963. testOnPointerDownOnly?: boolean;
  78964. /**
  78965. * The node to use to transform the local results to world coordinates
  78966. */
  78967. worldParentNode?: TransformNode;
  78968. }
  78969. /**
  78970. * Interface defining the babylon result of raycasting/hit-test
  78971. */
  78972. export interface IWebXRLegacyHitResult {
  78973. /**
  78974. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78975. */
  78976. transformationMatrix: Matrix;
  78977. /**
  78978. * The native hit test result
  78979. */
  78980. xrHitResult: XRHitResult | XRHitTestResult;
  78981. }
  78982. /**
  78983. * The currently-working hit-test module.
  78984. * Hit test (or Ray-casting) is used to interact with the real world.
  78985. * For further information read here - https://github.com/immersive-web/hit-test
  78986. */
  78987. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78988. /**
  78989. * options to use when constructing this feature
  78990. */
  78991. readonly options: IWebXRLegacyHitTestOptions;
  78992. private _direction;
  78993. private _mat;
  78994. private _onSelectEnabled;
  78995. private _origin;
  78996. /**
  78997. * The module's name
  78998. */
  78999. static readonly Name: string;
  79000. /**
  79001. * The (Babylon) version of this module.
  79002. * This is an integer representing the implementation version.
  79003. * This number does not correspond to the WebXR specs version
  79004. */
  79005. static readonly Version: number;
  79006. /**
  79007. * Populated with the last native XR Hit Results
  79008. */
  79009. lastNativeXRHitResults: XRHitResult[];
  79010. /**
  79011. * Triggered when new babylon (transformed) hit test results are available
  79012. */
  79013. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79014. /**
  79015. * Creates a new instance of the (legacy version) hit test feature
  79016. * @param _xrSessionManager an instance of WebXRSessionManager
  79017. * @param options options to use when constructing this feature
  79018. */
  79019. constructor(_xrSessionManager: WebXRSessionManager,
  79020. /**
  79021. * options to use when constructing this feature
  79022. */
  79023. options?: IWebXRLegacyHitTestOptions);
  79024. /**
  79025. * execute a hit test with an XR Ray
  79026. *
  79027. * @param xrSession a native xrSession that will execute this hit test
  79028. * @param xrRay the ray (position and direction) to use for ray-casting
  79029. * @param referenceSpace native XR reference space to use for the hit-test
  79030. * @param filter filter function that will filter the results
  79031. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79032. */
  79033. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79034. /**
  79035. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79036. * @param event the (select) event to use to select with
  79037. * @param referenceSpace the reference space to use for this hit test
  79038. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79039. */
  79040. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79041. /**
  79042. * attach this feature
  79043. * Will usually be called by the features manager
  79044. *
  79045. * @returns true if successful.
  79046. */
  79047. attach(): boolean;
  79048. /**
  79049. * detach this feature.
  79050. * Will usually be called by the features manager
  79051. *
  79052. * @returns true if successful.
  79053. */
  79054. detach(): boolean;
  79055. /**
  79056. * Dispose this feature and all of the resources attached
  79057. */
  79058. dispose(): void;
  79059. protected _onXRFrame(frame: XRFrame): void;
  79060. private _onHitTestResults;
  79061. private _onSelect;
  79062. }
  79063. }
  79064. declare module BABYLON {
  79065. /**
  79066. * Options used for hit testing (version 2)
  79067. */
  79068. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79069. /**
  79070. * Do not create a permanent hit test. Will usually be used when only
  79071. * transient inputs are needed.
  79072. */
  79073. disablePermanentHitTest?: boolean;
  79074. /**
  79075. * Enable transient (for example touch-based) hit test inspections
  79076. */
  79077. enableTransientHitTest?: boolean;
  79078. /**
  79079. * Offset ray for the permanent hit test
  79080. */
  79081. offsetRay?: Vector3;
  79082. /**
  79083. * Offset ray for the transient hit test
  79084. */
  79085. transientOffsetRay?: Vector3;
  79086. /**
  79087. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79088. */
  79089. useReferenceSpace?: boolean;
  79090. /**
  79091. * Override the default entity type(s) of the hit-test result
  79092. */
  79093. entityTypes?: XRHitTestTrackableType[];
  79094. }
  79095. /**
  79096. * Interface defining the babylon result of hit-test
  79097. */
  79098. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79099. /**
  79100. * The input source that generated this hit test (if transient)
  79101. */
  79102. inputSource?: XRInputSource;
  79103. /**
  79104. * Is this a transient hit test
  79105. */
  79106. isTransient?: boolean;
  79107. /**
  79108. * Position of the hit test result
  79109. */
  79110. position: Vector3;
  79111. /**
  79112. * Rotation of the hit test result
  79113. */
  79114. rotationQuaternion: Quaternion;
  79115. /**
  79116. * The native hit test result
  79117. */
  79118. xrHitResult: XRHitTestResult;
  79119. }
  79120. /**
  79121. * The currently-working hit-test module.
  79122. * Hit test (or Ray-casting) is used to interact with the real world.
  79123. * For further information read here - https://github.com/immersive-web/hit-test
  79124. *
  79125. * Tested on chrome (mobile) 80.
  79126. */
  79127. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79128. /**
  79129. * options to use when constructing this feature
  79130. */
  79131. readonly options: IWebXRHitTestOptions;
  79132. private _tmpMat;
  79133. private _tmpPos;
  79134. private _tmpQuat;
  79135. private _transientXrHitTestSource;
  79136. private _xrHitTestSource;
  79137. private initHitTestSource;
  79138. /**
  79139. * The module's name
  79140. */
  79141. static readonly Name: string;
  79142. /**
  79143. * The (Babylon) version of this module.
  79144. * This is an integer representing the implementation version.
  79145. * This number does not correspond to the WebXR specs version
  79146. */
  79147. static readonly Version: number;
  79148. /**
  79149. * When set to true, each hit test will have its own position/rotation objects
  79150. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79151. * the developers will clone them or copy them as they see fit.
  79152. */
  79153. autoCloneTransformation: boolean;
  79154. /**
  79155. * Triggered when new babylon (transformed) hit test results are available
  79156. * Note - this will be called when results come back from the device. It can be an empty array!!
  79157. */
  79158. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79159. /**
  79160. * Use this to temporarily pause hit test checks.
  79161. */
  79162. paused: boolean;
  79163. /**
  79164. * Creates a new instance of the hit test feature
  79165. * @param _xrSessionManager an instance of WebXRSessionManager
  79166. * @param options options to use when constructing this feature
  79167. */
  79168. constructor(_xrSessionManager: WebXRSessionManager,
  79169. /**
  79170. * options to use when constructing this feature
  79171. */
  79172. options?: IWebXRHitTestOptions);
  79173. /**
  79174. * attach this feature
  79175. * Will usually be called by the features manager
  79176. *
  79177. * @returns true if successful.
  79178. */
  79179. attach(): boolean;
  79180. /**
  79181. * detach this feature.
  79182. * Will usually be called by the features manager
  79183. *
  79184. * @returns true if successful.
  79185. */
  79186. detach(): boolean;
  79187. /**
  79188. * Dispose this feature and all of the resources attached
  79189. */
  79190. dispose(): void;
  79191. protected _onXRFrame(frame: XRFrame): void;
  79192. private _processWebXRHitTestResult;
  79193. }
  79194. }
  79195. declare module BABYLON {
  79196. /**
  79197. * Configuration options of the anchor system
  79198. */
  79199. export interface IWebXRAnchorSystemOptions {
  79200. /**
  79201. * a node that will be used to convert local to world coordinates
  79202. */
  79203. worldParentNode?: TransformNode;
  79204. /**
  79205. * If set to true a reference of the created anchors will be kept until the next session starts
  79206. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79207. */
  79208. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79209. }
  79210. /**
  79211. * A babylon container for an XR Anchor
  79212. */
  79213. export interface IWebXRAnchor {
  79214. /**
  79215. * A babylon-assigned ID for this anchor
  79216. */
  79217. id: number;
  79218. /**
  79219. * Transformation matrix to apply to an object attached to this anchor
  79220. */
  79221. transformationMatrix: Matrix;
  79222. /**
  79223. * The native anchor object
  79224. */
  79225. xrAnchor: XRAnchor;
  79226. /**
  79227. * if defined, this object will be constantly updated by the anchor's position and rotation
  79228. */
  79229. attachedNode?: TransformNode;
  79230. /**
  79231. * Remove this anchor from the scene
  79232. */
  79233. remove(): void;
  79234. }
  79235. /**
  79236. * An implementation of the anchor system for WebXR.
  79237. * For further information see https://github.com/immersive-web/anchors/
  79238. */
  79239. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79240. private _options;
  79241. private _lastFrameDetected;
  79242. private _trackedAnchors;
  79243. private _referenceSpaceForFrameAnchors;
  79244. private _futureAnchors;
  79245. /**
  79246. * The module's name
  79247. */
  79248. static readonly Name: string;
  79249. /**
  79250. * The (Babylon) version of this module.
  79251. * This is an integer representing the implementation version.
  79252. * This number does not correspond to the WebXR specs version
  79253. */
  79254. static readonly Version: number;
  79255. /**
  79256. * Observers registered here will be executed when a new anchor was added to the session
  79257. */
  79258. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79259. /**
  79260. * Observers registered here will be executed when an anchor was removed from the session
  79261. */
  79262. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79263. /**
  79264. * Observers registered here will be executed when an existing anchor updates
  79265. * This can execute N times every frame
  79266. */
  79267. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79268. /**
  79269. * Set the reference space to use for anchor creation, when not using a hit test.
  79270. * Will default to the session's reference space if not defined
  79271. */
  79272. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79273. /**
  79274. * constructs a new anchor system
  79275. * @param _xrSessionManager an instance of WebXRSessionManager
  79276. * @param _options configuration object for this feature
  79277. */
  79278. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79279. private _tmpVector;
  79280. private _tmpQuaternion;
  79281. private _populateTmpTransformation;
  79282. /**
  79283. * Create a new anchor point using a hit test result at a specific point in the scene
  79284. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79285. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79286. *
  79287. * @param hitTestResult The hit test result to use for this anchor creation
  79288. * @param position an optional position offset for this anchor
  79289. * @param rotationQuaternion an optional rotation offset for this anchor
  79290. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79291. */
  79292. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79293. /**
  79294. * Add a new anchor at a specific position and rotation
  79295. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79296. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79297. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79298. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79299. *
  79300. * @param position the position in which to add an anchor
  79301. * @param rotationQuaternion an optional rotation for the anchor transformation
  79302. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79303. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79304. */
  79305. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79306. /**
  79307. * Get the list of anchors currently being tracked by the system
  79308. */
  79309. get anchors(): IWebXRAnchor[];
  79310. /**
  79311. * detach this feature.
  79312. * Will usually be called by the features manager
  79313. *
  79314. * @returns true if successful.
  79315. */
  79316. detach(): boolean;
  79317. /**
  79318. * Dispose this feature and all of the resources attached
  79319. */
  79320. dispose(): void;
  79321. protected _onXRFrame(frame: XRFrame): void;
  79322. /**
  79323. * avoiding using Array.find for global support.
  79324. * @param xrAnchor the plane to find in the array
  79325. */
  79326. private _findIndexInAnchorArray;
  79327. private _updateAnchorWithXRFrame;
  79328. private _createAnchorAtTransformation;
  79329. }
  79330. }
  79331. declare module BABYLON {
  79332. /**
  79333. * Options used in the plane detector module
  79334. */
  79335. export interface IWebXRPlaneDetectorOptions {
  79336. /**
  79337. * The node to use to transform the local results to world coordinates
  79338. */
  79339. worldParentNode?: TransformNode;
  79340. /**
  79341. * If set to true a reference of the created planes will be kept until the next session starts
  79342. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79343. */
  79344. doNotRemovePlanesOnSessionEnded?: boolean;
  79345. /**
  79346. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79347. */
  79348. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79349. }
  79350. /**
  79351. * A babylon interface for a WebXR plane.
  79352. * A Plane is actually a polygon, built from N points in space
  79353. *
  79354. * Supported in chrome 79, not supported in canary 81 ATM
  79355. */
  79356. export interface IWebXRPlane {
  79357. /**
  79358. * a babylon-assigned ID for this polygon
  79359. */
  79360. id: number;
  79361. /**
  79362. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79363. */
  79364. polygonDefinition: Array<Vector3>;
  79365. /**
  79366. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79367. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79368. */
  79369. transformationMatrix: Matrix;
  79370. /**
  79371. * the native xr-plane object
  79372. */
  79373. xrPlane: XRPlane;
  79374. }
  79375. /**
  79376. * The plane detector is used to detect planes in the real world when in AR
  79377. * For more information see https://github.com/immersive-web/real-world-geometry/
  79378. */
  79379. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79380. private _options;
  79381. private _detectedPlanes;
  79382. private _enabled;
  79383. private _lastFrameDetected;
  79384. /**
  79385. * The module's name
  79386. */
  79387. static readonly Name: string;
  79388. /**
  79389. * The (Babylon) version of this module.
  79390. * This is an integer representing the implementation version.
  79391. * This number does not correspond to the WebXR specs version
  79392. */
  79393. static readonly Version: number;
  79394. /**
  79395. * Observers registered here will be executed when a new plane was added to the session
  79396. */
  79397. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79398. /**
  79399. * Observers registered here will be executed when a plane is no longer detected in the session
  79400. */
  79401. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79402. /**
  79403. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79404. * This can execute N times every frame
  79405. */
  79406. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79407. /**
  79408. * construct a new Plane Detector
  79409. * @param _xrSessionManager an instance of xr Session manager
  79410. * @param _options configuration to use when constructing this feature
  79411. */
  79412. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79413. /**
  79414. * detach this feature.
  79415. * Will usually be called by the features manager
  79416. *
  79417. * @returns true if successful.
  79418. */
  79419. detach(): boolean;
  79420. /**
  79421. * Dispose this feature and all of the resources attached
  79422. */
  79423. dispose(): void;
  79424. /**
  79425. * Check if the needed objects are defined.
  79426. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79427. */
  79428. isCompatible(): boolean;
  79429. protected _onXRFrame(frame: XRFrame): void;
  79430. private _init;
  79431. private _updatePlaneWithXRPlane;
  79432. /**
  79433. * avoiding using Array.find for global support.
  79434. * @param xrPlane the plane to find in the array
  79435. */
  79436. private _findIndexInPlaneArray;
  79437. }
  79438. }
  79439. declare module BABYLON {
  79440. /**
  79441. * Options interface for the background remover plugin
  79442. */
  79443. export interface IWebXRBackgroundRemoverOptions {
  79444. /**
  79445. * Further background meshes to disable when entering AR
  79446. */
  79447. backgroundMeshes?: AbstractMesh[];
  79448. /**
  79449. * flags to configure the removal of the environment helper.
  79450. * If not set, the entire background will be removed. If set, flags should be set as well.
  79451. */
  79452. environmentHelperRemovalFlags?: {
  79453. /**
  79454. * Should the skybox be removed (default false)
  79455. */
  79456. skyBox?: boolean;
  79457. /**
  79458. * Should the ground be removed (default false)
  79459. */
  79460. ground?: boolean;
  79461. };
  79462. /**
  79463. * don't disable the environment helper
  79464. */
  79465. ignoreEnvironmentHelper?: boolean;
  79466. }
  79467. /**
  79468. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79469. */
  79470. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79471. /**
  79472. * read-only options to be used in this module
  79473. */
  79474. readonly options: IWebXRBackgroundRemoverOptions;
  79475. /**
  79476. * The module's name
  79477. */
  79478. static readonly Name: string;
  79479. /**
  79480. * The (Babylon) version of this module.
  79481. * This is an integer representing the implementation version.
  79482. * This number does not correspond to the WebXR specs version
  79483. */
  79484. static readonly Version: number;
  79485. /**
  79486. * registered observers will be triggered when the background state changes
  79487. */
  79488. onBackgroundStateChangedObservable: Observable<boolean>;
  79489. /**
  79490. * constructs a new background remover module
  79491. * @param _xrSessionManager the session manager for this module
  79492. * @param options read-only options to be used in this module
  79493. */
  79494. constructor(_xrSessionManager: WebXRSessionManager,
  79495. /**
  79496. * read-only options to be used in this module
  79497. */
  79498. options?: IWebXRBackgroundRemoverOptions);
  79499. /**
  79500. * attach this feature
  79501. * Will usually be called by the features manager
  79502. *
  79503. * @returns true if successful.
  79504. */
  79505. attach(): boolean;
  79506. /**
  79507. * detach this feature.
  79508. * Will usually be called by the features manager
  79509. *
  79510. * @returns true if successful.
  79511. */
  79512. detach(): boolean;
  79513. /**
  79514. * Dispose this feature and all of the resources attached
  79515. */
  79516. dispose(): void;
  79517. protected _onXRFrame(_xrFrame: XRFrame): void;
  79518. private _setBackgroundState;
  79519. }
  79520. }
  79521. declare module BABYLON {
  79522. /**
  79523. * Options for the controller physics feature
  79524. */
  79525. export class IWebXRControllerPhysicsOptions {
  79526. /**
  79527. * Should the headset get its own impostor
  79528. */
  79529. enableHeadsetImpostor?: boolean;
  79530. /**
  79531. * Optional parameters for the headset impostor
  79532. */
  79533. headsetImpostorParams?: {
  79534. /**
  79535. * The type of impostor to create. Default is sphere
  79536. */
  79537. impostorType: number;
  79538. /**
  79539. * the size of the impostor. Defaults to 10cm
  79540. */
  79541. impostorSize?: number | {
  79542. width: number;
  79543. height: number;
  79544. depth: number;
  79545. };
  79546. /**
  79547. * Friction definitions
  79548. */
  79549. friction?: number;
  79550. /**
  79551. * Restitution
  79552. */
  79553. restitution?: number;
  79554. };
  79555. /**
  79556. * The physics properties of the future impostors
  79557. */
  79558. physicsProperties?: {
  79559. /**
  79560. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79561. * Note that this requires a physics engine that supports mesh impostors!
  79562. */
  79563. useControllerMesh?: boolean;
  79564. /**
  79565. * The type of impostor to create. Default is sphere
  79566. */
  79567. impostorType?: number;
  79568. /**
  79569. * the size of the impostor. Defaults to 10cm
  79570. */
  79571. impostorSize?: number | {
  79572. width: number;
  79573. height: number;
  79574. depth: number;
  79575. };
  79576. /**
  79577. * Friction definitions
  79578. */
  79579. friction?: number;
  79580. /**
  79581. * Restitution
  79582. */
  79583. restitution?: number;
  79584. };
  79585. /**
  79586. * the xr input to use with this pointer selection
  79587. */
  79588. xrInput: WebXRInput;
  79589. }
  79590. /**
  79591. * Add physics impostor to your webxr controllers,
  79592. * including naive calculation of their linear and angular velocity
  79593. */
  79594. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79595. private readonly _options;
  79596. private _attachController;
  79597. private _controllers;
  79598. private _debugMode;
  79599. private _delta;
  79600. private _headsetImpostor?;
  79601. private _headsetMesh?;
  79602. private _lastTimestamp;
  79603. private _tmpQuaternion;
  79604. private _tmpVector;
  79605. /**
  79606. * The module's name
  79607. */
  79608. static readonly Name: string;
  79609. /**
  79610. * The (Babylon) version of this module.
  79611. * This is an integer representing the implementation version.
  79612. * This number does not correspond to the webxr specs version
  79613. */
  79614. static readonly Version: number;
  79615. /**
  79616. * Construct a new Controller Physics Feature
  79617. * @param _xrSessionManager the corresponding xr session manager
  79618. * @param _options options to create this feature with
  79619. */
  79620. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79621. /**
  79622. * @hidden
  79623. * enable debugging - will show console outputs and the impostor mesh
  79624. */
  79625. _enablePhysicsDebug(): void;
  79626. /**
  79627. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79628. * @param xrController the controller to add
  79629. */
  79630. addController(xrController: WebXRInputSource): void;
  79631. /**
  79632. * attach this feature
  79633. * Will usually be called by the features manager
  79634. *
  79635. * @returns true if successful.
  79636. */
  79637. attach(): boolean;
  79638. /**
  79639. * detach this feature.
  79640. * Will usually be called by the features manager
  79641. *
  79642. * @returns true if successful.
  79643. */
  79644. detach(): boolean;
  79645. /**
  79646. * Get the headset impostor, if enabled
  79647. * @returns the impostor
  79648. */
  79649. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79650. /**
  79651. * Get the physics impostor of a specific controller.
  79652. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79653. * @param controller the controller or the controller id of which to get the impostor
  79654. * @returns the impostor or null
  79655. */
  79656. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79657. /**
  79658. * Update the physics properties provided in the constructor
  79659. * @param newProperties the new properties object
  79660. */
  79661. setPhysicsProperties(newProperties: {
  79662. impostorType?: number;
  79663. impostorSize?: number | {
  79664. width: number;
  79665. height: number;
  79666. depth: number;
  79667. };
  79668. friction?: number;
  79669. restitution?: number;
  79670. }): void;
  79671. protected _onXRFrame(_xrFrame: any): void;
  79672. private _detachController;
  79673. }
  79674. }
  79675. declare module BABYLON {
  79676. /**
  79677. * A babylon interface for a "WebXR" feature point.
  79678. * Represents the position and confidence value of a given feature point.
  79679. */
  79680. export interface IWebXRFeaturePoint {
  79681. /**
  79682. * Represents the position of the feature point in world space.
  79683. */
  79684. position: Vector3;
  79685. /**
  79686. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79687. */
  79688. confidenceValue: number;
  79689. }
  79690. /**
  79691. * The feature point system is used to detect feature points from real world geometry.
  79692. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79693. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79694. */
  79695. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79696. private _enabled;
  79697. private _featurePointCloud;
  79698. /**
  79699. * The module's name
  79700. */
  79701. static readonly Name: string;
  79702. /**
  79703. * The (Babylon) version of this module.
  79704. * This is an integer representing the implementation version.
  79705. * This number does not correspond to the WebXR specs version
  79706. */
  79707. static readonly Version: number;
  79708. /**
  79709. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79710. * Will notify the observers about which feature points have been added.
  79711. */
  79712. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79713. /**
  79714. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79715. * Will notify the observers about which feature points have been updated.
  79716. */
  79717. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79718. /**
  79719. * The current feature point cloud maintained across frames.
  79720. */
  79721. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79722. /**
  79723. * construct the feature point system
  79724. * @param _xrSessionManager an instance of xr Session manager
  79725. */
  79726. constructor(_xrSessionManager: WebXRSessionManager);
  79727. /**
  79728. * Detach this feature.
  79729. * Will usually be called by the features manager
  79730. *
  79731. * @returns true if successful.
  79732. */
  79733. detach(): boolean;
  79734. /**
  79735. * Dispose this feature and all of the resources attached
  79736. */
  79737. dispose(): void;
  79738. /**
  79739. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79740. */
  79741. protected _onXRFrame(frame: XRFrame): void;
  79742. /**
  79743. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79744. */
  79745. private _init;
  79746. }
  79747. }
  79748. declare module BABYLON {
  79749. /**
  79750. * Configuration interface for the hand tracking feature
  79751. */
  79752. export interface IWebXRHandTrackingOptions {
  79753. /**
  79754. * The xrInput that will be used as source for new hands
  79755. */
  79756. xrInput: WebXRInput;
  79757. /**
  79758. * Configuration object for the joint meshes
  79759. */
  79760. jointMeshes?: {
  79761. /**
  79762. * Should the meshes created be invisible (defaults to false)
  79763. */
  79764. invisible?: boolean;
  79765. /**
  79766. * A source mesh to be used to create instances. Defaults to a sphere.
  79767. * This mesh will be the source for all other (25) meshes.
  79768. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79769. */
  79770. sourceMesh?: Mesh;
  79771. /**
  79772. * This function will be called after a mesh was created for a specific joint.
  79773. * Using this function you can either manipulate the instance or return a new mesh.
  79774. * When returning a new mesh the instance created before will be disposed
  79775. */
  79776. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79777. /**
  79778. * Should the source mesh stay visible. Defaults to false
  79779. */
  79780. keepOriginalVisible?: boolean;
  79781. /**
  79782. * Scale factor for all instances (defaults to 2)
  79783. */
  79784. scaleFactor?: number;
  79785. /**
  79786. * Should each instance have its own physics impostor
  79787. */
  79788. enablePhysics?: boolean;
  79789. /**
  79790. * If enabled, override default physics properties
  79791. */
  79792. physicsProps?: {
  79793. friction?: number;
  79794. restitution?: number;
  79795. impostorType?: number;
  79796. };
  79797. /**
  79798. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79799. */
  79800. disableDefaultHandMesh?: boolean;
  79801. /**
  79802. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79803. */
  79804. handMeshes?: {
  79805. right: AbstractMesh;
  79806. left: AbstractMesh;
  79807. };
  79808. /**
  79809. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79810. */
  79811. rigMapping?: {
  79812. right: string[];
  79813. left: string[];
  79814. };
  79815. };
  79816. }
  79817. /**
  79818. * Parts of the hands divided to writs and finger names
  79819. */
  79820. export const enum HandPart {
  79821. /**
  79822. * HandPart - Wrist
  79823. */
  79824. WRIST = "wrist",
  79825. /**
  79826. * HandPart - The THumb
  79827. */
  79828. THUMB = "thumb",
  79829. /**
  79830. * HandPart - Index finger
  79831. */
  79832. INDEX = "index",
  79833. /**
  79834. * HandPart - Middle finger
  79835. */
  79836. MIDDLE = "middle",
  79837. /**
  79838. * HandPart - Ring finger
  79839. */
  79840. RING = "ring",
  79841. /**
  79842. * HandPart - Little finger
  79843. */
  79844. LITTLE = "little"
  79845. }
  79846. /**
  79847. * Representing a single hand (with its corresponding native XRHand object)
  79848. */
  79849. export class WebXRHand implements IDisposable {
  79850. /** the controller to which the hand correlates */
  79851. readonly xrController: WebXRInputSource;
  79852. /** the meshes to be used to track the hand joints */
  79853. readonly trackedMeshes: AbstractMesh[];
  79854. private _handMesh?;
  79855. private _rigMapping?;
  79856. private _scene;
  79857. private _defaultHandMesh;
  79858. private _transformNodeMapping;
  79859. /**
  79860. * Hand-parts definition (key is HandPart)
  79861. */
  79862. handPartsDefinition: {
  79863. [key: string]: number[];
  79864. };
  79865. /**
  79866. * Observers will be triggered when the mesh for this hand was initialized.
  79867. */
  79868. onHandMeshReadyObservable: Observable<WebXRHand>;
  79869. /**
  79870. * Populate the HandPartsDefinition object.
  79871. * This is called as a side effect since certain browsers don't have XRHand defined.
  79872. */
  79873. private generateHandPartsDefinition;
  79874. /**
  79875. * Construct a new hand object
  79876. * @param xrController the controller to which the hand correlates
  79877. * @param trackedMeshes the meshes to be used to track the hand joints
  79878. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79879. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79880. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79881. */
  79882. constructor(
  79883. /** the controller to which the hand correlates */
  79884. xrController: WebXRInputSource,
  79885. /** the meshes to be used to track the hand joints */
  79886. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79887. /**
  79888. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79889. */
  79890. get handMesh(): AbstractMesh | undefined;
  79891. /**
  79892. * Update this hand from the latest xr frame
  79893. * @param xrFrame xrFrame to update from
  79894. * @param referenceSpace The current viewer reference space
  79895. * @param scaleFactor optional scale factor for the meshes
  79896. */
  79897. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79898. /**
  79899. * Get meshes of part of the hand
  79900. * @param part the part of hand to get
  79901. * @returns An array of meshes that correlate to the hand part requested
  79902. */
  79903. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79904. /**
  79905. * Dispose this Hand object
  79906. */
  79907. dispose(): void;
  79908. private _generateDefaultHandMesh;
  79909. }
  79910. /**
  79911. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79912. */
  79913. export class WebXRHandTracking extends WebXRAbstractFeature {
  79914. /**
  79915. * options to use when constructing this feature
  79916. */
  79917. readonly options: IWebXRHandTrackingOptions;
  79918. private static _idCounter;
  79919. /**
  79920. * The module's name
  79921. */
  79922. static readonly Name: string;
  79923. /**
  79924. * The (Babylon) version of this module.
  79925. * This is an integer representing the implementation version.
  79926. * This number does not correspond to the WebXR specs version
  79927. */
  79928. static readonly Version: number;
  79929. /**
  79930. * This observable will notify registered observers when a new hand object was added and initialized
  79931. */
  79932. onHandAddedObservable: Observable<WebXRHand>;
  79933. /**
  79934. * This observable will notify its observers right before the hand object is disposed
  79935. */
  79936. onHandRemovedObservable: Observable<WebXRHand>;
  79937. private _hands;
  79938. /**
  79939. * Creates a new instance of the hit test feature
  79940. * @param _xrSessionManager an instance of WebXRSessionManager
  79941. * @param options options to use when constructing this feature
  79942. */
  79943. constructor(_xrSessionManager: WebXRSessionManager,
  79944. /**
  79945. * options to use when constructing this feature
  79946. */
  79947. options: IWebXRHandTrackingOptions);
  79948. /**
  79949. * Check if the needed objects are defined.
  79950. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79951. */
  79952. isCompatible(): boolean;
  79953. /**
  79954. * attach this feature
  79955. * Will usually be called by the features manager
  79956. *
  79957. * @returns true if successful.
  79958. */
  79959. attach(): boolean;
  79960. /**
  79961. * detach this feature.
  79962. * Will usually be called by the features manager
  79963. *
  79964. * @returns true if successful.
  79965. */
  79966. detach(): boolean;
  79967. /**
  79968. * Dispose this feature and all of the resources attached
  79969. */
  79970. dispose(): void;
  79971. /**
  79972. * Get the hand object according to the controller id
  79973. * @param controllerId the controller id to which we want to get the hand
  79974. * @returns null if not found or the WebXRHand object if found
  79975. */
  79976. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79977. /**
  79978. * Get a hand object according to the requested handedness
  79979. * @param handedness the handedness to request
  79980. * @returns null if not found or the WebXRHand object if found
  79981. */
  79982. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79983. protected _onXRFrame(_xrFrame: XRFrame): void;
  79984. private _attachHand;
  79985. private _detachHand;
  79986. }
  79987. }
  79988. declare module BABYLON {
  79989. /**
  79990. * Options used in the mesh detector module
  79991. */
  79992. export interface IWebXRMeshDetectorOptions {
  79993. /**
  79994. * The node to use to transform the local results to world coordinates
  79995. */
  79996. worldParentNode?: TransformNode;
  79997. /**
  79998. * If set to true a reference of the created meshes will be kept until the next session starts
  79999. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80000. */
  80001. doNotRemoveMeshesOnSessionEnded?: boolean;
  80002. /**
  80003. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80004. */
  80005. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80006. /**
  80007. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80008. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80009. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80010. */
  80011. convertCoordinateSystems?: boolean;
  80012. }
  80013. /**
  80014. * A babylon interface for a XR mesh's vertex data.
  80015. *
  80016. * Currently not supported by WebXR, available only with BabylonNative
  80017. */
  80018. export interface IWebXRVertexData {
  80019. /**
  80020. * A babylon-assigned ID for this mesh
  80021. */
  80022. id: number;
  80023. /**
  80024. * Data required for constructing a mesh in Babylon.js.
  80025. */
  80026. xrMesh: XRMesh;
  80027. /**
  80028. * The node to use to transform the local results to world coordinates.
  80029. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80030. */
  80031. worldParentNode?: TransformNode;
  80032. /**
  80033. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80034. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80035. */
  80036. positions?: Float32Array;
  80037. /**
  80038. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80039. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80040. */
  80041. indices?: Uint32Array;
  80042. /**
  80043. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80044. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80045. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80046. */
  80047. normals?: Float32Array;
  80048. /**
  80049. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80050. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80051. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80052. */
  80053. transformationMatrix?: Matrix;
  80054. }
  80055. /**
  80056. * The mesh detector is used to detect meshes in the real world when in AR
  80057. */
  80058. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80059. private _options;
  80060. private _detectedMeshes;
  80061. /**
  80062. * The module's name
  80063. */
  80064. static readonly Name: string;
  80065. /**
  80066. * The (Babylon) version of this module.
  80067. * This is an integer representing the implementation version.
  80068. * This number does not correspond to the WebXR specs version
  80069. */
  80070. static readonly Version: number;
  80071. /**
  80072. * Observers registered here will be executed when a new mesh was added to the session
  80073. */
  80074. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80075. /**
  80076. * Observers registered here will be executed when a mesh is no longer detected in the session
  80077. */
  80078. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80079. /**
  80080. * Observers registered here will be executed when an existing mesh updates
  80081. */
  80082. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80083. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80084. detach(): boolean;
  80085. dispose(): void;
  80086. protected _onXRFrame(frame: XRFrame): void;
  80087. private _init;
  80088. private _updateVertexDataWithXRMesh;
  80089. }
  80090. }
  80091. declare module BABYLON {
  80092. /**
  80093. * Options interface for the background remover plugin
  80094. */
  80095. export interface IWebXRImageTrackingOptions {
  80096. /**
  80097. * A required array with images to track
  80098. */
  80099. images: {
  80100. /**
  80101. * The source of the image. can be a URL or an image bitmap
  80102. */
  80103. src: string | ImageBitmap;
  80104. /**
  80105. * The estimated width in the real world (in meters)
  80106. */
  80107. estimatedRealWorldWidth: number;
  80108. }[];
  80109. }
  80110. /**
  80111. * An object representing an image tracked by the system
  80112. */
  80113. export interface IWebXRTrackedImage {
  80114. /**
  80115. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80116. */
  80117. id: number;
  80118. /**
  80119. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80120. */
  80121. emulated?: boolean;
  80122. /**
  80123. * Just in case it is needed - the image bitmap that is being tracked
  80124. */
  80125. originalBitmap: ImageBitmap;
  80126. /**
  80127. * The native XR result image tracking result, untouched
  80128. */
  80129. xrTrackingResult?: XRImageTrackingResult;
  80130. /**
  80131. * Width in real world (meters)
  80132. */
  80133. realWorldWidth?: number;
  80134. /**
  80135. * A transformation matrix of this current image in the current reference space.
  80136. */
  80137. transformationMatrix: Matrix;
  80138. /**
  80139. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80140. */
  80141. ratio?: number;
  80142. }
  80143. /**
  80144. * Image tracking for immersive AR sessions.
  80145. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80146. */
  80147. export class WebXRImageTracking extends WebXRAbstractFeature {
  80148. /**
  80149. * read-only options to be used in this module
  80150. */
  80151. readonly options: IWebXRImageTrackingOptions;
  80152. /**
  80153. * The module's name
  80154. */
  80155. static readonly Name: string;
  80156. /**
  80157. * The (Babylon) version of this module.
  80158. * This is an integer representing the implementation version.
  80159. * This number does not correspond to the WebXR specs version
  80160. */
  80161. static readonly Version: number;
  80162. /**
  80163. * This will be triggered if the underlying system deems an image untrackable.
  80164. * The index is the index of the image from the array used to initialize the feature.
  80165. */
  80166. onUntrackableImageFoundObservable: Observable<number>;
  80167. /**
  80168. * An image was deemed trackable, and the system will start tracking it.
  80169. */
  80170. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80171. /**
  80172. * The image was found and its state was updated.
  80173. */
  80174. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80175. private _trackedImages;
  80176. private _originalTrackingRequest;
  80177. /**
  80178. * constructs the image tracking feature
  80179. * @param _xrSessionManager the session manager for this module
  80180. * @param options read-only options to be used in this module
  80181. */
  80182. constructor(_xrSessionManager: WebXRSessionManager,
  80183. /**
  80184. * read-only options to be used in this module
  80185. */
  80186. options: IWebXRImageTrackingOptions);
  80187. /**
  80188. * attach this feature
  80189. * Will usually be called by the features manager
  80190. *
  80191. * @returns true if successful.
  80192. */
  80193. attach(): boolean;
  80194. /**
  80195. * detach this feature.
  80196. * Will usually be called by the features manager
  80197. *
  80198. * @returns true if successful.
  80199. */
  80200. detach(): boolean;
  80201. /**
  80202. * Check if the needed objects are defined.
  80203. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80204. */
  80205. isCompatible(): boolean;
  80206. /**
  80207. * Get a tracked image by its ID.
  80208. *
  80209. * @param id the id of the image to load (position in the init array)
  80210. * @returns a trackable image, if exists in this location
  80211. */
  80212. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80213. /**
  80214. * Dispose this feature and all of the resources attached
  80215. */
  80216. dispose(): void;
  80217. /**
  80218. * Extends the session init object if needed
  80219. * @returns augmentation object fo the xr session init object.
  80220. */
  80221. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80222. protected _onXRFrame(_xrFrame: XRFrame): void;
  80223. private _init;
  80224. }
  80225. }
  80226. declare module BABYLON {
  80227. /**
  80228. * The motion controller class for all microsoft mixed reality controllers
  80229. */
  80230. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80231. protected readonly _mapping: {
  80232. defaultButton: {
  80233. valueNodeName: string;
  80234. unpressedNodeName: string;
  80235. pressedNodeName: string;
  80236. };
  80237. defaultAxis: {
  80238. valueNodeName: string;
  80239. minNodeName: string;
  80240. maxNodeName: string;
  80241. };
  80242. buttons: {
  80243. "xr-standard-trigger": {
  80244. rootNodeName: string;
  80245. componentProperty: string;
  80246. states: string[];
  80247. };
  80248. "xr-standard-squeeze": {
  80249. rootNodeName: string;
  80250. componentProperty: string;
  80251. states: string[];
  80252. };
  80253. "xr-standard-touchpad": {
  80254. rootNodeName: string;
  80255. labelAnchorNodeName: string;
  80256. touchPointNodeName: string;
  80257. };
  80258. "xr-standard-thumbstick": {
  80259. rootNodeName: string;
  80260. componentProperty: string;
  80261. states: string[];
  80262. };
  80263. };
  80264. axes: {
  80265. "xr-standard-touchpad": {
  80266. "x-axis": {
  80267. rootNodeName: string;
  80268. };
  80269. "y-axis": {
  80270. rootNodeName: string;
  80271. };
  80272. };
  80273. "xr-standard-thumbstick": {
  80274. "x-axis": {
  80275. rootNodeName: string;
  80276. };
  80277. "y-axis": {
  80278. rootNodeName: string;
  80279. };
  80280. };
  80281. };
  80282. };
  80283. /**
  80284. * The base url used to load the left and right controller models
  80285. */
  80286. static MODEL_BASE_URL: string;
  80287. /**
  80288. * The name of the left controller model file
  80289. */
  80290. static MODEL_LEFT_FILENAME: string;
  80291. /**
  80292. * The name of the right controller model file
  80293. */
  80294. static MODEL_RIGHT_FILENAME: string;
  80295. profileId: string;
  80296. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80297. protected _getFilenameAndPath(): {
  80298. filename: string;
  80299. path: string;
  80300. };
  80301. protected _getModelLoadingConstraints(): boolean;
  80302. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80303. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80304. protected _updateModel(): void;
  80305. }
  80306. }
  80307. declare module BABYLON {
  80308. /**
  80309. * The motion controller class for oculus touch (quest, rift).
  80310. * This class supports legacy mapping as well the standard xr mapping
  80311. */
  80312. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80313. private _forceLegacyControllers;
  80314. private _modelRootNode;
  80315. /**
  80316. * The base url used to load the left and right controller models
  80317. */
  80318. static MODEL_BASE_URL: string;
  80319. /**
  80320. * The name of the left controller model file
  80321. */
  80322. static MODEL_LEFT_FILENAME: string;
  80323. /**
  80324. * The name of the right controller model file
  80325. */
  80326. static MODEL_RIGHT_FILENAME: string;
  80327. /**
  80328. * Base Url for the Quest controller model.
  80329. */
  80330. static QUEST_MODEL_BASE_URL: string;
  80331. profileId: string;
  80332. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80333. protected _getFilenameAndPath(): {
  80334. filename: string;
  80335. path: string;
  80336. };
  80337. protected _getModelLoadingConstraints(): boolean;
  80338. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80339. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80340. protected _updateModel(): void;
  80341. /**
  80342. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80343. * between the touch and touch 2.
  80344. */
  80345. private _isQuest;
  80346. }
  80347. }
  80348. declare module BABYLON {
  80349. /**
  80350. * The motion controller class for the standard HTC-Vive controllers
  80351. */
  80352. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80353. private _modelRootNode;
  80354. /**
  80355. * The base url used to load the left and right controller models
  80356. */
  80357. static MODEL_BASE_URL: string;
  80358. /**
  80359. * File name for the controller model.
  80360. */
  80361. static MODEL_FILENAME: string;
  80362. profileId: string;
  80363. /**
  80364. * Create a new Vive motion controller object
  80365. * @param scene the scene to use to create this controller
  80366. * @param gamepadObject the corresponding gamepad object
  80367. * @param handedness the handedness of the controller
  80368. */
  80369. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80370. protected _getFilenameAndPath(): {
  80371. filename: string;
  80372. path: string;
  80373. };
  80374. protected _getModelLoadingConstraints(): boolean;
  80375. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80376. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80377. protected _updateModel(): void;
  80378. }
  80379. }
  80380. declare module BABYLON {
  80381. /**
  80382. * A cursor which tracks a point on a path
  80383. */
  80384. export class PathCursor {
  80385. private path;
  80386. /**
  80387. * Stores path cursor callbacks for when an onchange event is triggered
  80388. */
  80389. private _onchange;
  80390. /**
  80391. * The value of the path cursor
  80392. */
  80393. value: number;
  80394. /**
  80395. * The animation array of the path cursor
  80396. */
  80397. animations: Animation[];
  80398. /**
  80399. * Initializes the path cursor
  80400. * @param path The path to track
  80401. */
  80402. constructor(path: Path2);
  80403. /**
  80404. * Gets the cursor point on the path
  80405. * @returns A point on the path cursor at the cursor location
  80406. */
  80407. getPoint(): Vector3;
  80408. /**
  80409. * Moves the cursor ahead by the step amount
  80410. * @param step The amount to move the cursor forward
  80411. * @returns This path cursor
  80412. */
  80413. moveAhead(step?: number): PathCursor;
  80414. /**
  80415. * Moves the cursor behind by the step amount
  80416. * @param step The amount to move the cursor back
  80417. * @returns This path cursor
  80418. */
  80419. moveBack(step?: number): PathCursor;
  80420. /**
  80421. * Moves the cursor by the step amount
  80422. * If the step amount is greater than one, an exception is thrown
  80423. * @param step The amount to move the cursor
  80424. * @returns This path cursor
  80425. */
  80426. move(step: number): PathCursor;
  80427. /**
  80428. * Ensures that the value is limited between zero and one
  80429. * @returns This path cursor
  80430. */
  80431. private ensureLimits;
  80432. /**
  80433. * Runs onchange callbacks on change (used by the animation engine)
  80434. * @returns This path cursor
  80435. */
  80436. private raiseOnChange;
  80437. /**
  80438. * Executes a function on change
  80439. * @param f A path cursor onchange callback
  80440. * @returns This path cursor
  80441. */
  80442. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80443. }
  80444. }
  80445. declare module BABYLON {
  80446. /** @hidden */
  80447. export var blurPixelShader: {
  80448. name: string;
  80449. shader: string;
  80450. };
  80451. }
  80452. declare module BABYLON {
  80453. /** @hidden */
  80454. export var pointCloudVertexDeclaration: {
  80455. name: string;
  80456. shader: string;
  80457. };
  80458. }
  80459. // Mixins
  80460. interface Window {
  80461. mozIndexedDB: IDBFactory;
  80462. webkitIndexedDB: IDBFactory;
  80463. msIndexedDB: IDBFactory;
  80464. webkitURL: typeof URL;
  80465. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80466. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80467. WebGLRenderingContext: WebGLRenderingContext;
  80468. MSGesture: MSGesture;
  80469. CANNON: any;
  80470. AudioContext: AudioContext;
  80471. webkitAudioContext: AudioContext;
  80472. PointerEvent: any;
  80473. Math: Math;
  80474. Uint8Array: Uint8ArrayConstructor;
  80475. Float32Array: Float32ArrayConstructor;
  80476. mozURL: typeof URL;
  80477. msURL: typeof URL;
  80478. VRFrameData: any; // WebVR, from specs 1.1
  80479. DracoDecoderModule: any;
  80480. setImmediate(handler: (...args: any[]) => void): number;
  80481. }
  80482. interface HTMLCanvasElement {
  80483. requestPointerLock(): void;
  80484. msRequestPointerLock?(): void;
  80485. mozRequestPointerLock?(): void;
  80486. webkitRequestPointerLock?(): void;
  80487. /** Track wether a record is in progress */
  80488. isRecording: boolean;
  80489. /** Capture Stream method defined by some browsers */
  80490. captureStream(fps?: number): MediaStream;
  80491. }
  80492. interface CanvasRenderingContext2D {
  80493. msImageSmoothingEnabled: boolean;
  80494. }
  80495. interface MouseEvent {
  80496. mozMovementX: number;
  80497. mozMovementY: number;
  80498. webkitMovementX: number;
  80499. webkitMovementY: number;
  80500. msMovementX: number;
  80501. msMovementY: number;
  80502. }
  80503. interface Navigator {
  80504. mozGetVRDevices: (any: any) => any;
  80505. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80506. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80507. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80508. webkitGetGamepads(): Gamepad[];
  80509. msGetGamepads(): Gamepad[];
  80510. webkitGamepads(): Gamepad[];
  80511. }
  80512. interface HTMLVideoElement {
  80513. mozSrcObject: any;
  80514. }
  80515. interface Math {
  80516. fround(x: number): number;
  80517. imul(a: number, b: number): number;
  80518. log2(x: number): number;
  80519. }
  80520. interface WebGLRenderingContext {
  80521. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80522. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80523. vertexAttribDivisor(index: number, divisor: number): void;
  80524. createVertexArray(): any;
  80525. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80526. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80527. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80528. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80529. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80530. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80531. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80532. // Queries
  80533. createQuery(): WebGLQuery;
  80534. deleteQuery(query: WebGLQuery): void;
  80535. beginQuery(target: number, query: WebGLQuery): void;
  80536. endQuery(target: number): void;
  80537. getQueryParameter(query: WebGLQuery, pname: number): any;
  80538. getQuery(target: number, pname: number): any;
  80539. MAX_SAMPLES: number;
  80540. RGBA8: number;
  80541. READ_FRAMEBUFFER: number;
  80542. DRAW_FRAMEBUFFER: number;
  80543. UNIFORM_BUFFER: number;
  80544. HALF_FLOAT_OES: number;
  80545. RGBA16F: number;
  80546. RGBA32F: number;
  80547. R32F: number;
  80548. RG32F: number;
  80549. RGB32F: number;
  80550. R16F: number;
  80551. RG16F: number;
  80552. RGB16F: number;
  80553. RED: number;
  80554. RG: number;
  80555. R8: number;
  80556. RG8: number;
  80557. UNSIGNED_INT_24_8: number;
  80558. DEPTH24_STENCIL8: number;
  80559. MIN: number;
  80560. MAX: number;
  80561. /* Multiple Render Targets */
  80562. drawBuffers(buffers: number[]): void;
  80563. readBuffer(src: number): void;
  80564. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80565. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80566. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80567. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80568. // Occlusion Query
  80569. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80570. ANY_SAMPLES_PASSED: number;
  80571. QUERY_RESULT_AVAILABLE: number;
  80572. QUERY_RESULT: number;
  80573. }
  80574. interface WebGLProgram {
  80575. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80576. }
  80577. interface EXT_disjoint_timer_query {
  80578. QUERY_COUNTER_BITS_EXT: number;
  80579. TIME_ELAPSED_EXT: number;
  80580. TIMESTAMP_EXT: number;
  80581. GPU_DISJOINT_EXT: number;
  80582. QUERY_RESULT_EXT: number;
  80583. QUERY_RESULT_AVAILABLE_EXT: number;
  80584. queryCounterEXT(query: WebGLQuery, target: number): void;
  80585. createQueryEXT(): WebGLQuery;
  80586. beginQueryEXT(target: number, query: WebGLQuery): void;
  80587. endQueryEXT(target: number): void;
  80588. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80589. deleteQueryEXT(query: WebGLQuery): void;
  80590. }
  80591. interface WebGLUniformLocation {
  80592. _currentState: any;
  80593. }
  80594. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80595. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80596. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80597. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80598. interface WebGLRenderingContext {
  80599. readonly RASTERIZER_DISCARD: number;
  80600. readonly DEPTH_COMPONENT24: number;
  80601. readonly TEXTURE_3D: number;
  80602. readonly TEXTURE_2D_ARRAY: number;
  80603. readonly TEXTURE_COMPARE_FUNC: number;
  80604. readonly TEXTURE_COMPARE_MODE: number;
  80605. readonly COMPARE_REF_TO_TEXTURE: number;
  80606. readonly TEXTURE_WRAP_R: number;
  80607. readonly HALF_FLOAT: number;
  80608. readonly RGB8: number;
  80609. readonly RED_INTEGER: number;
  80610. readonly RG_INTEGER: number;
  80611. readonly RGB_INTEGER: number;
  80612. readonly RGBA_INTEGER: number;
  80613. readonly R8_SNORM: number;
  80614. readonly RG8_SNORM: number;
  80615. readonly RGB8_SNORM: number;
  80616. readonly RGBA8_SNORM: number;
  80617. readonly R8I: number;
  80618. readonly RG8I: number;
  80619. readonly RGB8I: number;
  80620. readonly RGBA8I: number;
  80621. readonly R8UI: number;
  80622. readonly RG8UI: number;
  80623. readonly RGB8UI: number;
  80624. readonly RGBA8UI: number;
  80625. readonly R16I: number;
  80626. readonly RG16I: number;
  80627. readonly RGB16I: number;
  80628. readonly RGBA16I: number;
  80629. readonly R16UI: number;
  80630. readonly RG16UI: number;
  80631. readonly RGB16UI: number;
  80632. readonly RGBA16UI: number;
  80633. readonly R32I: number;
  80634. readonly RG32I: number;
  80635. readonly RGB32I: number;
  80636. readonly RGBA32I: number;
  80637. readonly R32UI: number;
  80638. readonly RG32UI: number;
  80639. readonly RGB32UI: number;
  80640. readonly RGBA32UI: number;
  80641. readonly RGB10_A2UI: number;
  80642. readonly R11F_G11F_B10F: number;
  80643. readonly RGB9_E5: number;
  80644. readonly RGB10_A2: number;
  80645. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80646. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80647. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80648. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80649. readonly DEPTH_COMPONENT32F: number;
  80650. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80652. 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;
  80653. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80654. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80655. readonly TRANSFORM_FEEDBACK: number;
  80656. readonly INTERLEAVED_ATTRIBS: number;
  80657. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80658. createTransformFeedback(): WebGLTransformFeedback;
  80659. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80660. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80661. beginTransformFeedback(primitiveMode: number): void;
  80662. endTransformFeedback(): void;
  80663. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80664. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80665. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80666. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80667. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80668. }
  80669. interface ImageBitmap {
  80670. readonly width: number;
  80671. readonly height: number;
  80672. close(): void;
  80673. }
  80674. interface WebGLQuery extends WebGLObject {
  80675. }
  80676. declare var WebGLQuery: {
  80677. prototype: WebGLQuery;
  80678. new(): WebGLQuery;
  80679. };
  80680. interface WebGLSampler extends WebGLObject {
  80681. }
  80682. declare var WebGLSampler: {
  80683. prototype: WebGLSampler;
  80684. new(): WebGLSampler;
  80685. };
  80686. interface WebGLSync extends WebGLObject {
  80687. }
  80688. declare var WebGLSync: {
  80689. prototype: WebGLSync;
  80690. new(): WebGLSync;
  80691. };
  80692. interface WebGLTransformFeedback extends WebGLObject {
  80693. }
  80694. declare var WebGLTransformFeedback: {
  80695. prototype: WebGLTransformFeedback;
  80696. new(): WebGLTransformFeedback;
  80697. };
  80698. interface WebGLVertexArrayObject extends WebGLObject {
  80699. }
  80700. declare var WebGLVertexArrayObject: {
  80701. prototype: WebGLVertexArrayObject;
  80702. new(): WebGLVertexArrayObject;
  80703. };
  80704. interface Navigator {
  80705. readonly gpu: GPU | undefined;
  80706. }
  80707. interface GPUColorDict {
  80708. a: number;
  80709. b: number;
  80710. g: number;
  80711. r: number;
  80712. }
  80713. type GPUColor = [number, number, number, number] | GPUColorDict;
  80714. interface GPUOrigin2DDict {
  80715. x?: number;
  80716. y?: number;
  80717. }
  80718. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80719. interface GPUOrigin3DDict {
  80720. x?: number;
  80721. y?: number;
  80722. z?: number;
  80723. }
  80724. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80725. interface GPUExtent3DDict {
  80726. width: number;
  80727. height: number;
  80728. depth: number;
  80729. }
  80730. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80731. type GPUBindingResource =
  80732. | GPUSampler
  80733. | GPUTextureView
  80734. | GPUBufferBinding;
  80735. type GPUExtensionName =
  80736. | "texture-compression-bc"
  80737. | "timestamp-query"
  80738. | "pipeline-statistics-query"
  80739. | "depth-clamping"
  80740. | "depth24unorm-stencil8"
  80741. | "depth32float-stencil8";
  80742. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80743. type GPUBindingType =
  80744. | "uniform-buffer"
  80745. | "storage-buffer"
  80746. | "readonly-storage-buffer"
  80747. | "sampler"
  80748. | "comparison-sampler"
  80749. | "sampled-texture"
  80750. | "readonly-storage-texture"
  80751. | "writeonly-storage-texture";
  80752. type GPUBlendFactor =
  80753. | "zero"
  80754. | "one"
  80755. | "src-color"
  80756. | "one-minus-src-color"
  80757. | "src-alpha"
  80758. | "one-minus-src-alpha"
  80759. | "dst-color"
  80760. | "one-minus-dst-color"
  80761. | "dst-alpha"
  80762. | "one-minus-dst-alpha"
  80763. | "src-alpha-saturated"
  80764. | "blend-color"
  80765. | "one-minus-blend-color";
  80766. type GPUBlendOperation =
  80767. | "add"
  80768. | "subtract"
  80769. | "reverse-subtract"
  80770. | "min"
  80771. | "max";
  80772. type GPUCompareFunction =
  80773. | "never"
  80774. | "less"
  80775. | "equal"
  80776. | "less-equal"
  80777. | "greater"
  80778. | "not-equal"
  80779. | "greater-equal"
  80780. | "always";
  80781. type GPUCullMode = "none" | "front" | "back";
  80782. type GPUFilterMode = "nearest" | "linear";
  80783. type GPUFrontFace = "ccw" | "cw";
  80784. type GPUIndexFormat = "uint16" | "uint32";
  80785. type GPUInputStepMode = "vertex" | "instance";
  80786. type GPULoadOp = "load";
  80787. type GPUPrimitiveTopology =
  80788. | "point-list"
  80789. | "line-list"
  80790. | "line-strip"
  80791. | "triangle-list"
  80792. | "triangle-strip";
  80793. type GPUStencilOperation =
  80794. | "keep"
  80795. | "zero"
  80796. | "replace"
  80797. | "invert"
  80798. | "increment-clamp"
  80799. | "decrement-clamp"
  80800. | "increment-wrap"
  80801. | "decrement-wrap";
  80802. type GPUStoreOp = "store" | "clear";
  80803. type GPUTextureDimension = "1d" | "2d" | "3d";
  80804. type GPUTextureFormat =
  80805. | "r8unorm"
  80806. | "r8snorm"
  80807. | "r8uint"
  80808. | "r8sint"
  80809. | "r16uint"
  80810. | "r16sint"
  80811. | "r16float"
  80812. | "rg8unorm"
  80813. | "rg8snorm"
  80814. | "rg8uint"
  80815. | "rg8sint"
  80816. | "r32uint"
  80817. | "r32sint"
  80818. | "r32float"
  80819. | "rg16uint"
  80820. | "rg16sint"
  80821. | "rg16float"
  80822. | "rgba8unorm"
  80823. | "rgba8unorm-srgb"
  80824. | "rgba8snorm"
  80825. | "rgba8uint"
  80826. | "rgba8sint"
  80827. | "bgra8unorm"
  80828. | "bgra8unorm-srgb"
  80829. | "rgb9e5ufloat"
  80830. | "rgb10a2unorm"
  80831. | "rg11b10ufloat"
  80832. | "rg32uint"
  80833. | "rg32sint"
  80834. | "rg32float"
  80835. | "rgba16uint"
  80836. | "rgba16sint"
  80837. | "rgba16float"
  80838. | "rgba32uint"
  80839. | "rgba32sint"
  80840. | "rgba32float"
  80841. | "stencil8"
  80842. | "depth16unorm"
  80843. | "depth24plus"
  80844. | "depth24plus-stencil8"
  80845. | "depth32float"
  80846. | "bc1-rgba-unorm"
  80847. | "bc1-rgba-unorm-srgb"
  80848. | "bc2-rgba-unorm"
  80849. | "bc2-rgba-unorm-srgb"
  80850. | "bc3-rgba-unorm"
  80851. | "bc3-rgba-unorm-srgb"
  80852. | "bc4-r-unorm"
  80853. | "bc4-r-snorm"
  80854. | "bc5-rg-unorm"
  80855. | "bc5-rg-snorm"
  80856. | "bc6h-rgb-ufloat"
  80857. | "bc6h-rgb-float"
  80858. | "bc7-rgba-unorm"
  80859. | "bc7-rgba-unorm-srgb"
  80860. | "depth24unorm-stencil8"
  80861. | "depth32float-stencil8";
  80862. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80863. type GPUTextureViewDimension =
  80864. | "1d"
  80865. | "2d"
  80866. | "2d-array"
  80867. | "cube"
  80868. | "cube-array"
  80869. | "3d";
  80870. type GPUVertexFormat =
  80871. | "uchar2"
  80872. | "uchar4"
  80873. | "char2"
  80874. | "char4"
  80875. | "uchar2norm"
  80876. | "uchar4norm"
  80877. | "char2norm"
  80878. | "char4norm"
  80879. | "ushort2"
  80880. | "ushort4"
  80881. | "short2"
  80882. | "short4"
  80883. | "ushort2norm"
  80884. | "ushort4norm"
  80885. | "short2norm"
  80886. | "short4norm"
  80887. | "half2"
  80888. | "half4"
  80889. | "float"
  80890. | "float2"
  80891. | "float3"
  80892. | "float4"
  80893. | "uint"
  80894. | "uint2"
  80895. | "uint3"
  80896. | "uint4"
  80897. | "int"
  80898. | "int2"
  80899. | "int3"
  80900. | "int4";
  80901. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80902. type GPUBufferUsageFlags = number;
  80903. type GPUColorWriteFlags = number;
  80904. type GPUShaderStageFlags = number;
  80905. type GPUTextureUsageFlags = number;
  80906. type GPUMapModeFlags = number;
  80907. interface GPUBindGroupEntry {
  80908. binding: number;
  80909. resource: GPUBindingResource;
  80910. }
  80911. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80912. layout: GPUBindGroupLayout;
  80913. entries: Iterable<GPUBindGroupEntry>;
  80914. }
  80915. interface GPUBindGroupLayoutEntry {
  80916. binding: number;
  80917. visibility: GPUShaderStageFlags;
  80918. type: GPUBindingType;
  80919. hasDynamicOffset?: boolean;
  80920. minBufferBindingSize?: number;
  80921. viewDimension?: GPUTextureViewDimension;
  80922. textureComponentType?: GPUTextureComponentType;
  80923. storageTextureFormat?: GPUTextureFormat;
  80924. }
  80925. interface GPUBindGroupLayoutDescriptor
  80926. extends GPUObjectDescriptorBase {
  80927. entries: Iterable<GPUBindGroupLayoutEntry>;
  80928. }
  80929. interface GPUBlendDescriptor {
  80930. dstFactor?: GPUBlendFactor;
  80931. operation?: GPUBlendOperation;
  80932. srcFactor?: GPUBlendFactor;
  80933. }
  80934. interface GPUColorStateDescriptor {
  80935. format: GPUTextureFormat;
  80936. alphaBlend?: GPUBlendDescriptor;
  80937. colorBlend?: GPUBlendDescriptor;
  80938. writeMask?: GPUColorWriteFlags;
  80939. }
  80940. interface GPUBufferBinding {
  80941. buffer: GPUBuffer;
  80942. offset?: number;
  80943. size?: number;
  80944. }
  80945. interface GPUTextureDataLayout {
  80946. offset?: number;
  80947. bytesPerRow: number;
  80948. rowsPerImage?: number;
  80949. }
  80950. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80951. buffer: GPUBuffer;
  80952. }
  80953. interface GPUTextureCopyView {
  80954. texture: GPUTexture;
  80955. mipLevel?: number;
  80956. origin?: GPUOrigin3D;
  80957. }
  80958. interface GPUImageBitmapCopyView {
  80959. imageBitmap: ImageBitmap;
  80960. origin?: GPUOrigin2D;
  80961. }
  80962. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80963. size: number;
  80964. usage: GPUBufferUsageFlags;
  80965. mappedAtCreation?: boolean;
  80966. }
  80967. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80968. label?: string;
  80969. measureExecutionTime?: boolean;
  80970. }
  80971. interface GPUComputePipelineDescriptor
  80972. extends GPUPipelineDescriptorBase {
  80973. computeStage: GPUProgrammableStageDescriptor;
  80974. }
  80975. interface GPUDepthStencilStateDescriptor {
  80976. format: GPUTextureFormat;
  80977. depthWriteEnabled?: boolean;
  80978. depthCompare?: GPUCompareFunction;
  80979. stencilFront?: GPUStencilStateFaceDescriptor;
  80980. stencilBack?: GPUStencilStateFaceDescriptor;
  80981. stencilReadMask?: number;
  80982. stencilWriteMask?: number;
  80983. }
  80984. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80985. extensions?: Iterable<GPUExtensionName>;
  80986. limits?: GPULimits;
  80987. }
  80988. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80989. initialValue?: number;
  80990. label?: string;
  80991. signalQueue?: GPUQueue;
  80992. }
  80993. interface GPUVertexAttributeDescriptor {
  80994. format: GPUVertexFormat;
  80995. offset: number;
  80996. shaderLocation: number;
  80997. }
  80998. interface GPUVertexBufferLayoutDescriptor {
  80999. arrayStride: number;
  81000. stepMode?: GPUInputStepMode;
  81001. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81002. }
  81003. interface GPUVertexStateDescriptor {
  81004. indexFormat?: GPUIndexFormat;
  81005. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81006. }
  81007. interface GPULimits {
  81008. maxBindGroups?: number;
  81009. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81010. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81011. maxSampledTexturesPerShaderStage?: number;
  81012. maxSamplersPerShaderStage?: number;
  81013. maxStorageBuffersPerShaderStage?: number;
  81014. maxStorageTexturesPerShaderStage?: number;
  81015. maxUniformBuffersPerShaderStage?: number;
  81016. maxUniformBufferBindingSize?: number;
  81017. }
  81018. interface GPUPipelineDescriptorBase {
  81019. label?: string;
  81020. layout?: GPUPipelineLayout;
  81021. }
  81022. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81023. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81024. }
  81025. interface GPUProgrammableStageDescriptor {
  81026. module: GPUShaderModule;
  81027. entryPoint: string;
  81028. }
  81029. interface GPURasterizationStateDescriptor {
  81030. frontFace?: GPUFrontFace;
  81031. cullMode?: GPUCullMode;
  81032. clampDepth?: boolean;
  81033. depthBias?: number;
  81034. depthBiasSlopeScale?: number;
  81035. depthBiasClamp?: number;
  81036. }
  81037. interface GPURenderPassColorAttachmentDescriptor {
  81038. attachment: GPUTextureView;
  81039. resolveTarget?: GPUTextureView;
  81040. loadValue: GPULoadOp | GPUColor;
  81041. storeOp?: GPUStoreOp;
  81042. }
  81043. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81044. attachment: GPUTextureView;
  81045. depthLoadValue: GPULoadOp | number;
  81046. depthStoreOp: GPUStoreOp;
  81047. depthReadOnly?: boolean;
  81048. stencilLoadValue: GPULoadOp | number;
  81049. stencilStoreOp: GPUStoreOp;
  81050. stencilReadOnly?: boolean;
  81051. }
  81052. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81053. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81054. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81055. }
  81056. interface GPURenderPipelineDescriptor
  81057. extends GPUPipelineDescriptorBase {
  81058. vertexStage: GPUProgrammableStageDescriptor;
  81059. fragmentStage?: GPUProgrammableStageDescriptor;
  81060. primitiveTopology: GPUPrimitiveTopology;
  81061. rasterizationState?: GPURasterizationStateDescriptor;
  81062. colorStates: Iterable<GPUColorStateDescriptor>;
  81063. depthStencilState?: GPUDepthStencilStateDescriptor;
  81064. vertexState?: GPUVertexStateDescriptor;
  81065. sampleCount?: number;
  81066. sampleMask?: number;
  81067. alphaToCoverageEnabled?: boolean;
  81068. }
  81069. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81070. addressModeU?: GPUAddressMode;
  81071. addressModeV?: GPUAddressMode;
  81072. addressModeW?: GPUAddressMode;
  81073. magFilter?: GPUFilterMode;
  81074. minFilter?: GPUFilterMode;
  81075. mipmapFilter?: GPUFilterMode;
  81076. lodMinClamp?: number;
  81077. lodMaxClamp?: number;
  81078. compare?: GPUCompareFunction;
  81079. maxAnisotropy?: number;
  81080. }
  81081. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81082. code: Uint32Array | string;
  81083. label?: string;
  81084. sourceMap?: object;
  81085. }
  81086. interface GPUStencilStateFaceDescriptor {
  81087. compare?: GPUCompareFunction;
  81088. depthFailOp?: GPUStencilOperation;
  81089. passOp?: GPUStencilOperation;
  81090. failOp?: GPUStencilOperation;
  81091. }
  81092. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81093. device: GPUDevice;
  81094. format: GPUTextureFormat;
  81095. usage?: GPUTextureUsageFlags;
  81096. }
  81097. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81098. size: GPUExtent3D;
  81099. mipLevelCount?: number;
  81100. sampleCount?: number;
  81101. dimension?: GPUTextureDimension;
  81102. format: GPUTextureFormat;
  81103. usage: GPUTextureUsageFlags;
  81104. }
  81105. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81106. format?: GPUTextureFormat;
  81107. dimension?: GPUTextureViewDimension;
  81108. aspect?: GPUTextureAspect;
  81109. baseArrayLayer?: number;
  81110. baseMipLevel?: number;
  81111. arrayLayerCount?: number;
  81112. mipLevelCount?: number;
  81113. }
  81114. declare class GPUAdapter {
  81115. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81116. private __brand: void;
  81117. readonly name: string;
  81118. readonly extensions: GPUExtensionName[];
  81119. readonly limits: Required<GPULimits>;
  81120. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81121. }
  81122. declare class GPUBindGroup implements GPUObjectBase {
  81123. private __brand: void;
  81124. label: string | undefined;
  81125. }
  81126. declare class GPUBindGroupLayout implements GPUObjectBase {
  81127. private __brand: void;
  81128. label: string | undefined;
  81129. }
  81130. declare class GPUBuffer implements GPUObjectBase {
  81131. private __brand: void;
  81132. label: string | undefined;
  81133. destroy(): void;
  81134. unmap(): void;
  81135. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81136. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81137. }
  81138. declare class GPUCommandBuffer implements GPUObjectBase {
  81139. private __brand: void;
  81140. label: string | undefined;
  81141. readonly executionTime: Promise<number>;
  81142. }
  81143. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81144. declare class GPUCommandEncoder implements GPUObjectBase {
  81145. private __brand: void;
  81146. label: string | undefined;
  81147. beginComputePass(
  81148. descriptor?: GPUComputePassDescriptor
  81149. ): GPUComputePassEncoder;
  81150. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81151. copyBufferToBuffer(
  81152. source: GPUBuffer,
  81153. sourceOffset: number,
  81154. destination: GPUBuffer,
  81155. destinationOffset: number,
  81156. size: number
  81157. ): void;
  81158. copyBufferToTexture(
  81159. source: GPUBufferCopyView,
  81160. destination: GPUTextureCopyView,
  81161. copySize: GPUExtent3D
  81162. ): void;
  81163. copyTextureToBuffer(
  81164. source: GPUTextureCopyView,
  81165. destination: GPUBufferCopyView,
  81166. copySize: GPUExtent3D
  81167. ): void;
  81168. copyTextureToTexture(
  81169. source: GPUTextureCopyView,
  81170. destination: GPUTextureCopyView,
  81171. copySize: GPUExtent3D
  81172. ): void;
  81173. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81174. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81175. popDebugGroup(): void;
  81176. pushDebugGroup(groupLabel: string): void;
  81177. insertDebugMarker(markerLabel: string): void;
  81178. }
  81179. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81180. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81181. private __brand: void;
  81182. label: string | undefined;
  81183. setBindGroup(
  81184. index: number,
  81185. bindGroup: GPUBindGroup,
  81186. dynamicOffsets?: Iterable<number>
  81187. ): void;
  81188. popDebugGroup(): void;
  81189. pushDebugGroup(groupLabel: string): void;
  81190. insertDebugMarker(markerLabel: string): void;
  81191. setPipeline(pipeline: GPUComputePipeline): void;
  81192. dispatch(x: number, y?: number, z?: number): void;
  81193. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81194. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81195. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81196. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81197. endPass(): void;
  81198. }
  81199. declare class GPUComputePipeline implements GPUPipelineBase {
  81200. private __brand: void;
  81201. label: string | undefined;
  81202. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81203. }
  81204. interface GPUObjectBase {
  81205. label: string | undefined;
  81206. }
  81207. interface GPUObjectDescriptorBase {
  81208. label?: string;
  81209. }
  81210. // SwapChain / CanvasContext
  81211. declare class GPUCanvasContext {
  81212. private __brand: void;
  81213. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81214. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81215. }
  81216. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81217. private __brand: void;
  81218. label: string | undefined;
  81219. readonly adapter: GPUAdapter;
  81220. readonly extensions: GPUExtensionName[];
  81221. readonly limits: Required<GPULimits>;
  81222. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81223. createBindGroupLayout(
  81224. descriptor: GPUBindGroupLayoutDescriptor
  81225. ): GPUBindGroupLayout;
  81226. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81227. createPipelineLayout(
  81228. descriptor: GPUPipelineLayoutDescriptor
  81229. ): GPUPipelineLayout;
  81230. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81231. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81232. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81233. createComputePipeline(
  81234. descriptor: GPUComputePipelineDescriptor
  81235. ): GPUComputePipeline;
  81236. createRenderPipeline(
  81237. descriptor: GPURenderPipelineDescriptor
  81238. ): GPURenderPipeline;
  81239. createReadyComputePipeline(
  81240. descriptor: GPUComputePipelineDescriptor
  81241. ): Promise<GPUComputePipeline>;
  81242. createReadyRenderPipeline(
  81243. descriptor: GPURenderPipelineDescriptor
  81244. ): Promise<GPURenderPipeline>;
  81245. createCommandEncoder(
  81246. descriptor?: GPUCommandEncoderDescriptor
  81247. ): GPUCommandEncoder;
  81248. createRenderBundleEncoder(
  81249. descriptor: GPURenderBundleEncoderDescriptor
  81250. ): GPURenderBundleEncoder;
  81251. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81252. defaultQueue: GPUQueue;
  81253. pushErrorScope(filter: GPUErrorFilter): void;
  81254. popErrorScope(): Promise<GPUError | null>;
  81255. onuncapturederror: Event | undefined;
  81256. readonly lost: Promise<GPUDeviceLostInfo>;
  81257. }
  81258. declare class GPUFence implements GPUObjectBase {
  81259. private __brand: void;
  81260. label: string | undefined;
  81261. getCompletedValue(): number;
  81262. onCompletion(completionValue: number): Promise<void>;
  81263. }
  81264. interface GPUPipelineBase extends GPUObjectBase {
  81265. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81266. }
  81267. declare class GPUPipelineLayout implements GPUObjectBase {
  81268. private __brand: void;
  81269. label: string | undefined;
  81270. }
  81271. interface GPUProgrammablePassEncoder {
  81272. setBindGroup(
  81273. index: number,
  81274. bindGroup: GPUBindGroup,
  81275. dynamicOffsets?: Iterable<number>
  81276. ): void;
  81277. popDebugGroup(): void;
  81278. pushDebugGroup(groupLabel: string): void;
  81279. insertDebugMarker(markerLabel: string): void;
  81280. }
  81281. declare class GPUQueue implements GPUObjectBase {
  81282. private __brand: void;
  81283. label: string | undefined;
  81284. signal(fence: GPUFence, signalValue: number): void;
  81285. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81286. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81287. writeBuffer(buffer: GPUBuffer,
  81288. bufferOffset: number,
  81289. data: BufferSource | ArrayBuffer,
  81290. dataOffset?: number,
  81291. size?: number): void;
  81292. writeTexture(destination: GPUTextureCopyView,
  81293. data: BufferSource | ArrayBuffer,
  81294. dataLayout: GPUTextureDataLayout,
  81295. size: GPUExtent3D): void;
  81296. copyImageBitmapToTexture(
  81297. source: GPUImageBitmapCopyView,
  81298. destination: GPUTextureCopyView,
  81299. copySize: GPUExtent3D
  81300. ): void;
  81301. }
  81302. type GPUQueryType =
  81303. | "occlusion"
  81304. | "timestamp"
  81305. | "pipeline-statistics";
  81306. type GPUPipelineStatisticName =
  81307. | "vertex-shader-invocations"
  81308. | "clipper-invocations"
  81309. | "clipper-primitives-out"
  81310. | "fragment-shader-invocations"
  81311. | "compute-shader-invocations";
  81312. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81313. type: GPUQueryType;
  81314. count: number;
  81315. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81316. }
  81317. declare class GPUQuerySet implements GPUObjectBase {
  81318. private __brand: void;
  81319. label: string | undefined;
  81320. destroy(): void;
  81321. }
  81322. interface GPURenderEncoderBase {
  81323. setPipeline(pipeline: GPURenderPipeline): void;
  81324. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81325. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81326. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81327. draw(
  81328. vertexCount: number,
  81329. instanceCount?: number,
  81330. firstVertex?: number,
  81331. firstInstance?: number
  81332. ): void;
  81333. drawIndexed(
  81334. indexCount: number,
  81335. instanceCount?: number,
  81336. firstIndex?: number,
  81337. baseVertex?: number,
  81338. firstInstance?: number
  81339. ): void;
  81340. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81341. drawIndexedIndirect(
  81342. indirectBuffer: GPUBuffer,
  81343. indirectOffset: number
  81344. ): void;
  81345. }
  81346. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81347. private __brand: void;
  81348. label: string | undefined;
  81349. setBindGroup(
  81350. index: number,
  81351. bindGroup: GPUBindGroup,
  81352. dynamicOffsets?: Iterable<number>
  81353. ): void;
  81354. popDebugGroup(): void;
  81355. pushDebugGroup(groupLabel: string): void;
  81356. insertDebugMarker(markerLabel: string): void;
  81357. setPipeline(pipeline: GPURenderPipeline): void;
  81358. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81359. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81360. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81361. draw(
  81362. vertexCount: number,
  81363. instanceCount?: number,
  81364. firstVertex?: number,
  81365. firstInstance?: number
  81366. ): void;
  81367. drawIndexed(
  81368. indexCount: number,
  81369. instanceCount?: number,
  81370. firstIndex?: number,
  81371. baseVertex?: number,
  81372. firstInstance?: number
  81373. ): void;
  81374. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81375. drawIndexedIndirect(
  81376. indirectBuffer: GPUBuffer,
  81377. indirectOffset: number
  81378. ): void;
  81379. setViewport(
  81380. x: number,
  81381. y: number,
  81382. width: number,
  81383. height: number,
  81384. minDepth: number,
  81385. maxDepth: number
  81386. ): void;
  81387. setScissorRect(x: number, y: number, width: number, height: number): void;
  81388. setBlendColor(color: GPUColor): void;
  81389. setStencilReference(reference: number): void;
  81390. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81391. beginOcclusionQuery(queryIndex: number): void;
  81392. endOcclusionQuery(): void;
  81393. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81394. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81395. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81396. endPass(): void;
  81397. }
  81398. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81399. declare class GPURenderBundle implements GPUObjectBase {
  81400. private __brand: void;
  81401. label: string | undefined;
  81402. }
  81403. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81404. private __brand: void;
  81405. label: string | undefined;
  81406. setBindGroup(
  81407. index: number,
  81408. bindGroup: GPUBindGroup,
  81409. dynamicOffsets?: Iterable<number>
  81410. ): void;
  81411. popDebugGroup(): void;
  81412. pushDebugGroup(groupLabel: string): void;
  81413. insertDebugMarker(markerLabel: string): void;
  81414. setPipeline(pipeline: GPURenderPipeline): void;
  81415. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81416. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81417. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81418. draw(
  81419. vertexCount: number,
  81420. instanceCount?: number,
  81421. firstVertex?: number,
  81422. firstInstance?: number
  81423. ): void;
  81424. drawIndexed(
  81425. indexCount: number,
  81426. instanceCount?: number,
  81427. firstIndex?: number,
  81428. baseVertex?: number,
  81429. firstInstance?: number
  81430. ): void;
  81431. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81432. drawIndexedIndirect(
  81433. indirectBuffer: GPUBuffer,
  81434. indirectOffset: number
  81435. ): void;
  81436. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81437. }
  81438. interface GPURenderBundleEncoderDescriptor
  81439. extends GPUObjectDescriptorBase {
  81440. colorFormats: Iterable<GPUTextureFormat>;
  81441. depthStencilFormat?: GPUTextureFormat;
  81442. sampleCount?: number;
  81443. }
  81444. declare class GPURenderPipeline implements GPUPipelineBase {
  81445. private __brand: void;
  81446. label: string | undefined;
  81447. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81448. }
  81449. declare class GPUSampler implements GPUObjectBase {
  81450. private __brand: void;
  81451. label: string | undefined;
  81452. }
  81453. type GPUCompilationMessageType =
  81454. | "error"
  81455. | "warning"
  81456. | "info";
  81457. interface GPUCompilationMessage {
  81458. readonly message: string;
  81459. readonly type: GPUCompilationMessageType;
  81460. readonly lineNum: number;
  81461. readonly linePos: number;
  81462. }
  81463. interface GPUCompilationInfo {
  81464. readonly messages: readonly GPUCompilationMessage[];
  81465. }
  81466. declare class GPUShaderModule implements GPUObjectBase {
  81467. private __brand: void;
  81468. label: string | undefined;
  81469. compilationInfo(): Promise<GPUCompilationInfo>;
  81470. }
  81471. declare class GPUSwapChain implements GPUObjectBase {
  81472. private __brand: void;
  81473. label: string | undefined;
  81474. getCurrentTexture(): GPUTexture;
  81475. }
  81476. declare class GPUTexture implements GPUObjectBase {
  81477. private __brand: void;
  81478. label: string | undefined;
  81479. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81480. destroy(): void;
  81481. }
  81482. declare class GPUTextureView implements GPUObjectBase {
  81483. private __brand: void;
  81484. label: string | undefined;
  81485. }
  81486. type GPUPowerPreference = "low-power" | "high-performance";
  81487. interface GPURequestAdapterOptions {
  81488. powerPreference?: GPUPowerPreference;
  81489. }
  81490. declare class GPU {
  81491. private __brand: void;
  81492. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81493. }
  81494. // ****************************************************************************
  81495. // ERROR SCOPES
  81496. // ****************************************************************************
  81497. type GPUErrorFilter = "out-of-memory" | "validation";
  81498. declare class GPUOutOfMemoryError {
  81499. private __brand: void;
  81500. constructor();
  81501. }
  81502. declare class GPUValidationError {
  81503. private __brand: void;
  81504. constructor(message: string);
  81505. readonly message: string;
  81506. }
  81507. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81508. // ****************************************************************************
  81509. // TELEMETRY
  81510. // ****************************************************************************
  81511. declare class GPUUncapturedErrorEvent extends Event {
  81512. private __brand: void;
  81513. constructor(
  81514. type: string,
  81515. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81516. );
  81517. readonly error: GPUError;
  81518. }
  81519. interface GPUUncapturedErrorEventInit extends EventInit {
  81520. error: GPUError;
  81521. }
  81522. declare class GPUDeviceLostInfo {
  81523. private __brand: void;
  81524. readonly message: string;
  81525. }
  81526. // Type definitions for WebVR API
  81527. // Project: https://w3c.github.io/webvr/
  81528. // Definitions by: six a <https://github.com/lostfictions>
  81529. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81530. interface VRDisplay extends EventTarget {
  81531. /**
  81532. * Dictionary of capabilities describing the VRDisplay.
  81533. */
  81534. readonly capabilities: VRDisplayCapabilities;
  81535. /**
  81536. * z-depth defining the far plane of the eye view frustum
  81537. * enables mapping of values in the render target depth
  81538. * attachment to scene coordinates. Initially set to 10000.0.
  81539. */
  81540. depthFar: number;
  81541. /**
  81542. * z-depth defining the near plane of the eye view frustum
  81543. * enables mapping of values in the render target depth
  81544. * attachment to scene coordinates. Initially set to 0.01.
  81545. */
  81546. depthNear: number;
  81547. /**
  81548. * An identifier for this distinct VRDisplay. Used as an
  81549. * association point in the Gamepad API.
  81550. */
  81551. readonly displayId: number;
  81552. /**
  81553. * A display name, a user-readable name identifying it.
  81554. */
  81555. readonly displayName: string;
  81556. readonly isConnected: boolean;
  81557. readonly isPresenting: boolean;
  81558. /**
  81559. * If this VRDisplay supports room-scale experiences, the optional
  81560. * stage attribute contains details on the room-scale parameters.
  81561. */
  81562. readonly stageParameters: VRStageParameters | null;
  81563. /**
  81564. * Passing the value returned by `requestAnimationFrame` to
  81565. * `cancelAnimationFrame` will unregister the callback.
  81566. * @param handle Define the hanle of the request to cancel
  81567. */
  81568. cancelAnimationFrame(handle: number): void;
  81569. /**
  81570. * Stops presenting to the VRDisplay.
  81571. * @returns a promise to know when it stopped
  81572. */
  81573. exitPresent(): Promise<void>;
  81574. /**
  81575. * Return the current VREyeParameters for the given eye.
  81576. * @param whichEye Define the eye we want the parameter for
  81577. * @returns the eye parameters
  81578. */
  81579. getEyeParameters(whichEye: string): VREyeParameters;
  81580. /**
  81581. * Populates the passed VRFrameData with the information required to render
  81582. * the current frame.
  81583. * @param frameData Define the data structure to populate
  81584. * @returns true if ok otherwise false
  81585. */
  81586. getFrameData(frameData: VRFrameData): boolean;
  81587. /**
  81588. * Get the layers currently being presented.
  81589. * @returns the list of VR layers
  81590. */
  81591. getLayers(): VRLayer[];
  81592. /**
  81593. * Return a VRPose containing the future predicted pose of the VRDisplay
  81594. * when the current frame will be presented. The value returned will not
  81595. * change until JavaScript has returned control to the browser.
  81596. *
  81597. * The VRPose will contain the position, orientation, velocity,
  81598. * and acceleration of each of these properties.
  81599. * @returns the pose object
  81600. */
  81601. getPose(): VRPose;
  81602. /**
  81603. * Return the current instantaneous pose of the VRDisplay, with no
  81604. * prediction applied.
  81605. * @returns the current instantaneous pose
  81606. */
  81607. getImmediatePose(): VRPose;
  81608. /**
  81609. * The callback passed to `requestAnimationFrame` will be called
  81610. * any time a new frame should be rendered. When the VRDisplay is
  81611. * presenting the callback will be called at the native refresh
  81612. * rate of the HMD. When not presenting this function acts
  81613. * identically to how window.requestAnimationFrame acts. Content should
  81614. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81615. * asynchronously from other displays and at differing refresh rates.
  81616. * @param callback Define the eaction to run next frame
  81617. * @returns the request handle it
  81618. */
  81619. requestAnimationFrame(callback: FrameRequestCallback): number;
  81620. /**
  81621. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81622. * Repeat calls while already presenting will update the VRLayers being displayed.
  81623. * @param layers Define the list of layer to present
  81624. * @returns a promise to know when the request has been fulfilled
  81625. */
  81626. requestPresent(layers: VRLayer[]): Promise<void>;
  81627. /**
  81628. * Reset the pose for this display, treating its current position and
  81629. * orientation as the "origin/zero" values. VRPose.position,
  81630. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81631. * updated when calling resetPose(). This should be called in only
  81632. * sitting-space experiences.
  81633. */
  81634. resetPose(): void;
  81635. /**
  81636. * The VRLayer provided to the VRDisplay will be captured and presented
  81637. * in the HMD. Calling this function has the same effect on the source
  81638. * canvas as any other operation that uses its source image, and canvases
  81639. * created without preserveDrawingBuffer set to true will be cleared.
  81640. * @param pose Define the pose to submit
  81641. */
  81642. submitFrame(pose?: VRPose): void;
  81643. }
  81644. declare var VRDisplay: {
  81645. prototype: VRDisplay;
  81646. new(): VRDisplay;
  81647. };
  81648. interface VRLayer {
  81649. leftBounds?: number[] | Float32Array | null;
  81650. rightBounds?: number[] | Float32Array | null;
  81651. source?: HTMLCanvasElement | null;
  81652. }
  81653. interface VRDisplayCapabilities {
  81654. readonly canPresent: boolean;
  81655. readonly hasExternalDisplay: boolean;
  81656. readonly hasOrientation: boolean;
  81657. readonly hasPosition: boolean;
  81658. readonly maxLayers: number;
  81659. }
  81660. interface VREyeParameters {
  81661. /** @deprecated */
  81662. readonly fieldOfView: VRFieldOfView;
  81663. readonly offset: Float32Array;
  81664. readonly renderHeight: number;
  81665. readonly renderWidth: number;
  81666. }
  81667. interface VRFieldOfView {
  81668. readonly downDegrees: number;
  81669. readonly leftDegrees: number;
  81670. readonly rightDegrees: number;
  81671. readonly upDegrees: number;
  81672. }
  81673. interface VRFrameData {
  81674. readonly leftProjectionMatrix: Float32Array;
  81675. readonly leftViewMatrix: Float32Array;
  81676. readonly pose: VRPose;
  81677. readonly rightProjectionMatrix: Float32Array;
  81678. readonly rightViewMatrix: Float32Array;
  81679. readonly timestamp: number;
  81680. }
  81681. interface VRPose {
  81682. readonly angularAcceleration: Float32Array | null;
  81683. readonly angularVelocity: Float32Array | null;
  81684. readonly linearAcceleration: Float32Array | null;
  81685. readonly linearVelocity: Float32Array | null;
  81686. readonly orientation: Float32Array | null;
  81687. readonly position: Float32Array | null;
  81688. readonly timestamp: number;
  81689. }
  81690. interface VRStageParameters {
  81691. sittingToStandingTransform?: Float32Array;
  81692. sizeX?: number;
  81693. sizeY?: number;
  81694. }
  81695. interface Navigator {
  81696. getVRDisplays(): Promise<VRDisplay[]>;
  81697. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81698. }
  81699. interface Window {
  81700. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81701. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81702. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81703. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81704. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81705. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81706. }
  81707. interface Gamepad {
  81708. readonly displayId: number;
  81709. }
  81710. /**
  81711. * Available session modes
  81712. */
  81713. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81714. /**
  81715. * Reference space types
  81716. */
  81717. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81718. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81719. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81720. /**
  81721. * Handedness types
  81722. */
  81723. type XRHandedness = "none" | "left" | "right";
  81724. /**
  81725. * InputSource target ray modes
  81726. */
  81727. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81728. /**
  81729. * Eye types
  81730. */
  81731. type XREye = "none" | "left" | "right";
  81732. /**
  81733. * Type of XR events available
  81734. */
  81735. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81736. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81737. type XRPlaneSet = Set<XRPlane>;
  81738. type XRAnchorSet = Set<XRAnchor>;
  81739. type XREventHandler = (callback: any) => void;
  81740. interface XRLayer extends EventTarget {}
  81741. interface XRSessionInit {
  81742. optionalFeatures?: string[];
  81743. requiredFeatures?: string[];
  81744. trackedImages?: XRTrackedImageInit[];
  81745. }
  81746. interface XRSessionEvent extends Event {
  81747. readonly session: XRSession;
  81748. }
  81749. interface XRSystem {
  81750. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81751. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81752. }
  81753. interface XRViewport {
  81754. readonly x: number;
  81755. readonly y: number;
  81756. readonly width: number;
  81757. readonly height: number;
  81758. }
  81759. interface XRWebGLLayerInit {
  81760. antialias?: boolean;
  81761. depth?: boolean;
  81762. stencil?: boolean;
  81763. alpha?: boolean;
  81764. multiview?: boolean;
  81765. framebufferScaleFactor?: number;
  81766. }
  81767. declare class XRWebGLLayer {
  81768. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81769. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81770. readonly antialias: boolean;
  81771. readonly framebuffer: WebGLFramebuffer;
  81772. readonly framebufferWidth: number;
  81773. readonly framebufferHeight: number;
  81774. readonly ignoreDepthValues: boolean;
  81775. getViewport: (view: XRView) => XRViewport;
  81776. }
  81777. // tslint:disable-next-line no-empty-interface
  81778. interface XRSpace extends EventTarget {}
  81779. interface XRRenderState {
  81780. readonly baseLayer?: XRWebGLLayer;
  81781. readonly depthFar: number;
  81782. readonly depthNear: number;
  81783. readonly inlineVerticalFieldOfView?: number;
  81784. }
  81785. interface XRRenderStateInit extends XRRenderState {
  81786. baseLayer: XRWebGLLayer;
  81787. depthFar: number;
  81788. depthNear: number;
  81789. inlineVerticalFieldOfView?: number;
  81790. layers?: XRLayer[];
  81791. }
  81792. interface XRReferenceSpace extends XRSpace {
  81793. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81794. onreset: XREventHandler;
  81795. }
  81796. interface XRBoundedReferenceSpace extends XRSpace {
  81797. readonly boundsGeometry: DOMPointReadOnly[];
  81798. }
  81799. interface XRInputSource {
  81800. readonly handedness: XRHandedness;
  81801. readonly targetRayMode: XRTargetRayMode;
  81802. readonly targetRaySpace: XRSpace;
  81803. readonly gripSpace?: XRSpace;
  81804. readonly gamepad?: Gamepad;
  81805. readonly profiles: Array<string>;
  81806. readonly hand?: XRHand;
  81807. }
  81808. interface XRPose {
  81809. readonly transform: XRRigidTransform;
  81810. readonly emulatedPosition: boolean;
  81811. }
  81812. interface XRWorldInformation {
  81813. detectedPlanes?: XRPlaneSet;
  81814. }
  81815. interface XRFrame {
  81816. readonly session: XRSession;
  81817. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81818. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81819. // AR
  81820. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81821. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81822. // Anchors
  81823. trackedAnchors?: XRAnchorSet;
  81824. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81825. // World geometries
  81826. worldInformation?: XRWorldInformation;
  81827. // Hand tracking
  81828. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81829. // Image tracking
  81830. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81831. }
  81832. interface XRInputSourceEvent extends Event {
  81833. readonly frame: XRFrame;
  81834. readonly inputSource: XRInputSource;
  81835. }
  81836. type XRInputSourceArray = XRInputSource[];
  81837. interface XRSession {
  81838. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81839. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81840. /**
  81841. * Returns a list of this session's XRInputSources, each representing an input device
  81842. * used to control the camera and/or scene.
  81843. */
  81844. readonly inputSources: Array<XRInputSource>;
  81845. /**
  81846. * object which contains options affecting how the imagery is rendered.
  81847. * This includes things such as the near and far clipping planes
  81848. */
  81849. readonly renderState: XRRenderState;
  81850. readonly visibilityState: XRVisibilityState;
  81851. /**
  81852. * Removes a callback from the animation frame painting callback from
  81853. * XRSession's set of animation frame rendering callbacks, given the
  81854. * identifying handle returned by a previous call to requestAnimationFrame().
  81855. */
  81856. cancelAnimationFrame: (handle: number) => void;
  81857. /**
  81858. * Ends the WebXR session. Returns a promise which resolves when the
  81859. * session has been shut down.
  81860. */
  81861. end(): Promise<void>;
  81862. /**
  81863. * Schedules the specified method to be called the next time the user agent
  81864. * is working on rendering an animation frame for the WebXR device. Returns an
  81865. * integer value which can be used to identify the request for the purposes of
  81866. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81867. * to the Window.requestAnimationFrame() method.
  81868. */
  81869. requestAnimationFrame: XRFrameRequestCallback;
  81870. /**
  81871. * Requests that a new XRReferenceSpace of the specified type be created.
  81872. * Returns a promise which resolves with the XRReferenceSpace or
  81873. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81874. * the requested space type isn't supported by the device.
  81875. */
  81876. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81877. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81878. onend: XREventHandler;
  81879. oninputsourceschange: XREventHandler;
  81880. onselect: XREventHandler;
  81881. onselectstart: XREventHandler;
  81882. onselectend: XREventHandler;
  81883. onsqueeze: XREventHandler;
  81884. onsqueezestart: XREventHandler;
  81885. onsqueezeend: XREventHandler;
  81886. onvisibilitychange: XREventHandler;
  81887. // hit test
  81888. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81889. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81890. // legacy AR hit test
  81891. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81892. // legacy plane detection
  81893. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81894. // image tracking
  81895. getTrackedImageScores?(): XRImageTrackingScore[];
  81896. }
  81897. interface XRViewerPose extends XRPose {
  81898. readonly views: Array<XRView>;
  81899. }
  81900. declare class XRRigidTransform {
  81901. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81902. position: DOMPointReadOnly;
  81903. orientation: DOMPointReadOnly;
  81904. matrix: Float32Array;
  81905. inverse: XRRigidTransform;
  81906. }
  81907. interface XRView {
  81908. readonly eye: XREye;
  81909. readonly projectionMatrix: Float32Array;
  81910. readonly transform: XRRigidTransform;
  81911. readonly recommendedViewportScale?: number;
  81912. requestViewportScale(scale: number): void;
  81913. }
  81914. interface XRInputSourceChangeEvent extends Event {
  81915. session: XRSession;
  81916. removed: Array<XRInputSource>;
  81917. added: Array<XRInputSource>;
  81918. }
  81919. // Experimental/Draft features
  81920. declare class XRRay {
  81921. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81922. origin: DOMPointReadOnly;
  81923. direction: DOMPointReadOnly;
  81924. matrix: Float32Array;
  81925. }
  81926. declare enum XRHitTestTrackableType {
  81927. "point",
  81928. "plane",
  81929. "mesh",
  81930. }
  81931. interface XRHitResult {
  81932. hitMatrix: Float32Array;
  81933. }
  81934. interface XRTransientInputHitTestResult {
  81935. readonly inputSource: XRInputSource;
  81936. readonly results: Array<XRHitTestResult>;
  81937. }
  81938. interface XRHitTestResult {
  81939. getPose(baseSpace: XRSpace): XRPose | undefined;
  81940. // When anchor system is enabled
  81941. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81942. }
  81943. interface XRHitTestSource {
  81944. cancel(): void;
  81945. }
  81946. interface XRTransientInputHitTestSource {
  81947. cancel(): void;
  81948. }
  81949. interface XRHitTestOptionsInit {
  81950. space: XRSpace;
  81951. entityTypes?: Array<XRHitTestTrackableType>;
  81952. offsetRay?: XRRay;
  81953. }
  81954. interface XRTransientInputHitTestOptionsInit {
  81955. profile: string;
  81956. entityTypes?: Array<XRHitTestTrackableType>;
  81957. offsetRay?: XRRay;
  81958. }
  81959. interface XRAnchor {
  81960. anchorSpace: XRSpace;
  81961. delete(): void;
  81962. }
  81963. interface XRPlane {
  81964. orientation: "Horizontal" | "Vertical";
  81965. planeSpace: XRSpace;
  81966. polygon: Array<DOMPointReadOnly>;
  81967. lastChangedTime: number;
  81968. }
  81969. interface XRJointSpace extends XRSpace {}
  81970. interface XRJointPose extends XRPose {
  81971. radius: number | undefined;
  81972. }
  81973. interface XRHand extends Iterable<XRJointSpace> {
  81974. readonly length: number;
  81975. [index: number]: XRJointSpace;
  81976. readonly WRIST: number;
  81977. readonly THUMB_METACARPAL: number;
  81978. readonly THUMB_PHALANX_PROXIMAL: number;
  81979. readonly THUMB_PHALANX_DISTAL: number;
  81980. readonly THUMB_PHALANX_TIP: number;
  81981. readonly INDEX_METACARPAL: number;
  81982. readonly INDEX_PHALANX_PROXIMAL: number;
  81983. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81984. readonly INDEX_PHALANX_DISTAL: number;
  81985. readonly INDEX_PHALANX_TIP: number;
  81986. readonly MIDDLE_METACARPAL: number;
  81987. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81988. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81989. readonly MIDDLE_PHALANX_DISTAL: number;
  81990. readonly MIDDLE_PHALANX_TIP: number;
  81991. readonly RING_METACARPAL: number;
  81992. readonly RING_PHALANX_PROXIMAL: number;
  81993. readonly RING_PHALANX_INTERMEDIATE: number;
  81994. readonly RING_PHALANX_DISTAL: number;
  81995. readonly RING_PHALANX_TIP: number;
  81996. readonly LITTLE_METACARPAL: number;
  81997. readonly LITTLE_PHALANX_PROXIMAL: number;
  81998. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81999. readonly LITTLE_PHALANX_DISTAL: number;
  82000. readonly LITTLE_PHALANX_TIP: number;
  82001. }
  82002. type XRImageTrackingState = "tracked" | "emulated";
  82003. type XRImageTrackingScore = "untrackable" | "trackable";
  82004. interface XRTrackedImageInit {
  82005. image: ImageBitmap;
  82006. widthInMeters: number;
  82007. }
  82008. interface XRImageTrackingResult {
  82009. readonly imageSpace: XRSpace;
  82010. readonly index: number;
  82011. readonly trackingState: XRImageTrackingState;
  82012. readonly measuredWidthInMeters: number;
  82013. }
  82014. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82015. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82016. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82017. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82018. interface XRSceneObject {
  82019. type: XRSceneObjectType;
  82020. }
  82021. interface XRFieldOfView {
  82022. angleLeft: number;
  82023. angleRight: number;
  82024. angleUp: number;
  82025. angleDown: number;
  82026. }
  82027. interface XRFrustum {
  82028. position: DOMPointReadOnly;
  82029. orientation: DOMPointReadOnly;
  82030. fieldOfView: XRFieldOfView;
  82031. farDistance: number;
  82032. }
  82033. interface XRPlane {
  82034. parentSceneObject?: XRSceneObject;
  82035. }
  82036. interface XRMesh {
  82037. meshSpace: XRSpace;
  82038. positions: Float32Array;
  82039. indices: Uint32Array;
  82040. normals?: Float32Array;
  82041. lastChangedTime: number;
  82042. parentSceneObject?: XRSceneObject;
  82043. }
  82044. interface XRFrustumDetectionBoundary {
  82045. type: "frustum";
  82046. frustum: XRFrustum;
  82047. }
  82048. interface XRSphereDetectionBoundary {
  82049. type: "sphere";
  82050. radius: number;
  82051. }
  82052. interface XRBoxDetectionBoundary {
  82053. type: "box";
  82054. extent: DOMPointReadOnly;
  82055. }
  82056. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82057. interface XRGeometryDetectorOptions {
  82058. detectionBoundary?: XRDetectionBoundary;
  82059. updateInterval?: number;
  82060. }
  82061. interface XRSession {
  82062. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82063. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82064. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82065. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82066. }
  82067. interface XRFrame {
  82068. featurePointCloud?: Array<number>;
  82069. }
  82070. type XRMeshSet = Set<XRMesh>;
  82071. interface XRWorldInformation {
  82072. detectedMeshes?: XRMeshSet;
  82073. }
  82074. /**
  82075. * @ignore
  82076. */
  82077. declare module BABYLON.GLTF2.Exporter {
  82078. }
  82079. /**
  82080. * @ignore
  82081. */
  82082. declare module BABYLON.GLTF1 {
  82083. }
  82084. declare module BABYLON.GUI {
  82085. /**
  82086. * Interface used to define a control that can receive focus
  82087. */
  82088. export interface IFocusableControl {
  82089. /**
  82090. * Function called when the control receives the focus
  82091. */
  82092. onFocus(): void;
  82093. /**
  82094. * Function called when the control loses the focus
  82095. */
  82096. onBlur(): void;
  82097. /**
  82098. * Function called to let the control handle keyboard events
  82099. * @param evt defines the current keyboard event
  82100. */
  82101. processKeyboard(evt: KeyboardEvent): void;
  82102. /**
  82103. * Function called to get the list of controls that should not steal the focus from this control
  82104. * @returns an array of controls
  82105. */
  82106. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82107. /**
  82108. * Function to focus the control programmatically
  82109. */
  82110. focus(): void;
  82111. /**
  82112. * Function to unfocus the control programmatically
  82113. */
  82114. blur(): void;
  82115. }
  82116. }
  82117. declare module BABYLON.GUI {
  82118. /**
  82119. * Class used to specific a value and its associated unit
  82120. */
  82121. export class ValueAndUnit {
  82122. /** defines the unit to store */
  82123. unit: number;
  82124. /** defines a boolean indicating if the value can be negative */
  82125. negativeValueAllowed: boolean;
  82126. private _value;
  82127. private _originalUnit;
  82128. /**
  82129. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82130. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82131. */
  82132. ignoreAdaptiveScaling: boolean;
  82133. /**
  82134. * Creates a new ValueAndUnit
  82135. * @param value defines the value to store
  82136. * @param unit defines the unit to store
  82137. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82138. */
  82139. constructor(value: number,
  82140. /** defines the unit to store */
  82141. unit?: number,
  82142. /** defines a boolean indicating if the value can be negative */
  82143. negativeValueAllowed?: boolean);
  82144. /** Gets a boolean indicating if the value is a percentage */
  82145. get isPercentage(): boolean;
  82146. /** Gets a boolean indicating if the value is store as pixel */
  82147. get isPixel(): boolean;
  82148. /** Gets direct internal value */
  82149. get internalValue(): number;
  82150. /**
  82151. * Gets value as pixel
  82152. * @param host defines the root host
  82153. * @param refValue defines the reference value for percentages
  82154. * @returns the value as pixel
  82155. */
  82156. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82157. /**
  82158. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82159. * @param value defines the value to store
  82160. * @param unit defines the unit to store
  82161. * @returns the current ValueAndUnit
  82162. */
  82163. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82164. /**
  82165. * Gets the value accordingly to its unit
  82166. * @param host defines the root host
  82167. * @returns the value
  82168. */
  82169. getValue(host: AdvancedDynamicTexture): number;
  82170. /**
  82171. * Gets a string representation of the value
  82172. * @param host defines the root host
  82173. * @param decimals defines an optional number of decimals to display
  82174. * @returns a string
  82175. */
  82176. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82177. /**
  82178. * Store a value parsed from a string
  82179. * @param source defines the source string
  82180. * @returns true if the value was successfully parsed
  82181. */
  82182. fromString(source: string | number): boolean;
  82183. private static _Regex;
  82184. private static _UNITMODE_PERCENTAGE;
  82185. private static _UNITMODE_PIXEL;
  82186. /** UNITMODE_PERCENTAGE */
  82187. static get UNITMODE_PERCENTAGE(): number;
  82188. /** UNITMODE_PIXEL */
  82189. static get UNITMODE_PIXEL(): number;
  82190. }
  82191. }
  82192. declare module BABYLON.GUI {
  82193. /**
  82194. * Define a style used by control to automatically setup properties based on a template.
  82195. * Only support font related properties so far
  82196. */
  82197. export class Style implements BABYLON.IDisposable {
  82198. private _fontFamily;
  82199. private _fontStyle;
  82200. private _fontWeight;
  82201. /** @hidden */
  82202. _host: AdvancedDynamicTexture;
  82203. /** @hidden */
  82204. _fontSize: ValueAndUnit;
  82205. /**
  82206. * BABYLON.Observable raised when the style values are changed
  82207. */
  82208. onChangedObservable: BABYLON.Observable<Style>;
  82209. /**
  82210. * Creates a new style object
  82211. * @param host defines the AdvancedDynamicTexture which hosts this style
  82212. */
  82213. constructor(host: AdvancedDynamicTexture);
  82214. /**
  82215. * Gets or sets the font size
  82216. */
  82217. get fontSize(): string | number;
  82218. set fontSize(value: string | number);
  82219. /**
  82220. * Gets or sets the font family
  82221. */
  82222. get fontFamily(): string;
  82223. set fontFamily(value: string);
  82224. /**
  82225. * Gets or sets the font style
  82226. */
  82227. get fontStyle(): string;
  82228. set fontStyle(value: string);
  82229. /** Gets or sets font weight */
  82230. get fontWeight(): string;
  82231. set fontWeight(value: string);
  82232. /** Dispose all associated resources */
  82233. dispose(): void;
  82234. }
  82235. }
  82236. declare module BABYLON.GUI {
  82237. /**
  82238. * Class used to transport BABYLON.Vector2 information for pointer events
  82239. */
  82240. export class Vector2WithInfo extends BABYLON.Vector2 {
  82241. /** defines the current mouse button index */
  82242. buttonIndex: number;
  82243. /**
  82244. * Creates a new Vector2WithInfo
  82245. * @param source defines the vector2 data to transport
  82246. * @param buttonIndex defines the current mouse button index
  82247. */
  82248. constructor(source: BABYLON.Vector2,
  82249. /** defines the current mouse button index */
  82250. buttonIndex?: number);
  82251. }
  82252. /** Class used to provide 2D matrix features */
  82253. export class Matrix2D {
  82254. /** Gets the internal array of 6 floats used to store matrix data */
  82255. m: Float32Array;
  82256. /**
  82257. * Creates a new matrix
  82258. * @param m00 defines value for (0, 0)
  82259. * @param m01 defines value for (0, 1)
  82260. * @param m10 defines value for (1, 0)
  82261. * @param m11 defines value for (1, 1)
  82262. * @param m20 defines value for (2, 0)
  82263. * @param m21 defines value for (2, 1)
  82264. */
  82265. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82266. /**
  82267. * Fills the matrix from direct values
  82268. * @param m00 defines value for (0, 0)
  82269. * @param m01 defines value for (0, 1)
  82270. * @param m10 defines value for (1, 0)
  82271. * @param m11 defines value for (1, 1)
  82272. * @param m20 defines value for (2, 0)
  82273. * @param m21 defines value for (2, 1)
  82274. * @returns the current modified matrix
  82275. */
  82276. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82277. /**
  82278. * Gets matrix determinant
  82279. * @returns the determinant
  82280. */
  82281. determinant(): number;
  82282. /**
  82283. * Inverses the matrix and stores it in a target matrix
  82284. * @param result defines the target matrix
  82285. * @returns the current matrix
  82286. */
  82287. invertToRef(result: Matrix2D): Matrix2D;
  82288. /**
  82289. * Multiplies the current matrix with another one
  82290. * @param other defines the second operand
  82291. * @param result defines the target matrix
  82292. * @returns the current matrix
  82293. */
  82294. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82295. /**
  82296. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82297. * @param x defines the x coordinate to transform
  82298. * @param y defines the x coordinate to transform
  82299. * @param result defines the target vector2
  82300. * @returns the current matrix
  82301. */
  82302. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82303. /**
  82304. * Creates an identity matrix
  82305. * @returns a new matrix
  82306. */
  82307. static Identity(): Matrix2D;
  82308. /**
  82309. * Creates a translation matrix and stores it in a target matrix
  82310. * @param x defines the x coordinate of the translation
  82311. * @param y defines the y coordinate of the translation
  82312. * @param result defines the target matrix
  82313. */
  82314. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82315. /**
  82316. * Creates a scaling matrix and stores it in a target matrix
  82317. * @param x defines the x coordinate of the scaling
  82318. * @param y defines the y coordinate of the scaling
  82319. * @param result defines the target matrix
  82320. */
  82321. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82322. /**
  82323. * Creates a rotation matrix and stores it in a target matrix
  82324. * @param angle defines the rotation angle
  82325. * @param result defines the target matrix
  82326. */
  82327. static RotationToRef(angle: number, result: Matrix2D): void;
  82328. private static _TempPreTranslationMatrix;
  82329. private static _TempPostTranslationMatrix;
  82330. private static _TempRotationMatrix;
  82331. private static _TempScalingMatrix;
  82332. private static _TempCompose0;
  82333. private static _TempCompose1;
  82334. private static _TempCompose2;
  82335. /**
  82336. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82337. * @param tx defines the x coordinate of the translation
  82338. * @param ty defines the y coordinate of the translation
  82339. * @param angle defines the rotation angle
  82340. * @param scaleX defines the x coordinate of the scaling
  82341. * @param scaleY defines the y coordinate of the scaling
  82342. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82343. * @param result defines the target matrix
  82344. */
  82345. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82346. }
  82347. }
  82348. declare module BABYLON.GUI {
  82349. /**
  82350. * Class used to store 2D control sizes
  82351. */
  82352. export class Measure {
  82353. /** defines left coordinate */
  82354. left: number;
  82355. /** defines top coordinate */
  82356. top: number;
  82357. /** defines width dimension */
  82358. width: number;
  82359. /** defines height dimension */
  82360. height: number;
  82361. /**
  82362. * Creates a new measure
  82363. * @param left defines left coordinate
  82364. * @param top defines top coordinate
  82365. * @param width defines width dimension
  82366. * @param height defines height dimension
  82367. */
  82368. constructor(
  82369. /** defines left coordinate */
  82370. left: number,
  82371. /** defines top coordinate */
  82372. top: number,
  82373. /** defines width dimension */
  82374. width: number,
  82375. /** defines height dimension */
  82376. height: number);
  82377. /**
  82378. * Copy from another measure
  82379. * @param other defines the other measure to copy from
  82380. */
  82381. copyFrom(other: Measure): void;
  82382. /**
  82383. * Copy from a group of 4 floats
  82384. * @param left defines left coordinate
  82385. * @param top defines top coordinate
  82386. * @param width defines width dimension
  82387. * @param height defines height dimension
  82388. */
  82389. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82390. /**
  82391. * Computes the axis aligned bounding box measure for two given measures
  82392. * @param a Input measure
  82393. * @param b Input measure
  82394. * @param result the resulting bounding measure
  82395. */
  82396. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82397. /**
  82398. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82399. * @param transform the matrix to transform the measure before computing the AABB
  82400. * @param addX number to add to left
  82401. * @param addY number to add to top
  82402. * @param addWidth number to add to width
  82403. * @param addHeight number to add to height
  82404. * @param result the resulting AABB
  82405. */
  82406. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82407. /**
  82408. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82409. * @param transform the matrix to transform the measure before computing the AABB
  82410. * @param result the resulting AABB
  82411. */
  82412. transformToRef(transform: Matrix2D, result: Measure): void;
  82413. /**
  82414. * Check equality between this measure and another one
  82415. * @param other defines the other measures
  82416. * @returns true if both measures are equals
  82417. */
  82418. isEqualsTo(other: Measure): boolean;
  82419. /**
  82420. * Creates an empty measure
  82421. * @returns a new measure
  82422. */
  82423. static Empty(): Measure;
  82424. }
  82425. }
  82426. declare module BABYLON.GUI {
  82427. /**
  82428. * Class used to create texture to support 2D GUI elements
  82429. * @see https://doc.babylonjs.com/how_to/gui
  82430. */
  82431. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82432. /** Define the Uurl to load snippets */
  82433. static SnippetUrl: string;
  82434. /** Snippet ID if the content was created from the snippet server */
  82435. snippetId: string;
  82436. private _isDirty;
  82437. private _renderObserver;
  82438. private _resizeObserver;
  82439. private _preKeyboardObserver;
  82440. private _pointerMoveObserver;
  82441. private _pointerObserver;
  82442. private _canvasPointerOutObserver;
  82443. private _canvasBlurObserver;
  82444. private _background;
  82445. /** @hidden */
  82446. _rootContainer: Container;
  82447. /** @hidden */
  82448. _lastPickedControl: Control;
  82449. /** @hidden */
  82450. _lastControlOver: {
  82451. [pointerId: number]: Control;
  82452. };
  82453. /** @hidden */
  82454. _lastControlDown: {
  82455. [pointerId: number]: Control;
  82456. };
  82457. /** @hidden */
  82458. _capturingControl: {
  82459. [pointerId: number]: Control;
  82460. };
  82461. /** @hidden */
  82462. _shouldBlockPointer: boolean;
  82463. /** @hidden */
  82464. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82465. /** @hidden */
  82466. _linkedControls: Control[];
  82467. private _isFullscreen;
  82468. private _fullscreenViewport;
  82469. private _idealWidth;
  82470. private _idealHeight;
  82471. private _useSmallestIdeal;
  82472. private _renderAtIdealSize;
  82473. private _focusedControl;
  82474. private _blockNextFocusCheck;
  82475. private _renderScale;
  82476. private _rootElement;
  82477. private _cursorChanged;
  82478. private _defaultMousePointerId;
  82479. /** @hidden */
  82480. _numLayoutCalls: number;
  82481. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82482. get numLayoutCalls(): number;
  82483. /** @hidden */
  82484. _numRenderCalls: number;
  82485. /** Gets the number of render calls made the last time the ADT has been rendered */
  82486. get numRenderCalls(): number;
  82487. /**
  82488. * Define type to string to ensure compatibility across browsers
  82489. * Safari doesn't support DataTransfer constructor
  82490. */
  82491. private _clipboardData;
  82492. /**
  82493. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82494. */
  82495. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82496. /**
  82497. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82498. */
  82499. onControlPickedObservable: BABYLON.Observable<Control>;
  82500. /**
  82501. * BABYLON.Observable event triggered before layout is evaluated
  82502. */
  82503. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82504. /**
  82505. * BABYLON.Observable event triggered after the layout was evaluated
  82506. */
  82507. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82508. /**
  82509. * BABYLON.Observable event triggered before the texture is rendered
  82510. */
  82511. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82512. /**
  82513. * BABYLON.Observable event triggered after the texture was rendered
  82514. */
  82515. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82516. /**
  82517. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82518. */
  82519. premulAlpha: boolean;
  82520. /**
  82521. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82522. */
  82523. applyYInversionOnUpdate: boolean;
  82524. /**
  82525. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82526. * Useful when you want more antialiasing
  82527. */
  82528. get renderScale(): number;
  82529. set renderScale(value: number);
  82530. /** Gets or sets the background color */
  82531. get background(): string;
  82532. set background(value: string);
  82533. /**
  82534. * Gets or sets the ideal width used to design controls.
  82535. * The GUI will then rescale everything accordingly
  82536. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82537. */
  82538. get idealWidth(): number;
  82539. set idealWidth(value: number);
  82540. /**
  82541. * Gets or sets the ideal height used to design controls.
  82542. * The GUI will then rescale everything accordingly
  82543. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82544. */
  82545. get idealHeight(): number;
  82546. set idealHeight(value: number);
  82547. /**
  82548. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82549. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82550. */
  82551. get useSmallestIdeal(): boolean;
  82552. set useSmallestIdeal(value: boolean);
  82553. /**
  82554. * Gets or sets a boolean indicating if adaptive scaling must be used
  82555. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82556. */
  82557. get renderAtIdealSize(): boolean;
  82558. set renderAtIdealSize(value: boolean);
  82559. /**
  82560. * Gets the ratio used when in "ideal mode"
  82561. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82562. * */
  82563. get idealRatio(): number;
  82564. /**
  82565. * Gets the underlying layer used to render the texture when in fullscreen mode
  82566. */
  82567. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82568. /**
  82569. * Gets the root container control
  82570. */
  82571. get rootContainer(): Container;
  82572. /**
  82573. * Returns an array containing the root container.
  82574. * This is mostly used to let the Inspector introspects the ADT
  82575. * @returns an array containing the rootContainer
  82576. */
  82577. getChildren(): Array<Container>;
  82578. /**
  82579. * Will return all controls that are inside this texture
  82580. * @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
  82581. * @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
  82582. * @return all child controls
  82583. */
  82584. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82585. /**
  82586. * Gets or sets the current focused control
  82587. */
  82588. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82589. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82590. /**
  82591. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82592. */
  82593. get isForeground(): boolean;
  82594. set isForeground(value: boolean);
  82595. /**
  82596. * Gets or set information about clipboardData
  82597. */
  82598. get clipboardData(): string;
  82599. set clipboardData(value: string);
  82600. /**
  82601. * Creates a new AdvancedDynamicTexture
  82602. * @param name defines the name of the texture
  82603. * @param width defines the width of the texture
  82604. * @param height defines the height of the texture
  82605. * @param scene defines the hosting scene
  82606. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82607. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82608. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82609. */
  82610. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82611. /**
  82612. * Get the current class name of the texture useful for serialization or dynamic coding.
  82613. * @returns "AdvancedDynamicTexture"
  82614. */
  82615. getClassName(): string;
  82616. /**
  82617. * Function used to execute a function on all controls
  82618. * @param func defines the function to execute
  82619. * @param container defines the container where controls belong. If null the root container will be used
  82620. */
  82621. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82622. private _useInvalidateRectOptimization;
  82623. /**
  82624. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82625. */
  82626. get useInvalidateRectOptimization(): boolean;
  82627. set useInvalidateRectOptimization(value: boolean);
  82628. private _invalidatedRectangle;
  82629. /**
  82630. * Invalidates a rectangle area on the gui texture
  82631. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82632. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82633. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82634. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82635. */
  82636. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82637. /**
  82638. * Marks the texture as dirty forcing a complete update
  82639. */
  82640. markAsDirty(): void;
  82641. /**
  82642. * Helper function used to create a new style
  82643. * @returns a new style
  82644. * @see https://doc.babylonjs.com/how_to/gui#styles
  82645. */
  82646. createStyle(): Style;
  82647. /**
  82648. * Adds a new control to the root container
  82649. * @param control defines the control to add
  82650. * @returns the current texture
  82651. */
  82652. addControl(control: Control): AdvancedDynamicTexture;
  82653. /**
  82654. * Removes a control from the root container
  82655. * @param control defines the control to remove
  82656. * @returns the current texture
  82657. */
  82658. removeControl(control: Control): AdvancedDynamicTexture;
  82659. /**
  82660. * Release all resources
  82661. */
  82662. dispose(): void;
  82663. private _onResize;
  82664. /** @hidden */
  82665. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82666. /**
  82667. * Get screen coordinates for a vector3
  82668. * @param position defines the position to project
  82669. * @param worldMatrix defines the world matrix to use
  82670. * @returns the projected position
  82671. */
  82672. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82673. /**
  82674. * Get screen coordinates for a vector3
  82675. * @param position defines the position to project
  82676. * @param worldMatrix defines the world matrix to use
  82677. * @returns the projected position with Z
  82678. */
  82679. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82680. private _checkUpdate;
  82681. private _clearMeasure;
  82682. private _render;
  82683. /** @hidden */
  82684. _changeCursor(cursor: string): void;
  82685. /** @hidden */
  82686. _registerLastControlDown(control: Control, pointerId: number): void;
  82687. private _doPicking;
  82688. /** @hidden */
  82689. _cleanControlAfterRemovalFromList(list: {
  82690. [pointerId: number]: Control;
  82691. }, control: Control): void;
  82692. /** @hidden */
  82693. _cleanControlAfterRemoval(control: Control): void;
  82694. /** Attach to all scene events required to support pointer events */
  82695. attach(): void;
  82696. /** @hidden */
  82697. private onClipboardCopy;
  82698. /** @hidden */
  82699. private onClipboardCut;
  82700. /** @hidden */
  82701. private onClipboardPaste;
  82702. /**
  82703. * Register the clipboard Events onto the canvas
  82704. */
  82705. registerClipboardEvents(): void;
  82706. /**
  82707. * Unregister the clipboard Events from the canvas
  82708. */
  82709. unRegisterClipboardEvents(): void;
  82710. /**
  82711. * Connect the texture to a hosting mesh to enable interactions
  82712. * @param mesh defines the mesh to attach to
  82713. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82714. */
  82715. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82716. /**
  82717. * Move the focus to a specific control
  82718. * @param control defines the control which will receive the focus
  82719. */
  82720. moveFocusToControl(control: IFocusableControl): void;
  82721. private _manageFocus;
  82722. private _attachToOnPointerOut;
  82723. private _attachToOnBlur;
  82724. /**
  82725. * Serializes the entire GUI system
  82726. * @returns an object with the JSON serialized data
  82727. */
  82728. serializeContent(): any;
  82729. /**
  82730. * Recreate the content of the ADT from a JSON object
  82731. * @param serializedObject define the JSON serialized object to restore from
  82732. */
  82733. parseContent(serializedObject: any): void;
  82734. /**
  82735. * Recreate the content of the ADT from a snippet saved by the GUI editor
  82736. * @param snippetId defines the snippet to load
  82737. * @returns a promise that will resolve on success
  82738. */
  82739. parseFromSnippetAsync(snippetId: string): Promise<void>;
  82740. /**
  82741. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82742. * @param mesh defines the mesh which will receive the texture
  82743. * @param width defines the texture width (1024 by default)
  82744. * @param height defines the texture height (1024 by default)
  82745. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82746. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82747. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82748. * @returns a new AdvancedDynamicTexture
  82749. */
  82750. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82751. /**
  82752. * 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
  82753. * @param mesh defines the mesh which will receive the texture
  82754. * @param width defines the texture width (1024 by default)
  82755. * @param height defines the texture height (1024 by default)
  82756. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82757. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82758. * @returns a new AdvancedDynamicTexture
  82759. */
  82760. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82761. /**
  82762. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82763. * In this mode the texture will rely on a layer for its rendering.
  82764. * This allows it to be treated like any other layer.
  82765. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82766. * LayerMask is set through advancedTexture.layer.layerMask
  82767. * @param name defines name for the texture
  82768. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82769. * @param scene defines the hsoting scene
  82770. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82771. * @returns a new AdvancedDynamicTexture
  82772. */
  82773. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82774. }
  82775. }
  82776. declare module BABYLON.GUI {
  82777. /**
  82778. * Root class used for all 2D controls
  82779. * @see https://doc.babylonjs.com/how_to/gui#controls
  82780. */
  82781. export class Control {
  82782. /** defines the name of the control */
  82783. name?: string | undefined;
  82784. /**
  82785. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82786. */
  82787. static AllowAlphaInheritance: boolean;
  82788. private _alpha;
  82789. private _alphaSet;
  82790. private _zIndex;
  82791. /** @hidden */
  82792. _host: AdvancedDynamicTexture;
  82793. /** Gets or sets the control parent */
  82794. parent: BABYLON.Nullable<Container>;
  82795. /** @hidden */
  82796. _currentMeasure: Measure;
  82797. private _fontFamily;
  82798. private _fontStyle;
  82799. private _fontWeight;
  82800. private _fontSize;
  82801. private _font;
  82802. /** @hidden */
  82803. _width: ValueAndUnit;
  82804. /** @hidden */
  82805. _height: ValueAndUnit;
  82806. /** @hidden */
  82807. protected _fontOffset: {
  82808. ascent: number;
  82809. height: number;
  82810. descent: number;
  82811. };
  82812. private _color;
  82813. private _style;
  82814. private _styleObserver;
  82815. /** @hidden */
  82816. protected _horizontalAlignment: number;
  82817. /** @hidden */
  82818. protected _verticalAlignment: number;
  82819. /** @hidden */
  82820. protected _isDirty: boolean;
  82821. /** @hidden */
  82822. protected _wasDirty: boolean;
  82823. /** @hidden */
  82824. _tempParentMeasure: Measure;
  82825. /** @hidden */
  82826. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82827. /** @hidden */
  82828. protected _cachedParentMeasure: Measure;
  82829. private _paddingLeft;
  82830. private _paddingRight;
  82831. private _paddingTop;
  82832. private _paddingBottom;
  82833. /** @hidden */
  82834. _left: ValueAndUnit;
  82835. /** @hidden */
  82836. _top: ValueAndUnit;
  82837. private _scaleX;
  82838. private _scaleY;
  82839. private _rotation;
  82840. private _transformCenterX;
  82841. private _transformCenterY;
  82842. /** @hidden */
  82843. _transformMatrix: Matrix2D;
  82844. /** @hidden */
  82845. protected _invertTransformMatrix: Matrix2D;
  82846. /** @hidden */
  82847. protected _transformedPosition: BABYLON.Vector2;
  82848. private _isMatrixDirty;
  82849. private _cachedOffsetX;
  82850. private _cachedOffsetY;
  82851. private _isVisible;
  82852. private _isHighlighted;
  82853. /** @hidden */
  82854. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82855. private _fontSet;
  82856. private _dummyVector2;
  82857. private _downCount;
  82858. private _enterCount;
  82859. private _doNotRender;
  82860. private _downPointerIds;
  82861. protected _isEnabled: boolean;
  82862. protected _disabledColor: string;
  82863. protected _disabledColorItem: string;
  82864. /** @hidden */
  82865. protected _rebuildLayout: boolean;
  82866. /** @hidden */
  82867. _customData: any;
  82868. /** @hidden */
  82869. _isClipped: boolean;
  82870. /** @hidden */
  82871. _automaticSize: boolean;
  82872. /** @hidden */
  82873. _tag: any;
  82874. /**
  82875. * 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
  82876. */
  82877. uniqueId: number;
  82878. /**
  82879. * Gets or sets an object used to store user defined information for the node
  82880. */
  82881. metadata: any;
  82882. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82883. isHitTestVisible: boolean;
  82884. /** Gets or sets a boolean indicating if the control can block pointer events */
  82885. isPointerBlocker: boolean;
  82886. /** Gets or sets a boolean indicating if the control can be focusable */
  82887. isFocusInvisible: boolean;
  82888. /**
  82889. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82890. * 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
  82891. */
  82892. clipChildren: boolean;
  82893. /**
  82894. * Gets or sets a boolean indicating that control content must be clipped
  82895. * 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
  82896. */
  82897. clipContent: boolean;
  82898. /**
  82899. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82900. */
  82901. useBitmapCache: boolean;
  82902. private _cacheData;
  82903. private _shadowOffsetX;
  82904. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82905. get shadowOffsetX(): number;
  82906. set shadowOffsetX(value: number);
  82907. private _shadowOffsetY;
  82908. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82909. get shadowOffsetY(): number;
  82910. set shadowOffsetY(value: number);
  82911. private _shadowBlur;
  82912. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82913. get shadowBlur(): number;
  82914. set shadowBlur(value: number);
  82915. private _shadowColor;
  82916. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82917. get shadowColor(): string;
  82918. set shadowColor(value: string);
  82919. /** Gets or sets the cursor to use when the control is hovered */
  82920. hoverCursor: string;
  82921. /** @hidden */
  82922. protected _linkOffsetX: ValueAndUnit;
  82923. /** @hidden */
  82924. protected _linkOffsetY: ValueAndUnit;
  82925. /** Gets the control type name */
  82926. get typeName(): string;
  82927. /**
  82928. * Get the current class name of the control.
  82929. * @returns current class name
  82930. */
  82931. getClassName(): string;
  82932. /**
  82933. * An event triggered when pointer wheel is scrolled
  82934. */
  82935. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82936. /**
  82937. * An event triggered when the pointer move over the control.
  82938. */
  82939. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82940. /**
  82941. * An event triggered when the pointer move out of the control.
  82942. */
  82943. onPointerOutObservable: BABYLON.Observable<Control>;
  82944. /**
  82945. * An event triggered when the pointer taps the control
  82946. */
  82947. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82948. /**
  82949. * An event triggered when pointer up
  82950. */
  82951. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82952. /**
  82953. * An event triggered when a control is clicked on
  82954. */
  82955. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82956. /**
  82957. * An event triggered when pointer enters the control
  82958. */
  82959. onPointerEnterObservable: BABYLON.Observable<Control>;
  82960. /**
  82961. * An event triggered when the control is marked as dirty
  82962. */
  82963. onDirtyObservable: BABYLON.Observable<Control>;
  82964. /**
  82965. * An event triggered before drawing the control
  82966. */
  82967. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82968. /**
  82969. * An event triggered after the control was drawn
  82970. */
  82971. onAfterDrawObservable: BABYLON.Observable<Control>;
  82972. /**
  82973. * An event triggered when the control has been disposed
  82974. */
  82975. onDisposeObservable: BABYLON.Observable<Control>;
  82976. /**
  82977. * Get the hosting AdvancedDynamicTexture
  82978. */
  82979. get host(): AdvancedDynamicTexture;
  82980. /** Gets or set information about font offsets (used to render and align text) */
  82981. get fontOffset(): {
  82982. ascent: number;
  82983. height: number;
  82984. descent: number;
  82985. };
  82986. set fontOffset(offset: {
  82987. ascent: number;
  82988. height: number;
  82989. descent: number;
  82990. });
  82991. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82992. get alpha(): number;
  82993. set alpha(value: number);
  82994. /**
  82995. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82996. */
  82997. get isHighlighted(): boolean;
  82998. set isHighlighted(value: boolean);
  82999. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83000. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83001. */
  83002. get scaleX(): number;
  83003. set scaleX(value: number);
  83004. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83005. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83006. */
  83007. get scaleY(): number;
  83008. set scaleY(value: number);
  83009. /** Gets or sets the rotation angle (0 by default)
  83010. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83011. */
  83012. get rotation(): number;
  83013. set rotation(value: number);
  83014. /** Gets or sets the transformation center on Y axis (0 by default)
  83015. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83016. */
  83017. get transformCenterY(): number;
  83018. set transformCenterY(value: number);
  83019. /** Gets or sets the transformation center on X axis (0 by default)
  83020. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83021. */
  83022. get transformCenterX(): number;
  83023. set transformCenterX(value: number);
  83024. /**
  83025. * Gets or sets the horizontal alignment
  83026. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83027. */
  83028. get horizontalAlignment(): number;
  83029. set horizontalAlignment(value: number);
  83030. /**
  83031. * Gets or sets the vertical alignment
  83032. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83033. */
  83034. get verticalAlignment(): number;
  83035. set verticalAlignment(value: number);
  83036. /**
  83037. * Gets or sets a fixed ratio for this control.
  83038. * When different from 0, the ratio is used to compute the "second" dimension.
  83039. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83040. * second dimension is computed as first dimension * fixedRatio
  83041. */
  83042. fixedRatio: number;
  83043. private _fixedRatioMasterIsWidth;
  83044. /**
  83045. * Gets or sets control width
  83046. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83047. */
  83048. get width(): string | number;
  83049. set width(value: string | number);
  83050. /**
  83051. * Gets or sets the control width in pixel
  83052. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83053. */
  83054. get widthInPixels(): number;
  83055. set widthInPixels(value: number);
  83056. /**
  83057. * Gets or sets control height
  83058. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83059. */
  83060. get height(): string | number;
  83061. set height(value: string | number);
  83062. /**
  83063. * Gets or sets control height in pixel
  83064. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83065. */
  83066. get heightInPixels(): number;
  83067. set heightInPixels(value: number);
  83068. /** Gets or set font family */
  83069. get fontFamily(): string;
  83070. set fontFamily(value: string);
  83071. /** Gets or sets font style */
  83072. get fontStyle(): string;
  83073. set fontStyle(value: string);
  83074. /** Gets or sets font weight */
  83075. get fontWeight(): string;
  83076. set fontWeight(value: string);
  83077. /**
  83078. * Gets or sets style
  83079. * @see https://doc.babylonjs.com/how_to/gui#styles
  83080. */
  83081. get style(): BABYLON.Nullable<Style>;
  83082. set style(value: BABYLON.Nullable<Style>);
  83083. /** @hidden */
  83084. get _isFontSizeInPercentage(): boolean;
  83085. /** Gets or sets font size in pixels */
  83086. get fontSizeInPixels(): number;
  83087. set fontSizeInPixels(value: number);
  83088. /** Gets or sets font size */
  83089. get fontSize(): string | number;
  83090. set fontSize(value: string | number);
  83091. /** Gets or sets foreground color */
  83092. get color(): string;
  83093. set color(value: string);
  83094. /** Gets or sets z index which is used to reorder controls on the z axis */
  83095. get zIndex(): number;
  83096. set zIndex(value: number);
  83097. /** Gets or sets a boolean indicating if the control can be rendered */
  83098. get notRenderable(): boolean;
  83099. set notRenderable(value: boolean);
  83100. /** Gets or sets a boolean indicating if the control is visible */
  83101. get isVisible(): boolean;
  83102. set isVisible(value: boolean);
  83103. /** Gets a boolean indicating that the control needs to update its rendering */
  83104. get isDirty(): boolean;
  83105. /**
  83106. * Gets the current linked mesh (or null if none)
  83107. */
  83108. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83109. /**
  83110. * Gets or sets a value indicating the padding to use on the left of the control
  83111. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83112. */
  83113. get paddingLeft(): string | number;
  83114. set paddingLeft(value: string | number);
  83115. /**
  83116. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83117. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83118. */
  83119. get paddingLeftInPixels(): number;
  83120. set paddingLeftInPixels(value: number);
  83121. /**
  83122. * Gets or sets a value indicating the padding to use on the right of the control
  83123. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83124. */
  83125. get paddingRight(): string | number;
  83126. set paddingRight(value: string | number);
  83127. /**
  83128. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83129. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83130. */
  83131. get paddingRightInPixels(): number;
  83132. set paddingRightInPixels(value: number);
  83133. /**
  83134. * Gets or sets a value indicating the padding to use on the top of the control
  83135. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83136. */
  83137. get paddingTop(): string | number;
  83138. set paddingTop(value: string | number);
  83139. /**
  83140. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83141. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83142. */
  83143. get paddingTopInPixels(): number;
  83144. set paddingTopInPixels(value: number);
  83145. /**
  83146. * Gets or sets a value indicating the padding to use on the bottom of the control
  83147. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83148. */
  83149. get paddingBottom(): string | number;
  83150. set paddingBottom(value: string | number);
  83151. /**
  83152. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83153. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83154. */
  83155. get paddingBottomInPixels(): number;
  83156. set paddingBottomInPixels(value: number);
  83157. /**
  83158. * Gets or sets a value indicating the left coordinate of the control
  83159. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83160. */
  83161. get left(): string | number;
  83162. set left(value: string | number);
  83163. /**
  83164. * Gets or sets a value indicating the left coordinate in pixels of the control
  83165. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83166. */
  83167. get leftInPixels(): number;
  83168. set leftInPixels(value: number);
  83169. /**
  83170. * Gets or sets a value indicating the top coordinate of the control
  83171. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83172. */
  83173. get top(): string | number;
  83174. set top(value: string | number);
  83175. /**
  83176. * Gets or sets a value indicating the top coordinate in pixels of the control
  83177. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83178. */
  83179. get topInPixels(): number;
  83180. set topInPixels(value: number);
  83181. /**
  83182. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83183. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83184. */
  83185. get linkOffsetX(): string | number;
  83186. set linkOffsetX(value: string | number);
  83187. /**
  83188. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83189. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83190. */
  83191. get linkOffsetXInPixels(): number;
  83192. set linkOffsetXInPixels(value: number);
  83193. /**
  83194. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83195. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83196. */
  83197. get linkOffsetY(): string | number;
  83198. set linkOffsetY(value: string | number);
  83199. /**
  83200. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83201. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83202. */
  83203. get linkOffsetYInPixels(): number;
  83204. set linkOffsetYInPixels(value: number);
  83205. /** Gets the center coordinate on X axis */
  83206. get centerX(): number;
  83207. /** Gets the center coordinate on Y axis */
  83208. get centerY(): number;
  83209. /** Gets or sets if control is Enabled */
  83210. get isEnabled(): boolean;
  83211. set isEnabled(value: boolean);
  83212. /** Gets or sets background color of control if it's disabled */
  83213. get disabledColor(): string;
  83214. set disabledColor(value: string);
  83215. /** Gets or sets front color of control if it's disabled */
  83216. get disabledColorItem(): string;
  83217. set disabledColorItem(value: string);
  83218. /**
  83219. * Creates a new control
  83220. * @param name defines the name of the control
  83221. */
  83222. constructor(
  83223. /** defines the name of the control */
  83224. name?: string | undefined);
  83225. /** @hidden */
  83226. protected _getTypeName(): string;
  83227. /**
  83228. * Gets the first ascendant in the hierarchy of the given type
  83229. * @param className defines the required type
  83230. * @returns the ascendant or null if not found
  83231. */
  83232. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83233. /** @hidden */
  83234. _resetFontCache(): void;
  83235. /**
  83236. * Determines if a container is an ascendant of the current control
  83237. * @param container defines the container to look for
  83238. * @returns true if the container is one of the ascendant of the control
  83239. */
  83240. isAscendant(container: Control): boolean;
  83241. /**
  83242. * Gets coordinates in local control space
  83243. * @param globalCoordinates defines the coordinates to transform
  83244. * @returns the new coordinates in local space
  83245. */
  83246. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83247. /**
  83248. * Gets coordinates in local control space
  83249. * @param globalCoordinates defines the coordinates to transform
  83250. * @param result defines the target vector2 where to store the result
  83251. * @returns the current control
  83252. */
  83253. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83254. /**
  83255. * Gets coordinates in parent local control space
  83256. * @param globalCoordinates defines the coordinates to transform
  83257. * @returns the new coordinates in parent local space
  83258. */
  83259. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83260. /**
  83261. * Move the current control to a vector3 position projected onto the screen.
  83262. * @param position defines the target position
  83263. * @param scene defines the hosting scene
  83264. */
  83265. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83266. /**
  83267. * Will store all controls that have this control as ascendant in a given array
  83268. * @param results defines the array where to store the descendants
  83269. * @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
  83270. * @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
  83271. */
  83272. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83273. /**
  83274. * Will return all controls that have this control as ascendant
  83275. * @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
  83276. * @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
  83277. * @return all child controls
  83278. */
  83279. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83280. /**
  83281. * Link current control with a target mesh
  83282. * @param mesh defines the mesh to link with
  83283. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83284. */
  83285. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83286. /**
  83287. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83288. * @param { string | number} paddingTop - The value of the top padding.
  83289. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83290. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83291. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83292. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83293. */
  83294. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83295. /**
  83296. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83297. * @param { number} paddingTop - The value in pixels of the top padding.
  83298. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83299. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83300. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83301. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83302. */
  83303. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83304. /** @hidden */
  83305. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83306. /** @hidden */
  83307. _offsetLeft(offset: number): void;
  83308. /** @hidden */
  83309. _offsetTop(offset: number): void;
  83310. /** @hidden */
  83311. _markMatrixAsDirty(): void;
  83312. /** @hidden */
  83313. _flagDescendantsAsMatrixDirty(): void;
  83314. /** @hidden */
  83315. _intersectsRect(rect: Measure): boolean;
  83316. /** @hidden */
  83317. protected invalidateRect(): void;
  83318. /** @hidden */
  83319. _markAsDirty(force?: boolean): void;
  83320. /** @hidden */
  83321. _markAllAsDirty(): void;
  83322. /** @hidden */
  83323. _link(host: AdvancedDynamicTexture): void;
  83324. /** @hidden */
  83325. protected _transform(context?: CanvasRenderingContext2D): void;
  83326. /** @hidden */
  83327. _renderHighlight(context: CanvasRenderingContext2D): void;
  83328. /** @hidden */
  83329. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83330. /** @hidden */
  83331. protected _applyStates(context: CanvasRenderingContext2D): void;
  83332. /** @hidden */
  83333. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83334. /** @hidden */
  83335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83336. protected _evaluateClippingState(parentMeasure: Measure): void;
  83337. /** @hidden */
  83338. _measure(): void;
  83339. /** @hidden */
  83340. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83341. /** @hidden */
  83342. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83343. /** @hidden */
  83344. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83345. /** @hidden */
  83346. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83347. private static _ClipMeasure;
  83348. private _tmpMeasureA;
  83349. private _clip;
  83350. /** @hidden */
  83351. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83352. /** @hidden */
  83353. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83354. /**
  83355. * Tests if a given coordinates belong to the current control
  83356. * @param x defines x coordinate to test
  83357. * @param y defines y coordinate to test
  83358. * @returns true if the coordinates are inside the control
  83359. */
  83360. contains(x: number, y: number): boolean;
  83361. /** @hidden */
  83362. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83363. /** @hidden */
  83364. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83365. /** @hidden */
  83366. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83367. /** @hidden */
  83368. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83369. /** @hidden */
  83370. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83371. /** @hidden */
  83372. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83373. /** @hidden */
  83374. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83375. /** @hidden */
  83376. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83377. /** @hidden */
  83378. _onCanvasBlur(): void;
  83379. /** @hidden */
  83380. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83381. private _prepareFont;
  83382. /**
  83383. * Serializes the current control
  83384. * @param serializationObject defined the JSON serialized object
  83385. */
  83386. serialize(serializationObject: any): void;
  83387. /** @hidden */
  83388. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83389. /** Releases associated resources */
  83390. dispose(): void;
  83391. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83392. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83393. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83394. private static _VERTICAL_ALIGNMENT_TOP;
  83395. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83396. private static _VERTICAL_ALIGNMENT_CENTER;
  83397. /** HORIZONTAL_ALIGNMENT_LEFT */
  83398. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83399. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83400. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83401. /** HORIZONTAL_ALIGNMENT_CENTER */
  83402. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83403. /** VERTICAL_ALIGNMENT_TOP */
  83404. static get VERTICAL_ALIGNMENT_TOP(): number;
  83405. /** VERTICAL_ALIGNMENT_BOTTOM */
  83406. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83407. /** VERTICAL_ALIGNMENT_CENTER */
  83408. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83409. private static _FontHeightSizes;
  83410. /** @hidden */
  83411. static _GetFontOffset(font: string): {
  83412. ascent: number;
  83413. height: number;
  83414. descent: number;
  83415. };
  83416. /**
  83417. * Creates a Control from parsed data
  83418. * @param serializedObject defines parsed data
  83419. * @param host defines the hosting AdvancedDynamicTexture
  83420. * @returns a new Control
  83421. */
  83422. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83423. /**
  83424. * Creates a stack panel that can be used to render headers
  83425. * @param control defines the control to associate with the header
  83426. * @param text defines the text of the header
  83427. * @param size defines the size of the header
  83428. * @param options defines options used to configure the header
  83429. * @returns a new StackPanel
  83430. * @ignore
  83431. * @hidden
  83432. */
  83433. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83434. isHorizontal: boolean;
  83435. controlFirst: boolean;
  83436. }) => any;
  83437. /** @hidden */
  83438. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83439. }
  83440. }
  83441. declare module BABYLON.GUI {
  83442. /**
  83443. * Root class for 2D containers
  83444. * @see https://doc.babylonjs.com/how_to/gui#containers
  83445. */
  83446. export class Container extends Control {
  83447. name?: string | undefined;
  83448. /** @hidden */
  83449. _children: Control[];
  83450. /** @hidden */
  83451. protected _measureForChildren: Measure;
  83452. /** @hidden */
  83453. protected _background: string;
  83454. /** @hidden */
  83455. protected _adaptWidthToChildren: boolean;
  83456. /** @hidden */
  83457. protected _adaptHeightToChildren: boolean;
  83458. /**
  83459. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83460. */
  83461. logLayoutCycleErrors: boolean;
  83462. /**
  83463. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83464. */
  83465. maxLayoutCycle: number;
  83466. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83467. get adaptHeightToChildren(): boolean;
  83468. set adaptHeightToChildren(value: boolean);
  83469. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83470. get adaptWidthToChildren(): boolean;
  83471. set adaptWidthToChildren(value: boolean);
  83472. /** Gets or sets background color */
  83473. get background(): string;
  83474. set background(value: string);
  83475. /** Gets the list of children */
  83476. get children(): Control[];
  83477. /**
  83478. * Creates a new Container
  83479. * @param name defines the name of the container
  83480. */
  83481. constructor(name?: string | undefined);
  83482. protected _getTypeName(): string;
  83483. _flagDescendantsAsMatrixDirty(): void;
  83484. /**
  83485. * Gets a child using its name
  83486. * @param name defines the child name to look for
  83487. * @returns the child control if found
  83488. */
  83489. getChildByName(name: string): BABYLON.Nullable<Control>;
  83490. /**
  83491. * Gets a child using its type and its name
  83492. * @param name defines the child name to look for
  83493. * @param type defines the child type to look for
  83494. * @returns the child control if found
  83495. */
  83496. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83497. /**
  83498. * Search for a specific control in children
  83499. * @param control defines the control to look for
  83500. * @returns true if the control is in child list
  83501. */
  83502. containsControl(control: Control): boolean;
  83503. /**
  83504. * Adds a new control to the current container
  83505. * @param control defines the control to add
  83506. * @returns the current container
  83507. */
  83508. addControl(control: BABYLON.Nullable<Control>): Container;
  83509. /**
  83510. * Removes all controls from the current container
  83511. * @returns the current container
  83512. */
  83513. clearControls(): Container;
  83514. /**
  83515. * Removes a control from the current container
  83516. * @param control defines the control to remove
  83517. * @returns the current container
  83518. */
  83519. removeControl(control: Control): Container;
  83520. /** @hidden */
  83521. _reOrderControl(control: Control): void;
  83522. /** @hidden */
  83523. _offsetLeft(offset: number): void;
  83524. /** @hidden */
  83525. _offsetTop(offset: number): void;
  83526. /** @hidden */
  83527. _markAllAsDirty(): void;
  83528. /** @hidden */
  83529. protected _localDraw(context: CanvasRenderingContext2D): void;
  83530. /** @hidden */
  83531. _link(host: AdvancedDynamicTexture): void;
  83532. /** @hidden */
  83533. protected _beforeLayout(): void;
  83534. /** @hidden */
  83535. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83536. /** @hidden */
  83537. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83538. protected _postMeasure(): void;
  83539. /** @hidden */
  83540. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83541. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83542. /** @hidden */
  83543. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83544. /** @hidden */
  83545. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83546. /**
  83547. * Serializes the current control
  83548. * @param serializationObject defined the JSON serialized object
  83549. */
  83550. serialize(serializationObject: any): void;
  83551. /** Releases associated resources */
  83552. dispose(): void;
  83553. /** @hidden */
  83554. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83555. }
  83556. }
  83557. declare module BABYLON.GUI {
  83558. /** Class used to create rectangle container */
  83559. export class Rectangle extends Container {
  83560. name?: string | undefined;
  83561. private _thickness;
  83562. private _cornerRadius;
  83563. /** Gets or sets border thickness */
  83564. get thickness(): number;
  83565. set thickness(value: number);
  83566. /** Gets or sets the corner radius angle */
  83567. get cornerRadius(): number;
  83568. set cornerRadius(value: number);
  83569. /**
  83570. * Creates a new Rectangle
  83571. * @param name defines the control name
  83572. */
  83573. constructor(name?: string | undefined);
  83574. protected _getTypeName(): string;
  83575. protected _localDraw(context: CanvasRenderingContext2D): void;
  83576. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83577. private _drawRoundedRect;
  83578. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83579. }
  83580. }
  83581. declare module BABYLON.GUI {
  83582. /**
  83583. * Enum that determines the text-wrapping mode to use.
  83584. */
  83585. export enum TextWrapping {
  83586. /**
  83587. * Clip the text when it's larger than Control.width; this is the default mode.
  83588. */
  83589. Clip = 0,
  83590. /**
  83591. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83592. */
  83593. WordWrap = 1,
  83594. /**
  83595. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83596. */
  83597. Ellipsis = 2
  83598. }
  83599. /**
  83600. * Class used to create text block control
  83601. */
  83602. export class TextBlock extends Control {
  83603. /**
  83604. * Defines the name of the control
  83605. */
  83606. name?: string | undefined;
  83607. private _text;
  83608. private _textWrapping;
  83609. private _textHorizontalAlignment;
  83610. private _textVerticalAlignment;
  83611. private _lines;
  83612. private _resizeToFit;
  83613. private _lineSpacing;
  83614. private _outlineWidth;
  83615. private _outlineColor;
  83616. private _underline;
  83617. private _lineThrough;
  83618. /**
  83619. * An event triggered after the text is changed
  83620. */
  83621. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83622. /**
  83623. * An event triggered after the text was broken up into lines
  83624. */
  83625. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83626. /**
  83627. * Function used to split a string into words. By default, a string is split at each space character found
  83628. */
  83629. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83630. /**
  83631. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83632. */
  83633. get lines(): any[];
  83634. /**
  83635. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83636. */
  83637. get resizeToFit(): boolean;
  83638. /**
  83639. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83640. */
  83641. set resizeToFit(value: boolean);
  83642. /**
  83643. * Gets or sets a boolean indicating if text must be wrapped
  83644. */
  83645. get textWrapping(): TextWrapping | boolean;
  83646. /**
  83647. * Gets or sets a boolean indicating if text must be wrapped
  83648. */
  83649. set textWrapping(value: TextWrapping | boolean);
  83650. /**
  83651. * Gets or sets text to display
  83652. */
  83653. get text(): string;
  83654. /**
  83655. * Gets or sets text to display
  83656. */
  83657. set text(value: string);
  83658. /**
  83659. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83660. */
  83661. get textHorizontalAlignment(): number;
  83662. /**
  83663. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83664. */
  83665. set textHorizontalAlignment(value: number);
  83666. /**
  83667. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83668. */
  83669. get textVerticalAlignment(): number;
  83670. /**
  83671. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83672. */
  83673. set textVerticalAlignment(value: number);
  83674. /**
  83675. * Gets or sets line spacing value
  83676. */
  83677. set lineSpacing(value: string | number);
  83678. /**
  83679. * Gets or sets line spacing value
  83680. */
  83681. get lineSpacing(): string | number;
  83682. /**
  83683. * Gets or sets outlineWidth of the text to display
  83684. */
  83685. get outlineWidth(): number;
  83686. /**
  83687. * Gets or sets outlineWidth of the text to display
  83688. */
  83689. set outlineWidth(value: number);
  83690. /**
  83691. * Gets or sets a boolean indicating that text must have underline
  83692. */
  83693. get underline(): boolean;
  83694. /**
  83695. * Gets or sets a boolean indicating that text must have underline
  83696. */
  83697. set underline(value: boolean);
  83698. /**
  83699. * Gets or sets an boolean indicating that text must be crossed out
  83700. */
  83701. get lineThrough(): boolean;
  83702. /**
  83703. * Gets or sets an boolean indicating that text must be crossed out
  83704. */
  83705. set lineThrough(value: boolean);
  83706. /**
  83707. * Gets or sets outlineColor of the text to display
  83708. */
  83709. get outlineColor(): string;
  83710. /**
  83711. * Gets or sets outlineColor of the text to display
  83712. */
  83713. set outlineColor(value: string);
  83714. /**
  83715. * Creates a new TextBlock object
  83716. * @param name defines the name of the control
  83717. * @param text defines the text to display (emptry string by default)
  83718. */
  83719. constructor(
  83720. /**
  83721. * Defines the name of the control
  83722. */
  83723. name?: string | undefined, text?: string);
  83724. protected _getTypeName(): string;
  83725. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83726. private _drawText;
  83727. /** @hidden */
  83728. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83729. protected _applyStates(context: CanvasRenderingContext2D): void;
  83730. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83731. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83732. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83733. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83734. protected _renderLines(context: CanvasRenderingContext2D): void;
  83735. /**
  83736. * Given a width constraint applied on the text block, find the expected height
  83737. * @returns expected height
  83738. */
  83739. computeExpectedHeight(): number;
  83740. dispose(): void;
  83741. }
  83742. }
  83743. declare module BABYLON.GUI {
  83744. /**
  83745. * Class used to create 2D images
  83746. */
  83747. export class Image extends Control {
  83748. name?: string | undefined;
  83749. private _workingCanvas;
  83750. private _domImage;
  83751. private _imageWidth;
  83752. private _imageHeight;
  83753. private _loaded;
  83754. private _stretch;
  83755. private _source;
  83756. private _autoScale;
  83757. private _sourceLeft;
  83758. private _sourceTop;
  83759. private _sourceWidth;
  83760. private _sourceHeight;
  83761. private _svgAttributesComputationCompleted;
  83762. private _isSVG;
  83763. private _cellWidth;
  83764. private _cellHeight;
  83765. private _cellId;
  83766. private _populateNinePatchSlicesFromImage;
  83767. private _sliceLeft;
  83768. private _sliceRight;
  83769. private _sliceTop;
  83770. private _sliceBottom;
  83771. private _detectPointerOnOpaqueOnly;
  83772. private _imageDataCache;
  83773. /**
  83774. * BABYLON.Observable notified when the content is loaded
  83775. */
  83776. onImageLoadedObservable: BABYLON.Observable<Image>;
  83777. /**
  83778. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83779. */
  83780. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83781. /**
  83782. * Gets a boolean indicating that the content is loaded
  83783. */
  83784. get isLoaded(): boolean;
  83785. /**
  83786. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83787. */
  83788. get populateNinePatchSlicesFromImage(): boolean;
  83789. set populateNinePatchSlicesFromImage(value: boolean);
  83790. /**
  83791. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83792. * Beware using this as this will comsume more memory as the image has to be stored twice
  83793. */
  83794. get detectPointerOnOpaqueOnly(): boolean;
  83795. set detectPointerOnOpaqueOnly(value: boolean);
  83796. /**
  83797. * Gets or sets the left value for slicing (9-patch)
  83798. */
  83799. get sliceLeft(): number;
  83800. set sliceLeft(value: number);
  83801. /**
  83802. * Gets or sets the right value for slicing (9-patch)
  83803. */
  83804. get sliceRight(): number;
  83805. set sliceRight(value: number);
  83806. /**
  83807. * Gets or sets the top value for slicing (9-patch)
  83808. */
  83809. get sliceTop(): number;
  83810. set sliceTop(value: number);
  83811. /**
  83812. * Gets or sets the bottom value for slicing (9-patch)
  83813. */
  83814. get sliceBottom(): number;
  83815. set sliceBottom(value: number);
  83816. /**
  83817. * Gets or sets the left coordinate in the source image
  83818. */
  83819. get sourceLeft(): number;
  83820. set sourceLeft(value: number);
  83821. /**
  83822. * Gets or sets the top coordinate in the source image
  83823. */
  83824. get sourceTop(): number;
  83825. set sourceTop(value: number);
  83826. /**
  83827. * Gets or sets the width to capture in the source image
  83828. */
  83829. get sourceWidth(): number;
  83830. set sourceWidth(value: number);
  83831. /**
  83832. * Gets or sets the height to capture in the source image
  83833. */
  83834. get sourceHeight(): number;
  83835. set sourceHeight(value: number);
  83836. /** Indicates if the format of the image is SVG */
  83837. get isSVG(): boolean;
  83838. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83839. get svgAttributesComputationCompleted(): boolean;
  83840. /**
  83841. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83842. * @see https://doc.babylonjs.com/how_to/gui#image
  83843. */
  83844. get autoScale(): boolean;
  83845. set autoScale(value: boolean);
  83846. /** Gets or sets the streching mode used by the image */
  83847. get stretch(): number;
  83848. set stretch(value: number);
  83849. /** @hidden */
  83850. _rotate90(n: number, preserveProperties?: boolean): Image;
  83851. private _handleRotationForSVGImage;
  83852. private _rotate90SourceProperties;
  83853. /**
  83854. * Gets or sets the internal DOM image used to render the control
  83855. */
  83856. set domImage(value: HTMLImageElement);
  83857. get domImage(): HTMLImageElement;
  83858. private _onImageLoaded;
  83859. private _extractNinePatchSliceDataFromImage;
  83860. /**
  83861. * Gets the image source url
  83862. */
  83863. get source(): BABYLON.Nullable<string>;
  83864. /**
  83865. * Gets or sets image source url
  83866. */
  83867. set source(value: BABYLON.Nullable<string>);
  83868. /**
  83869. * Checks for svg document with icon id present
  83870. */
  83871. private _svgCheck;
  83872. /**
  83873. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83874. * given external svg file and icon id
  83875. */
  83876. private _getSVGAttribs;
  83877. /**
  83878. * Gets or sets the cell width to use when animation sheet is enabled
  83879. * @see https://doc.babylonjs.com/how_to/gui#image
  83880. */
  83881. get cellWidth(): number;
  83882. set cellWidth(value: number);
  83883. /**
  83884. * Gets or sets the cell height to use when animation sheet is enabled
  83885. * @see https://doc.babylonjs.com/how_to/gui#image
  83886. */
  83887. get cellHeight(): number;
  83888. set cellHeight(value: number);
  83889. /**
  83890. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83891. * @see https://doc.babylonjs.com/how_to/gui#image
  83892. */
  83893. get cellId(): number;
  83894. set cellId(value: number);
  83895. /**
  83896. * Creates a new Image
  83897. * @param name defines the control name
  83898. * @param url defines the image url
  83899. */
  83900. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83901. /**
  83902. * Tests if a given coordinates belong to the current control
  83903. * @param x defines x coordinate to test
  83904. * @param y defines y coordinate to test
  83905. * @returns true if the coordinates are inside the control
  83906. */
  83907. contains(x: number, y: number): boolean;
  83908. protected _getTypeName(): string;
  83909. /** Force the control to synchronize with its content */
  83910. synchronizeSizeWithContent(): void;
  83911. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83912. private _prepareWorkingCanvasForOpaqueDetection;
  83913. private _drawImage;
  83914. _draw(context: CanvasRenderingContext2D): void;
  83915. private _renderCornerPatch;
  83916. private _renderNinePatch;
  83917. dispose(): void;
  83918. /** STRETCH_NONE */
  83919. static readonly STRETCH_NONE: number;
  83920. /** STRETCH_FILL */
  83921. static readonly STRETCH_FILL: number;
  83922. /** STRETCH_UNIFORM */
  83923. static readonly STRETCH_UNIFORM: number;
  83924. /** STRETCH_EXTEND */
  83925. static readonly STRETCH_EXTEND: number;
  83926. /** NINE_PATCH */
  83927. static readonly STRETCH_NINE_PATCH: number;
  83928. }
  83929. }
  83930. declare module BABYLON.GUI {
  83931. /**
  83932. * Class used to create 2D buttons
  83933. */
  83934. export class Button extends Rectangle {
  83935. name?: string | undefined;
  83936. /**
  83937. * Function called to generate a pointer enter animation
  83938. */
  83939. pointerEnterAnimation: () => void;
  83940. /**
  83941. * Function called to generate a pointer out animation
  83942. */
  83943. pointerOutAnimation: () => void;
  83944. /**
  83945. * Function called to generate a pointer down animation
  83946. */
  83947. pointerDownAnimation: () => void;
  83948. /**
  83949. * Function called to generate a pointer up animation
  83950. */
  83951. pointerUpAnimation: () => void;
  83952. /**
  83953. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83954. */
  83955. delegatePickingToChildren: boolean;
  83956. private _image;
  83957. /**
  83958. * Returns the image part of the button (if any)
  83959. */
  83960. get image(): BABYLON.Nullable<Image>;
  83961. private _textBlock;
  83962. /**
  83963. * Returns the image part of the button (if any)
  83964. */
  83965. get textBlock(): BABYLON.Nullable<TextBlock>;
  83966. /**
  83967. * Creates a new Button
  83968. * @param name defines the name of the button
  83969. */
  83970. constructor(name?: string | undefined);
  83971. protected _getTypeName(): string;
  83972. /** @hidden */
  83973. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83974. /** @hidden */
  83975. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83976. /** @hidden */
  83977. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83978. /** @hidden */
  83979. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83980. /** @hidden */
  83981. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83982. /**
  83983. * Creates a new button made with an image and a text
  83984. * @param name defines the name of the button
  83985. * @param text defines the text of the button
  83986. * @param imageUrl defines the url of the image
  83987. * @returns a new Button
  83988. */
  83989. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83990. /**
  83991. * Creates a new button made with an image
  83992. * @param name defines the name of the button
  83993. * @param imageUrl defines the url of the image
  83994. * @returns a new Button
  83995. */
  83996. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83997. /**
  83998. * Creates a new button made with a text
  83999. * @param name defines the name of the button
  84000. * @param text defines the text of the button
  84001. * @returns a new Button
  84002. */
  84003. static CreateSimpleButton(name: string, text: string): Button;
  84004. /**
  84005. * Creates a new button made with an image and a centered text
  84006. * @param name defines the name of the button
  84007. * @param text defines the text of the button
  84008. * @param imageUrl defines the url of the image
  84009. * @returns a new Button
  84010. */
  84011. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84012. }
  84013. }
  84014. declare module BABYLON.GUI {
  84015. /**
  84016. * Class used to create a 2D stack panel container
  84017. */
  84018. export class StackPanel extends Container {
  84019. name?: string | undefined;
  84020. private _isVertical;
  84021. private _manualWidth;
  84022. private _manualHeight;
  84023. private _doNotTrackManualChanges;
  84024. /**
  84025. * Gets or sets a boolean indicating that layou warnings should be ignored
  84026. */
  84027. ignoreLayoutWarnings: boolean;
  84028. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84029. get isVertical(): boolean;
  84030. set isVertical(value: boolean);
  84031. /**
  84032. * Gets or sets panel width.
  84033. * This value should not be set when in horizontal mode as it will be computed automatically
  84034. */
  84035. set width(value: string | number);
  84036. get width(): string | number;
  84037. /**
  84038. * Gets or sets panel height.
  84039. * This value should not be set when in vertical mode as it will be computed automatically
  84040. */
  84041. set height(value: string | number);
  84042. get height(): string | number;
  84043. /**
  84044. * Creates a new StackPanel
  84045. * @param name defines control name
  84046. */
  84047. constructor(name?: string | undefined);
  84048. protected _getTypeName(): string;
  84049. /** @hidden */
  84050. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84051. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84052. protected _postMeasure(): void;
  84053. /**
  84054. * Serializes the current control
  84055. * @param serializationObject defined the JSON serialized object
  84056. */
  84057. serialize(serializationObject: any): void;
  84058. /** @hidden */
  84059. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84060. }
  84061. }
  84062. declare module BABYLON.GUI {
  84063. /**
  84064. * Class used to represent a 2D checkbox
  84065. */
  84066. export class Checkbox extends Control {
  84067. name?: string | undefined;
  84068. private _isChecked;
  84069. private _background;
  84070. private _checkSizeRatio;
  84071. private _thickness;
  84072. /** Gets or sets border thickness */
  84073. get thickness(): number;
  84074. set thickness(value: number);
  84075. /**
  84076. * BABYLON.Observable raised when isChecked property changes
  84077. */
  84078. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84079. /** Gets or sets a value indicating the ratio between overall size and check size */
  84080. get checkSizeRatio(): number;
  84081. set checkSizeRatio(value: number);
  84082. /** Gets or sets background color */
  84083. get background(): string;
  84084. set background(value: string);
  84085. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84086. get isChecked(): boolean;
  84087. set isChecked(value: boolean);
  84088. /**
  84089. * Creates a new CheckBox
  84090. * @param name defines the control name
  84091. */
  84092. constructor(name?: string | undefined);
  84093. protected _getTypeName(): string;
  84094. /** @hidden */
  84095. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84096. /** @hidden */
  84097. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84098. /**
  84099. * Utility function to easily create a checkbox with a header
  84100. * @param title defines the label to use for the header
  84101. * @param onValueChanged defines the callback to call when value changes
  84102. * @returns a StackPanel containing the checkbox and a textBlock
  84103. */
  84104. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84105. }
  84106. }
  84107. declare module BABYLON.GUI {
  84108. /**
  84109. * Class used to store key control properties
  84110. */
  84111. export class KeyPropertySet {
  84112. /** Width */
  84113. width?: string;
  84114. /** Height */
  84115. height?: string;
  84116. /** Left padding */
  84117. paddingLeft?: string;
  84118. /** Right padding */
  84119. paddingRight?: string;
  84120. /** Top padding */
  84121. paddingTop?: string;
  84122. /** Bottom padding */
  84123. paddingBottom?: string;
  84124. /** Foreground color */
  84125. color?: string;
  84126. /** Background color */
  84127. background?: string;
  84128. }
  84129. /**
  84130. * Class used to create virtual keyboard
  84131. */
  84132. export class VirtualKeyboard extends StackPanel {
  84133. /** BABYLON.Observable raised when a key is pressed */
  84134. onKeyPressObservable: BABYLON.Observable<string>;
  84135. /** Gets or sets default key button width */
  84136. defaultButtonWidth: string;
  84137. /** Gets or sets default key button height */
  84138. defaultButtonHeight: string;
  84139. /** Gets or sets default key button left padding */
  84140. defaultButtonPaddingLeft: string;
  84141. /** Gets or sets default key button right padding */
  84142. defaultButtonPaddingRight: string;
  84143. /** Gets or sets default key button top padding */
  84144. defaultButtonPaddingTop: string;
  84145. /** Gets or sets default key button bottom padding */
  84146. defaultButtonPaddingBottom: string;
  84147. /** Gets or sets default key button foreground color */
  84148. defaultButtonColor: string;
  84149. /** Gets or sets default key button background color */
  84150. defaultButtonBackground: string;
  84151. /** Gets or sets shift button foreground color */
  84152. shiftButtonColor: string;
  84153. /** Gets or sets shift button thickness*/
  84154. selectedShiftThickness: number;
  84155. /** Gets shift key state */
  84156. shiftState: number;
  84157. protected _getTypeName(): string;
  84158. private _createKey;
  84159. /**
  84160. * Adds a new row of keys
  84161. * @param keys defines the list of keys to add
  84162. * @param propertySets defines the associated property sets
  84163. */
  84164. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84165. /**
  84166. * Set the shift key to a specific state
  84167. * @param shiftState defines the new shift state
  84168. */
  84169. applyShiftState(shiftState: number): void;
  84170. private _currentlyConnectedInputText;
  84171. private _connectedInputTexts;
  84172. private _onKeyPressObserver;
  84173. /** Gets the input text control currently attached to the keyboard */
  84174. get connectedInputText(): BABYLON.Nullable<InputText>;
  84175. /**
  84176. * Connects the keyboard with an input text control
  84177. *
  84178. * @param input defines the target control
  84179. */
  84180. connect(input: InputText): void;
  84181. /**
  84182. * Disconnects the keyboard from connected InputText controls
  84183. *
  84184. * @param input optionally defines a target control, otherwise all are disconnected
  84185. */
  84186. disconnect(input?: InputText): void;
  84187. private _removeConnectedInputObservables;
  84188. /**
  84189. * Release all resources
  84190. */
  84191. dispose(): void;
  84192. /**
  84193. * Creates a new keyboard using a default layout
  84194. *
  84195. * @param name defines control name
  84196. * @returns a new VirtualKeyboard
  84197. */
  84198. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84199. }
  84200. }
  84201. declare module BABYLON.GUI {
  84202. /** @hidden */
  84203. export class TextWrapper {
  84204. private _text;
  84205. private _characters;
  84206. get text(): string;
  84207. set text(txt: string);
  84208. get length(): number;
  84209. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84210. charAt(idx: number): string;
  84211. substr(from: number, length?: number): string;
  84212. substring(from: number, to?: number): string;
  84213. isWord(index: number): boolean;
  84214. }
  84215. }
  84216. declare module BABYLON.GUI {
  84217. /**
  84218. * Class used to create input text control
  84219. */
  84220. export class InputText extends Control implements IFocusableControl {
  84221. name?: string | undefined;
  84222. private _textWrapper;
  84223. private _placeholderText;
  84224. private _background;
  84225. private _focusedBackground;
  84226. private _focusedColor;
  84227. private _placeholderColor;
  84228. private _thickness;
  84229. private _margin;
  84230. private _autoStretchWidth;
  84231. private _maxWidth;
  84232. private _isFocused;
  84233. private _blinkTimeout;
  84234. private _blinkIsEven;
  84235. private _cursorOffset;
  84236. private _scrollLeft;
  84237. private _textWidth;
  84238. private _clickedCoordinate;
  84239. private _deadKey;
  84240. private _addKey;
  84241. private _currentKey;
  84242. private _isTextHighlightOn;
  84243. private _textHighlightColor;
  84244. private _highligherOpacity;
  84245. private _highlightedText;
  84246. private _startHighlightIndex;
  84247. private _endHighlightIndex;
  84248. private _cursorIndex;
  84249. private _onFocusSelectAll;
  84250. private _isPointerDown;
  84251. private _onClipboardObserver;
  84252. private _onPointerDblTapObserver;
  84253. /** @hidden */
  84254. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84255. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84256. promptMessage: string;
  84257. /** Force disable prompt on mobile device */
  84258. disableMobilePrompt: boolean;
  84259. /** BABYLON.Observable raised when the text changes */
  84260. onTextChangedObservable: BABYLON.Observable<InputText>;
  84261. /** BABYLON.Observable raised just before an entered character is to be added */
  84262. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84263. /** BABYLON.Observable raised when the control gets the focus */
  84264. onFocusObservable: BABYLON.Observable<InputText>;
  84265. /** BABYLON.Observable raised when the control loses the focus */
  84266. onBlurObservable: BABYLON.Observable<InputText>;
  84267. /**Observable raised when the text is highlighted */
  84268. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84269. /**Observable raised when copy event is triggered */
  84270. onTextCopyObservable: BABYLON.Observable<InputText>;
  84271. /** BABYLON.Observable raised when cut event is triggered */
  84272. onTextCutObservable: BABYLON.Observable<InputText>;
  84273. /** BABYLON.Observable raised when paste event is triggered */
  84274. onTextPasteObservable: BABYLON.Observable<InputText>;
  84275. /** BABYLON.Observable raised when a key event was processed */
  84276. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84277. /** Gets or sets the maximum width allowed by the control */
  84278. get maxWidth(): string | number;
  84279. /** Gets the maximum width allowed by the control in pixels */
  84280. get maxWidthInPixels(): number;
  84281. set maxWidth(value: string | number);
  84282. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84283. get highligherOpacity(): number;
  84284. set highligherOpacity(value: number);
  84285. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84286. get onFocusSelectAll(): boolean;
  84287. set onFocusSelectAll(value: boolean);
  84288. /** Gets or sets the text hightlight color */
  84289. get textHighlightColor(): string;
  84290. set textHighlightColor(value: string);
  84291. /** Gets or sets control margin */
  84292. get margin(): string;
  84293. /** Gets control margin in pixels */
  84294. get marginInPixels(): number;
  84295. set margin(value: string);
  84296. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84297. get autoStretchWidth(): boolean;
  84298. set autoStretchWidth(value: boolean);
  84299. /** Gets or sets border thickness */
  84300. get thickness(): number;
  84301. set thickness(value: number);
  84302. /** Gets or sets the background color when focused */
  84303. get focusedBackground(): string;
  84304. set focusedBackground(value: string);
  84305. /** Gets or sets the background color when focused */
  84306. get focusedColor(): string;
  84307. set focusedColor(value: string);
  84308. /** Gets or sets the background color */
  84309. get background(): string;
  84310. set background(value: string);
  84311. /** Gets or sets the placeholder color */
  84312. get placeholderColor(): string;
  84313. set placeholderColor(value: string);
  84314. /** Gets or sets the text displayed when the control is empty */
  84315. get placeholderText(): string;
  84316. set placeholderText(value: string);
  84317. /** Gets or sets the dead key flag */
  84318. get deadKey(): boolean;
  84319. set deadKey(flag: boolean);
  84320. /** Gets or sets the highlight text */
  84321. get highlightedText(): string;
  84322. set highlightedText(text: string);
  84323. /** Gets or sets if the current key should be added */
  84324. get addKey(): boolean;
  84325. set addKey(flag: boolean);
  84326. /** Gets or sets the value of the current key being entered */
  84327. get currentKey(): string;
  84328. set currentKey(key: string);
  84329. /** Gets or sets the text displayed in the control */
  84330. get text(): string;
  84331. set text(value: string);
  84332. private _textHasChanged;
  84333. /** Gets or sets control width */
  84334. get width(): string | number;
  84335. set width(value: string | number);
  84336. /**
  84337. * Creates a new InputText
  84338. * @param name defines the control name
  84339. * @param text defines the text of the control
  84340. */
  84341. constructor(name?: string | undefined, text?: string);
  84342. /** @hidden */
  84343. onBlur(): void;
  84344. /** @hidden */
  84345. onFocus(): void;
  84346. /**
  84347. * Function to focus an inputText programmatically
  84348. */
  84349. focus(): void;
  84350. /**
  84351. * Function to unfocus an inputText programmatically
  84352. */
  84353. blur(): void;
  84354. protected _getTypeName(): string;
  84355. /**
  84356. * Function called to get the list of controls that should not steal the focus from this control
  84357. * @returns an array of controls
  84358. */
  84359. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84360. /** @hidden */
  84361. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84362. /** @hidden */
  84363. private _updateValueFromCursorIndex;
  84364. /** @hidden */
  84365. private _processDblClick;
  84366. /** @hidden */
  84367. private _selectAllText;
  84368. /**
  84369. * Handles the keyboard event
  84370. * @param evt Defines the KeyboardEvent
  84371. */
  84372. processKeyboard(evt: KeyboardEvent): void;
  84373. /** @hidden */
  84374. private _onCopyText;
  84375. /** @hidden */
  84376. private _onCutText;
  84377. /** @hidden */
  84378. private _onPasteText;
  84379. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84380. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84381. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84382. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84383. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84384. dispose(): void;
  84385. }
  84386. }
  84387. declare module BABYLON.GUI {
  84388. /**
  84389. * Class used to create a 2D grid container
  84390. */
  84391. export class Grid extends Container {
  84392. name?: string | undefined;
  84393. private _rowDefinitions;
  84394. private _columnDefinitions;
  84395. private _cells;
  84396. private _childControls;
  84397. /**
  84398. * Gets the number of columns
  84399. */
  84400. get columnCount(): number;
  84401. /**
  84402. * Gets the number of rows
  84403. */
  84404. get rowCount(): number;
  84405. /** Gets the list of children */
  84406. get children(): Control[];
  84407. /** Gets the list of cells (e.g. the containers) */
  84408. get cells(): {
  84409. [key: string]: Container;
  84410. };
  84411. /**
  84412. * Gets the definition of a specific row
  84413. * @param index defines the index of the row
  84414. * @returns the row definition
  84415. */
  84416. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84417. /**
  84418. * Gets the definition of a specific column
  84419. * @param index defines the index of the column
  84420. * @returns the column definition
  84421. */
  84422. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84423. /**
  84424. * Adds a new row to the grid
  84425. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84426. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84427. * @returns the current grid
  84428. */
  84429. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84430. /**
  84431. * Adds a new column to the grid
  84432. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84433. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84434. * @returns the current grid
  84435. */
  84436. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84437. /**
  84438. * Update a row definition
  84439. * @param index defines the index of the row to update
  84440. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84441. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84442. * @returns the current grid
  84443. */
  84444. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84445. /**
  84446. * Update a column definition
  84447. * @param index defines the index of the column to update
  84448. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84449. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84450. * @returns the current grid
  84451. */
  84452. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84453. /**
  84454. * Gets the list of children stored in a specific cell
  84455. * @param row defines the row to check
  84456. * @param column defines the column to check
  84457. * @returns the list of controls
  84458. */
  84459. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84460. /**
  84461. * Gets a string representing the child cell info (row x column)
  84462. * @param child defines the control to get info from
  84463. * @returns a string containing the child cell info (row x column)
  84464. */
  84465. getChildCellInfo(child: Control): string;
  84466. private _removeCell;
  84467. private _offsetCell;
  84468. /**
  84469. * Remove a column definition at specified index
  84470. * @param index defines the index of the column to remove
  84471. * @returns the current grid
  84472. */
  84473. removeColumnDefinition(index: number): Grid;
  84474. /**
  84475. * Remove a row definition at specified index
  84476. * @param index defines the index of the row to remove
  84477. * @returns the current grid
  84478. */
  84479. removeRowDefinition(index: number): Grid;
  84480. /**
  84481. * Adds a new control to the current grid
  84482. * @param control defines the control to add
  84483. * @param row defines the row where to add the control (0 by default)
  84484. * @param column defines the column where to add the control (0 by default)
  84485. * @returns the current grid
  84486. */
  84487. addControl(control: Control, row?: number, column?: number): Grid;
  84488. /**
  84489. * Removes a control from the current container
  84490. * @param control defines the control to remove
  84491. * @returns the current container
  84492. */
  84493. removeControl(control: Control): Container;
  84494. /**
  84495. * Creates a new Grid
  84496. * @param name defines control name
  84497. */
  84498. constructor(name?: string | undefined);
  84499. protected _getTypeName(): string;
  84500. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84501. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84502. _flagDescendantsAsMatrixDirty(): void;
  84503. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84504. /** Releases associated resources */
  84505. dispose(): void;
  84506. }
  84507. }
  84508. declare module BABYLON.GUI {
  84509. /** Class used to create color pickers */
  84510. export class ColorPicker extends Control {
  84511. name?: string | undefined;
  84512. private static _Epsilon;
  84513. private _colorWheelCanvas;
  84514. private _value;
  84515. private _tmpColor;
  84516. private _pointerStartedOnSquare;
  84517. private _pointerStartedOnWheel;
  84518. private _squareLeft;
  84519. private _squareTop;
  84520. private _squareSize;
  84521. private _h;
  84522. private _s;
  84523. private _v;
  84524. private _lastPointerDownID;
  84525. /**
  84526. * BABYLON.Observable raised when the value changes
  84527. */
  84528. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84529. /** Gets or sets the color of the color picker */
  84530. get value(): BABYLON.Color3;
  84531. set value(value: BABYLON.Color3);
  84532. /**
  84533. * Gets or sets control width
  84534. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84535. */
  84536. get width(): string | number;
  84537. set width(value: string | number);
  84538. /**
  84539. * Gets or sets control height
  84540. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84541. */
  84542. get height(): string | number;
  84543. /** Gets or sets control height */
  84544. set height(value: string | number);
  84545. /** Gets or sets control size */
  84546. get size(): string | number;
  84547. set size(value: string | number);
  84548. /**
  84549. * Creates a new ColorPicker
  84550. * @param name defines the control name
  84551. */
  84552. constructor(name?: string | undefined);
  84553. protected _getTypeName(): string;
  84554. /** @hidden */
  84555. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84556. private _updateSquareProps;
  84557. private _drawGradientSquare;
  84558. private _drawCircle;
  84559. private _createColorWheelCanvas;
  84560. /** @hidden */
  84561. _draw(context: CanvasRenderingContext2D): void;
  84562. private _pointerIsDown;
  84563. private _updateValueFromPointer;
  84564. private _isPointOnSquare;
  84565. private _isPointOnWheel;
  84566. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84567. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84568. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84569. _onCanvasBlur(): void;
  84570. /**
  84571. * This function expands the color picker by creating a color picker dialog with manual
  84572. * color value input and the ability to save colors into an array to be used later in
  84573. * subsequent launches of the dialogue.
  84574. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84575. * @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.
  84576. * @returns picked color as a hex string and the saved colors array as hex strings.
  84577. */
  84578. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84579. pickerWidth?: string;
  84580. pickerHeight?: string;
  84581. headerHeight?: string;
  84582. lastColor?: string;
  84583. swatchLimit?: number;
  84584. numSwatchesPerLine?: number;
  84585. savedColors?: Array<string>;
  84586. }): Promise<{
  84587. savedColors?: string[];
  84588. pickedColor: string;
  84589. }>;
  84590. }
  84591. }
  84592. declare module BABYLON.GUI {
  84593. /** Class used to create 2D ellipse containers */
  84594. export class Ellipse extends Container {
  84595. name?: string | undefined;
  84596. private _thickness;
  84597. /** Gets or sets border thickness */
  84598. get thickness(): number;
  84599. set thickness(value: number);
  84600. /**
  84601. * Creates a new Ellipse
  84602. * @param name defines the control name
  84603. */
  84604. constructor(name?: string | undefined);
  84605. protected _getTypeName(): string;
  84606. protected _localDraw(context: CanvasRenderingContext2D): void;
  84607. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84608. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84609. }
  84610. }
  84611. declare module BABYLON.GUI {
  84612. /**
  84613. * Class used to create a focusable button that can easily handle keyboard events
  84614. */
  84615. export class FocusableButton extends Button implements IFocusableControl {
  84616. name?: string | undefined;
  84617. /** Highlight color when button is focused */
  84618. focusedColor: BABYLON.Nullable<string>;
  84619. private _isFocused;
  84620. private _unfocusedColor;
  84621. /** BABYLON.Observable raised when the control gets the focus */
  84622. onFocusObservable: BABYLON.Observable<Button>;
  84623. /** BABYLON.Observable raised when the control loses the focus */
  84624. onBlurObservable: BABYLON.Observable<Button>;
  84625. /** BABYLON.Observable raised when a key event was processed */
  84626. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84627. constructor(name?: string | undefined);
  84628. /** @hidden */
  84629. onBlur(): void;
  84630. /** @hidden */
  84631. onFocus(): void;
  84632. /**
  84633. * Function called to get the list of controls that should not steal the focus from this control
  84634. * @returns an array of controls
  84635. */
  84636. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84637. /**
  84638. * Function to focus a button programmatically
  84639. */
  84640. focus(): void;
  84641. /**
  84642. * Function to unfocus a button programmatically
  84643. */
  84644. blur(): void;
  84645. /**
  84646. * Handles the keyboard event
  84647. * @param evt Defines the KeyboardEvent
  84648. */
  84649. processKeyboard(evt: KeyboardEvent): void;
  84650. /** @hidden */
  84651. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84652. /** @hidden */
  84653. displose(): void;
  84654. }
  84655. }
  84656. declare module BABYLON.GUI {
  84657. /**
  84658. * Class used to create a password control
  84659. */
  84660. export class InputPassword extends InputText {
  84661. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84662. }
  84663. }
  84664. declare module BABYLON.GUI {
  84665. /** Class used to render 2D lines */
  84666. export class Line extends Control {
  84667. name?: string | undefined;
  84668. private _lineWidth;
  84669. private _x1;
  84670. private _y1;
  84671. private _x2;
  84672. private _y2;
  84673. private _dash;
  84674. private _connectedControl;
  84675. private _connectedControlDirtyObserver;
  84676. /** Gets or sets the dash pattern */
  84677. get dash(): Array<number>;
  84678. set dash(value: Array<number>);
  84679. /** Gets or sets the control connected with the line end */
  84680. get connectedControl(): Control;
  84681. set connectedControl(value: Control);
  84682. /** Gets or sets start coordinates on X axis */
  84683. get x1(): string | number;
  84684. set x1(value: string | number);
  84685. /** Gets or sets start coordinates on Y axis */
  84686. get y1(): string | number;
  84687. set y1(value: string | number);
  84688. /** Gets or sets end coordinates on X axis */
  84689. get x2(): string | number;
  84690. set x2(value: string | number);
  84691. /** Gets or sets end coordinates on Y axis */
  84692. get y2(): string | number;
  84693. set y2(value: string | number);
  84694. /** Gets or sets line width */
  84695. get lineWidth(): number;
  84696. set lineWidth(value: number);
  84697. /** Gets or sets horizontal alignment */
  84698. set horizontalAlignment(value: number);
  84699. /** Gets or sets vertical alignment */
  84700. set verticalAlignment(value: number);
  84701. private get _effectiveX2();
  84702. private get _effectiveY2();
  84703. /**
  84704. * Creates a new Line
  84705. * @param name defines the control name
  84706. */
  84707. constructor(name?: string | undefined);
  84708. protected _getTypeName(): string;
  84709. _draw(context: CanvasRenderingContext2D): void;
  84710. _measure(): void;
  84711. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84712. /**
  84713. * Move one end of the line given 3D cartesian coordinates.
  84714. * @param position Targeted world position
  84715. * @param scene BABYLON.Scene
  84716. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84717. */
  84718. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84719. /**
  84720. * Move one end of the line to a position in screen absolute space.
  84721. * @param projectedPosition Position in screen absolute space (X, Y)
  84722. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84723. */
  84724. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84725. }
  84726. }
  84727. declare module BABYLON.GUI {
  84728. /**
  84729. * Class used to store a point for a MultiLine object.
  84730. * The point can be pure 2D coordinates, a mesh or a control
  84731. */
  84732. export class MultiLinePoint {
  84733. private _multiLine;
  84734. private _x;
  84735. private _y;
  84736. private _control;
  84737. private _mesh;
  84738. private _controlObserver;
  84739. private _meshObserver;
  84740. /** @hidden */
  84741. _point: BABYLON.Vector3;
  84742. /**
  84743. * Creates a new MultiLinePoint
  84744. * @param multiLine defines the source MultiLine object
  84745. */
  84746. constructor(multiLine: MultiLine);
  84747. /** Gets or sets x coordinate */
  84748. get x(): string | number;
  84749. set x(value: string | number);
  84750. /** Gets or sets y coordinate */
  84751. get y(): string | number;
  84752. set y(value: string | number);
  84753. /** Gets or sets the control associated with this point */
  84754. get control(): BABYLON.Nullable<Control>;
  84755. set control(value: BABYLON.Nullable<Control>);
  84756. /** Gets or sets the mesh associated with this point */
  84757. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84758. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84759. /** Resets links */
  84760. resetLinks(): void;
  84761. /**
  84762. * Gets a translation vector with Z component
  84763. * @returns the translation vector
  84764. */
  84765. translate(): BABYLON.Vector3;
  84766. private _translatePoint;
  84767. /** Release associated resources */
  84768. dispose(): void;
  84769. }
  84770. }
  84771. declare module BABYLON.GUI {
  84772. /**
  84773. * Class used to create multi line control
  84774. */
  84775. export class MultiLine extends Control {
  84776. name?: string | undefined;
  84777. private _lineWidth;
  84778. private _dash;
  84779. private _points;
  84780. private _minX;
  84781. private _minY;
  84782. private _maxX;
  84783. private _maxY;
  84784. /**
  84785. * Creates a new MultiLine
  84786. * @param name defines the control name
  84787. */
  84788. constructor(name?: string | undefined);
  84789. /** Gets or sets dash pattern */
  84790. get dash(): Array<number>;
  84791. set dash(value: Array<number>);
  84792. /**
  84793. * Gets point stored at specified index
  84794. * @param index defines the index to look for
  84795. * @returns the requested point if found
  84796. */
  84797. getAt(index: number): MultiLinePoint;
  84798. /** Function called when a point is updated */
  84799. onPointUpdate: () => void;
  84800. /**
  84801. * Adds new points to the point collection
  84802. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84803. * @returns the list of created MultiLinePoint
  84804. */
  84805. add(...items: (AbstractMesh | Control | {
  84806. x: string | number;
  84807. y: string | number;
  84808. })[]): MultiLinePoint[];
  84809. /**
  84810. * Adds a new point to the point collection
  84811. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84812. * @returns the created MultiLinePoint
  84813. */
  84814. push(item?: (AbstractMesh | Control | {
  84815. x: string | number;
  84816. y: string | number;
  84817. })): MultiLinePoint;
  84818. /**
  84819. * Remove a specific value or point from the active point collection
  84820. * @param value defines the value or point to remove
  84821. */
  84822. remove(value: number | MultiLinePoint): void;
  84823. /**
  84824. * Resets this object to initial state (no point)
  84825. */
  84826. reset(): void;
  84827. /**
  84828. * Resets all links
  84829. */
  84830. resetLinks(): void;
  84831. /** Gets or sets line width */
  84832. get lineWidth(): number;
  84833. set lineWidth(value: number);
  84834. set horizontalAlignment(value: number);
  84835. set verticalAlignment(value: number);
  84836. protected _getTypeName(): string;
  84837. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84838. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84839. _measure(): void;
  84840. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84841. dispose(): void;
  84842. }
  84843. }
  84844. declare module BABYLON.GUI {
  84845. /**
  84846. * Class used to create radio button controls
  84847. */
  84848. export class RadioButton extends Control {
  84849. name?: string | undefined;
  84850. private _isChecked;
  84851. private _background;
  84852. private _checkSizeRatio;
  84853. private _thickness;
  84854. /** Gets or sets border thickness */
  84855. get thickness(): number;
  84856. set thickness(value: number);
  84857. /** Gets or sets group name */
  84858. group: string;
  84859. /** BABYLON.Observable raised when isChecked is changed */
  84860. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84861. /** Gets or sets a value indicating the ratio between overall size and check size */
  84862. get checkSizeRatio(): number;
  84863. set checkSizeRatio(value: number);
  84864. /** Gets or sets background color */
  84865. get background(): string;
  84866. set background(value: string);
  84867. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84868. get isChecked(): boolean;
  84869. set isChecked(value: boolean);
  84870. /**
  84871. * Creates a new RadioButton
  84872. * @param name defines the control name
  84873. */
  84874. constructor(name?: string | undefined);
  84875. protected _getTypeName(): string;
  84876. _draw(context: CanvasRenderingContext2D): void;
  84877. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84878. /**
  84879. * Utility function to easily create a radio button with a header
  84880. * @param title defines the label to use for the header
  84881. * @param group defines the group to use for the radio button
  84882. * @param isChecked defines the initial state of the radio button
  84883. * @param onValueChanged defines the callback to call when value changes
  84884. * @returns a StackPanel containing the radio button and a textBlock
  84885. */
  84886. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84887. }
  84888. }
  84889. declare module BABYLON.GUI {
  84890. /**
  84891. * Class used to create slider controls
  84892. */
  84893. export class BaseSlider extends Control {
  84894. name?: string | undefined;
  84895. protected _thumbWidth: ValueAndUnit;
  84896. private _minimum;
  84897. private _maximum;
  84898. private _value;
  84899. private _isVertical;
  84900. protected _barOffset: ValueAndUnit;
  84901. private _isThumbClamped;
  84902. protected _displayThumb: boolean;
  84903. private _step;
  84904. private _lastPointerDownID;
  84905. protected _effectiveBarOffset: number;
  84906. protected _renderLeft: number;
  84907. protected _renderTop: number;
  84908. protected _renderWidth: number;
  84909. protected _renderHeight: number;
  84910. protected _backgroundBoxLength: number;
  84911. protected _backgroundBoxThickness: number;
  84912. protected _effectiveThumbThickness: number;
  84913. /** BABYLON.Observable raised when the sldier value changes */
  84914. onValueChangedObservable: BABYLON.Observable<number>;
  84915. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84916. get displayThumb(): boolean;
  84917. set displayThumb(value: boolean);
  84918. /** Gets or sets a step to apply to values (0 by default) */
  84919. get step(): number;
  84920. set step(value: number);
  84921. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84922. get barOffset(): string | number;
  84923. /** Gets main bar offset in pixels*/
  84924. get barOffsetInPixels(): number;
  84925. set barOffset(value: string | number);
  84926. /** Gets or sets thumb width */
  84927. get thumbWidth(): string | number;
  84928. /** Gets thumb width in pixels */
  84929. get thumbWidthInPixels(): number;
  84930. set thumbWidth(value: string | number);
  84931. /** Gets or sets minimum value */
  84932. get minimum(): number;
  84933. set minimum(value: number);
  84934. /** Gets or sets maximum value */
  84935. get maximum(): number;
  84936. set maximum(value: number);
  84937. /** Gets or sets current value */
  84938. get value(): number;
  84939. set value(value: number);
  84940. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84941. get isVertical(): boolean;
  84942. set isVertical(value: boolean);
  84943. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84944. get isThumbClamped(): boolean;
  84945. set isThumbClamped(value: boolean);
  84946. /**
  84947. * Creates a new BaseSlider
  84948. * @param name defines the control name
  84949. */
  84950. constructor(name?: string | undefined);
  84951. protected _getTypeName(): string;
  84952. protected _getThumbPosition(): number;
  84953. protected _getThumbThickness(type: string): number;
  84954. protected _prepareRenderingData(type: string): void;
  84955. private _pointerIsDown;
  84956. /** @hidden */
  84957. protected _updateValueFromPointer(x: number, y: number): void;
  84958. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84959. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84960. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84961. _onCanvasBlur(): void;
  84962. }
  84963. }
  84964. declare module BABYLON.GUI {
  84965. /**
  84966. * Class used to create slider controls
  84967. */
  84968. export class Slider extends BaseSlider {
  84969. name?: string | undefined;
  84970. private _background;
  84971. private _borderColor;
  84972. private _thumbColor;
  84973. private _isThumbCircle;
  84974. protected _displayValueBar: boolean;
  84975. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84976. get displayValueBar(): boolean;
  84977. set displayValueBar(value: boolean);
  84978. /** Gets or sets border color */
  84979. get borderColor(): string;
  84980. set borderColor(value: string);
  84981. /** Gets or sets background color */
  84982. get background(): string;
  84983. set background(value: string);
  84984. /** Gets or sets thumb's color */
  84985. get thumbColor(): string;
  84986. set thumbColor(value: string);
  84987. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84988. get isThumbCircle(): boolean;
  84989. set isThumbCircle(value: boolean);
  84990. /**
  84991. * Creates a new Slider
  84992. * @param name defines the control name
  84993. */
  84994. constructor(name?: string | undefined);
  84995. protected _getTypeName(): string;
  84996. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84997. }
  84998. }
  84999. declare module BABYLON.GUI {
  85000. /** Class used to create a RadioGroup
  85001. * which contains groups of radio buttons
  85002. */
  85003. export class SelectorGroup {
  85004. /** name of SelectorGroup */
  85005. name: string;
  85006. private _groupPanel;
  85007. private _selectors;
  85008. private _groupHeader;
  85009. /**
  85010. * Creates a new SelectorGroup
  85011. * @param name of group, used as a group heading
  85012. */
  85013. constructor(
  85014. /** name of SelectorGroup */
  85015. name: string);
  85016. /** Gets the groupPanel of the SelectorGroup */
  85017. get groupPanel(): StackPanel;
  85018. /** Gets the selectors array */
  85019. get selectors(): StackPanel[];
  85020. /** Gets and sets the group header */
  85021. get header(): string;
  85022. set header(label: string);
  85023. /** @hidden */
  85024. private _addGroupHeader;
  85025. /** @hidden*/
  85026. _getSelector(selectorNb: number): StackPanel | undefined;
  85027. /** Removes the selector at the given position
  85028. * @param selectorNb the position of the selector within the group
  85029. */
  85030. removeSelector(selectorNb: number): void;
  85031. }
  85032. /** Class used to create a CheckboxGroup
  85033. * which contains groups of checkbox buttons
  85034. */
  85035. export class CheckboxGroup extends SelectorGroup {
  85036. /** Adds a checkbox as a control
  85037. * @param text is the label for the selector
  85038. * @param func is the function called when the Selector is checked
  85039. * @param checked is true when Selector is checked
  85040. */
  85041. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85042. /** @hidden */
  85043. _setSelectorLabel(selectorNb: number, label: string): void;
  85044. /** @hidden */
  85045. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85046. /** @hidden */
  85047. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85048. /** @hidden */
  85049. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85050. }
  85051. /** Class used to create a RadioGroup
  85052. * which contains groups of radio buttons
  85053. */
  85054. export class RadioGroup extends SelectorGroup {
  85055. private _selectNb;
  85056. /** Adds a radio button as a control
  85057. * @param label is the label for the selector
  85058. * @param func is the function called when the Selector is checked
  85059. * @param checked is true when Selector is checked
  85060. */
  85061. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85062. /** @hidden */
  85063. _setSelectorLabel(selectorNb: number, label: string): void;
  85064. /** @hidden */
  85065. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85066. /** @hidden */
  85067. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85068. /** @hidden */
  85069. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85070. }
  85071. /** Class used to create a SliderGroup
  85072. * which contains groups of slider buttons
  85073. */
  85074. export class SliderGroup extends SelectorGroup {
  85075. /**
  85076. * Adds a slider to the SelectorGroup
  85077. * @param label is the label for the SliderBar
  85078. * @param func is the function called when the Slider moves
  85079. * @param unit is a string describing the units used, eg degrees or metres
  85080. * @param min is the minimum value for the Slider
  85081. * @param max is the maximum value for the Slider
  85082. * @param value is the start value for the Slider between min and max
  85083. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85084. */
  85085. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85086. /** @hidden */
  85087. _setSelectorLabel(selectorNb: number, label: string): void;
  85088. /** @hidden */
  85089. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85090. /** @hidden */
  85091. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85092. /** @hidden */
  85093. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85094. }
  85095. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85096. * @see https://doc.babylonjs.com/how_to/selector
  85097. */
  85098. export class SelectionPanel extends Rectangle {
  85099. /** name of SelectionPanel */
  85100. name: string;
  85101. /** an array of SelectionGroups */
  85102. groups: SelectorGroup[];
  85103. private _panel;
  85104. private _buttonColor;
  85105. private _buttonBackground;
  85106. private _headerColor;
  85107. private _barColor;
  85108. private _barHeight;
  85109. private _spacerHeight;
  85110. private _labelColor;
  85111. private _groups;
  85112. private _bars;
  85113. /**
  85114. * Creates a new SelectionPanel
  85115. * @param name of SelectionPanel
  85116. * @param groups is an array of SelectionGroups
  85117. */
  85118. constructor(
  85119. /** name of SelectionPanel */
  85120. name: string,
  85121. /** an array of SelectionGroups */
  85122. groups?: SelectorGroup[]);
  85123. protected _getTypeName(): string;
  85124. /** Gets the (stack) panel of the SelectionPanel */
  85125. get panel(): StackPanel;
  85126. /** Gets or sets the headerColor */
  85127. get headerColor(): string;
  85128. set headerColor(color: string);
  85129. private _setHeaderColor;
  85130. /** Gets or sets the button color */
  85131. get buttonColor(): string;
  85132. set buttonColor(color: string);
  85133. private _setbuttonColor;
  85134. /** Gets or sets the label color */
  85135. get labelColor(): string;
  85136. set labelColor(color: string);
  85137. private _setLabelColor;
  85138. /** Gets or sets the button background */
  85139. get buttonBackground(): string;
  85140. set buttonBackground(color: string);
  85141. private _setButtonBackground;
  85142. /** Gets or sets the color of separator bar */
  85143. get barColor(): string;
  85144. set barColor(color: string);
  85145. private _setBarColor;
  85146. /** Gets or sets the height of separator bar */
  85147. get barHeight(): string;
  85148. set barHeight(value: string);
  85149. private _setBarHeight;
  85150. /** Gets or sets the height of spacers*/
  85151. get spacerHeight(): string;
  85152. set spacerHeight(value: string);
  85153. private _setSpacerHeight;
  85154. /** Adds a bar between groups */
  85155. private _addSpacer;
  85156. /** Add a group to the selection panel
  85157. * @param group is the selector group to add
  85158. */
  85159. addGroup(group: SelectorGroup): void;
  85160. /** Remove the group from the given position
  85161. * @param groupNb is the position of the group in the list
  85162. */
  85163. removeGroup(groupNb: number): void;
  85164. /** Change a group header label
  85165. * @param label is the new group header label
  85166. * @param groupNb is the number of the group to relabel
  85167. * */
  85168. setHeaderName(label: string, groupNb: number): void;
  85169. /** Change selector label to the one given
  85170. * @param label is the new selector label
  85171. * @param groupNb is the number of the groupcontaining the selector
  85172. * @param selectorNb is the number of the selector within a group to relabel
  85173. * */
  85174. relabel(label: string, groupNb: number, selectorNb: number): void;
  85175. /** For a given group position remove the selector at the given position
  85176. * @param groupNb is the number of the group to remove the selector from
  85177. * @param selectorNb is the number of the selector within the group
  85178. */
  85179. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85180. /** For a given group position of correct type add a checkbox button
  85181. * @param groupNb is the number of the group to remove the selector from
  85182. * @param label is the label for the selector
  85183. * @param func is the function called when the Selector is checked
  85184. * @param checked is true when Selector is checked
  85185. */
  85186. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85187. /** For a given group position of correct type add a radio button
  85188. * @param groupNb is the number of the group to remove the selector from
  85189. * @param label is the label for the selector
  85190. * @param func is the function called when the Selector is checked
  85191. * @param checked is true when Selector is checked
  85192. */
  85193. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85194. /**
  85195. * For a given slider group add a slider
  85196. * @param groupNb is the number of the group to add the slider to
  85197. * @param label is the label for the Slider
  85198. * @param func is the function called when the Slider moves
  85199. * @param unit is a string describing the units used, eg degrees or metres
  85200. * @param min is the minimum value for the Slider
  85201. * @param max is the maximum value for the Slider
  85202. * @param value is the start value for the Slider between min and max
  85203. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85204. */
  85205. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85206. }
  85207. }
  85208. declare module BABYLON.GUI {
  85209. /**
  85210. * Class used to hold a the container for ScrollViewer
  85211. * @hidden
  85212. */
  85213. export class _ScrollViewerWindow extends Container {
  85214. parentClientWidth: number;
  85215. parentClientHeight: number;
  85216. private _freezeControls;
  85217. private _parentMeasure;
  85218. private _oldLeft;
  85219. private _oldTop;
  85220. get freezeControls(): boolean;
  85221. set freezeControls(value: boolean);
  85222. private _bucketWidth;
  85223. private _bucketHeight;
  85224. private _buckets;
  85225. private _bucketLen;
  85226. get bucketWidth(): number;
  85227. get bucketHeight(): number;
  85228. setBucketSizes(width: number, height: number): void;
  85229. private _useBuckets;
  85230. private _makeBuckets;
  85231. private _dispatchInBuckets;
  85232. private _updateMeasures;
  85233. private _updateChildrenMeasures;
  85234. private _restoreMeasures;
  85235. /**
  85236. * Creates a new ScrollViewerWindow
  85237. * @param name of ScrollViewerWindow
  85238. */
  85239. constructor(name?: string);
  85240. protected _getTypeName(): string;
  85241. /** @hidden */
  85242. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85243. /** @hidden */
  85244. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85245. private _scrollChildren;
  85246. private _scrollChildrenWithBuckets;
  85247. /** @hidden */
  85248. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85249. protected _postMeasure(): void;
  85250. }
  85251. }
  85252. declare module BABYLON.GUI {
  85253. /**
  85254. * Class used to create slider controls
  85255. */
  85256. export class ScrollBar extends BaseSlider {
  85257. name?: string | undefined;
  85258. private _background;
  85259. private _borderColor;
  85260. private _tempMeasure;
  85261. /** Gets or sets border color */
  85262. get borderColor(): string;
  85263. set borderColor(value: string);
  85264. /** Gets or sets background color */
  85265. get background(): string;
  85266. set background(value: string);
  85267. /**
  85268. * Creates a new Slider
  85269. * @param name defines the control name
  85270. */
  85271. constructor(name?: string | undefined);
  85272. protected _getTypeName(): string;
  85273. protected _getThumbThickness(): number;
  85274. _draw(context: CanvasRenderingContext2D): void;
  85275. private _first;
  85276. private _originX;
  85277. private _originY;
  85278. /** @hidden */
  85279. protected _updateValueFromPointer(x: number, y: number): void;
  85280. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85281. }
  85282. }
  85283. declare module BABYLON.GUI {
  85284. /**
  85285. * Class used to create slider controls
  85286. */
  85287. export class ImageScrollBar extends BaseSlider {
  85288. name?: string | undefined;
  85289. private _backgroundBaseImage;
  85290. private _backgroundImage;
  85291. private _thumbImage;
  85292. private _thumbBaseImage;
  85293. private _thumbLength;
  85294. private _thumbHeight;
  85295. private _barImageHeight;
  85296. private _tempMeasure;
  85297. /** Number of 90° rotation to apply on the images when in vertical mode */
  85298. num90RotationInVerticalMode: number;
  85299. /**
  85300. * Gets or sets the image used to render the background for horizontal bar
  85301. */
  85302. get backgroundImage(): Image;
  85303. set backgroundImage(value: Image);
  85304. /**
  85305. * Gets or sets the image used to render the thumb
  85306. */
  85307. get thumbImage(): Image;
  85308. set thumbImage(value: Image);
  85309. /**
  85310. * Gets or sets the length of the thumb
  85311. */
  85312. get thumbLength(): number;
  85313. set thumbLength(value: number);
  85314. /**
  85315. * Gets or sets the height of the thumb
  85316. */
  85317. get thumbHeight(): number;
  85318. set thumbHeight(value: number);
  85319. /**
  85320. * Gets or sets the height of the bar image
  85321. */
  85322. get barImageHeight(): number;
  85323. set barImageHeight(value: number);
  85324. /**
  85325. * Creates a new ImageScrollBar
  85326. * @param name defines the control name
  85327. */
  85328. constructor(name?: string | undefined);
  85329. protected _getTypeName(): string;
  85330. protected _getThumbThickness(): number;
  85331. _draw(context: CanvasRenderingContext2D): void;
  85332. private _first;
  85333. private _originX;
  85334. private _originY;
  85335. /** @hidden */
  85336. protected _updateValueFromPointer(x: number, y: number): void;
  85337. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85338. }
  85339. }
  85340. declare module BABYLON.GUI {
  85341. /**
  85342. * Class used to hold a viewer window and sliders in a grid
  85343. */
  85344. export class ScrollViewer extends Rectangle {
  85345. private _grid;
  85346. private _horizontalBarSpace;
  85347. private _verticalBarSpace;
  85348. private _dragSpace;
  85349. private _horizontalBar;
  85350. private _verticalBar;
  85351. private _barColor;
  85352. private _barBackground;
  85353. private _barImage;
  85354. private _horizontalBarImage;
  85355. private _verticalBarImage;
  85356. private _barBackgroundImage;
  85357. private _horizontalBarBackgroundImage;
  85358. private _verticalBarBackgroundImage;
  85359. private _barSize;
  85360. private _window;
  85361. private _pointerIsOver;
  85362. private _wheelPrecision;
  85363. private _onWheelObserver;
  85364. private _clientWidth;
  85365. private _clientHeight;
  85366. private _useImageBar;
  85367. private _thumbLength;
  85368. private _thumbHeight;
  85369. private _barImageHeight;
  85370. private _horizontalBarImageHeight;
  85371. private _verticalBarImageHeight;
  85372. private _oldWindowContentsWidth;
  85373. private _oldWindowContentsHeight;
  85374. /**
  85375. * Gets the horizontal scrollbar
  85376. */
  85377. get horizontalBar(): ScrollBar | ImageScrollBar;
  85378. /**
  85379. * Gets the vertical scrollbar
  85380. */
  85381. get verticalBar(): ScrollBar | ImageScrollBar;
  85382. /**
  85383. * Adds a new control to the current container
  85384. * @param control defines the control to add
  85385. * @returns the current container
  85386. */
  85387. addControl(control: BABYLON.Nullable<Control>): Container;
  85388. /**
  85389. * Removes a control from the current container
  85390. * @param control defines the control to remove
  85391. * @returns the current container
  85392. */
  85393. removeControl(control: Control): Container;
  85394. /** Gets the list of children */
  85395. get children(): Control[];
  85396. _flagDescendantsAsMatrixDirty(): void;
  85397. /**
  85398. * Freezes or unfreezes the controls in the window.
  85399. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85400. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85401. */
  85402. get freezeControls(): boolean;
  85403. set freezeControls(value: boolean);
  85404. /** Gets the bucket width */
  85405. get bucketWidth(): number;
  85406. /** Gets the bucket height */
  85407. get bucketHeight(): number;
  85408. /**
  85409. * Sets the bucket sizes.
  85410. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85411. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85412. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85413. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85414. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85415. * used), that's why it is not enabled by default.
  85416. * @param width width of the bucket
  85417. * @param height height of the bucket
  85418. */
  85419. setBucketSizes(width: number, height: number): void;
  85420. private _forceHorizontalBar;
  85421. private _forceVerticalBar;
  85422. /**
  85423. * Forces the horizontal scroll bar to be displayed
  85424. */
  85425. get forceHorizontalBar(): boolean;
  85426. set forceHorizontalBar(value: boolean);
  85427. /**
  85428. * Forces the vertical scroll bar to be displayed
  85429. */
  85430. get forceVerticalBar(): boolean;
  85431. set forceVerticalBar(value: boolean);
  85432. /**
  85433. * Creates a new ScrollViewer
  85434. * @param name of ScrollViewer
  85435. */
  85436. constructor(name?: string, isImageBased?: boolean);
  85437. /** Reset the scroll viewer window to initial size */
  85438. resetWindow(): void;
  85439. protected _getTypeName(): string;
  85440. private _buildClientSizes;
  85441. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85442. protected _postMeasure(): void;
  85443. /**
  85444. * Gets or sets the mouse wheel precision
  85445. * from 0 to 1 with a default value of 0.05
  85446. * */
  85447. get wheelPrecision(): number;
  85448. set wheelPrecision(value: number);
  85449. /** Gets or sets the scroll bar container background color */
  85450. get scrollBackground(): string;
  85451. set scrollBackground(color: string);
  85452. /** Gets or sets the bar color */
  85453. get barColor(): string;
  85454. set barColor(color: string);
  85455. /** Gets or sets the bar image */
  85456. get thumbImage(): Image;
  85457. set thumbImage(value: Image);
  85458. /** Gets or sets the horizontal bar image */
  85459. get horizontalThumbImage(): Image;
  85460. set horizontalThumbImage(value: Image);
  85461. /** Gets or sets the vertical bar image */
  85462. get verticalThumbImage(): Image;
  85463. set verticalThumbImage(value: Image);
  85464. /** Gets or sets the size of the bar */
  85465. get barSize(): number;
  85466. set barSize(value: number);
  85467. /** Gets or sets the length of the thumb */
  85468. get thumbLength(): number;
  85469. set thumbLength(value: number);
  85470. /** Gets or sets the height of the thumb */
  85471. get thumbHeight(): number;
  85472. set thumbHeight(value: number);
  85473. /** Gets or sets the height of the bar image */
  85474. get barImageHeight(): number;
  85475. set barImageHeight(value: number);
  85476. /** Gets or sets the height of the horizontal bar image */
  85477. get horizontalBarImageHeight(): number;
  85478. set horizontalBarImageHeight(value: number);
  85479. /** Gets or sets the height of the vertical bar image */
  85480. get verticalBarImageHeight(): number;
  85481. set verticalBarImageHeight(value: number);
  85482. /** Gets or sets the bar background */
  85483. get barBackground(): string;
  85484. set barBackground(color: string);
  85485. /** Gets or sets the bar background image */
  85486. get barImage(): Image;
  85487. set barImage(value: Image);
  85488. /** Gets or sets the horizontal bar background image */
  85489. get horizontalBarImage(): Image;
  85490. set horizontalBarImage(value: Image);
  85491. /** Gets or sets the vertical bar background image */
  85492. get verticalBarImage(): Image;
  85493. set verticalBarImage(value: Image);
  85494. private _setWindowPosition;
  85495. /** @hidden */
  85496. private _updateScroller;
  85497. _link(host: AdvancedDynamicTexture): void;
  85498. /** @hidden */
  85499. private _addBar;
  85500. /** @hidden */
  85501. private _attachWheel;
  85502. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85503. /** Releases associated resources */
  85504. dispose(): void;
  85505. }
  85506. }
  85507. declare module BABYLON.GUI {
  85508. /**
  85509. * Class used to create toggle buttons
  85510. */
  85511. export class ToggleButton extends Rectangle {
  85512. name?: string | undefined;
  85513. /**
  85514. * Function called to generate the toActive animation
  85515. */
  85516. toActiveAnimation: () => void;
  85517. /**
  85518. * Function called to generate the toInactive animation
  85519. */
  85520. toInactiveAnimation: () => void;
  85521. /**
  85522. * Function called to generate a pointer enter animation when the toggle button is active.
  85523. */
  85524. pointerEnterActiveAnimation: () => void;
  85525. /**
  85526. * Function called to generate a pointer out animation when the toggle button is active.
  85527. */
  85528. pointerOutActiveAnimation: () => void;
  85529. /**
  85530. * Function called to generate a pointer down animation when the toggle button is active.
  85531. */
  85532. pointerDownActiveAnimation: () => void;
  85533. /**
  85534. * Function called to generate a pointer up animation when the toggle button is active.
  85535. */
  85536. pointerUpActiveAnimation: () => void;
  85537. /**
  85538. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85539. */
  85540. pointerEnterInactiveAnimation: () => void;
  85541. /**
  85542. * Function called to generate a pointer out animation when the toggle button is inactive.
  85543. */
  85544. pointerOutInactiveAnimation: () => void;
  85545. /**
  85546. * Function called to generate a pointer down animation when the toggle button is inactive.
  85547. */
  85548. pointerDownInactiveAnimation: () => void;
  85549. /**
  85550. * Function called to generate a pointer up animation when the toggle button is inactive.
  85551. */
  85552. pointerUpInactiveAnimation: () => void;
  85553. /** BABYLON.Observable raised when isActive is changed */
  85554. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85555. /**
  85556. * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info
  85557. */
  85558. delegatePickingToChildren: boolean;
  85559. private _image;
  85560. /**
  85561. * Returns the ToggleButton's image control if it exists
  85562. */
  85563. get image(): BABYLON.Nullable<Image>;
  85564. private _textBlock;
  85565. /**
  85566. * Returns the ToggleButton's child TextBlock control if it exists
  85567. */
  85568. get textBlock(): BABYLON.Nullable<TextBlock>;
  85569. private _group;
  85570. /** Gets or sets group name this toggle button belongs to */
  85571. get group(): string;
  85572. set group(value: string);
  85573. private _isActive;
  85574. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85575. get isActive(): boolean;
  85576. set isActive(value: boolean);
  85577. /**
  85578. * Creates a new ToggleButton
  85579. * @param name defines the control name
  85580. * @param group defines the toggle group this toggle belongs to
  85581. */
  85582. constructor(name?: string | undefined, group?: string);
  85583. protected _getTypeName(): string;
  85584. /** @hidden */
  85585. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85586. /** @hidden */
  85587. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85588. /** @hidden */
  85589. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85590. /** @hidden */
  85591. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85592. /** @hidden */
  85593. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85594. }
  85595. }
  85596. declare module BABYLON.GUI {
  85597. /** Class used to render a grid */
  85598. export class DisplayGrid extends Control {
  85599. name?: string | undefined;
  85600. private _cellWidth;
  85601. private _cellHeight;
  85602. private _minorLineTickness;
  85603. private _minorLineColor;
  85604. private _majorLineTickness;
  85605. private _majorLineColor;
  85606. private _majorLineFrequency;
  85607. private _background;
  85608. private _displayMajorLines;
  85609. private _displayMinorLines;
  85610. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85611. get displayMinorLines(): boolean;
  85612. set displayMinorLines(value: boolean);
  85613. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85614. get displayMajorLines(): boolean;
  85615. set displayMajorLines(value: boolean);
  85616. /** Gets or sets background color (Black by default) */
  85617. get background(): string;
  85618. set background(value: string);
  85619. /** Gets or sets the width of each cell (20 by default) */
  85620. get cellWidth(): number;
  85621. set cellWidth(value: number);
  85622. /** Gets or sets the height of each cell (20 by default) */
  85623. get cellHeight(): number;
  85624. set cellHeight(value: number);
  85625. /** Gets or sets the tickness of minor lines (1 by default) */
  85626. get minorLineTickness(): number;
  85627. set minorLineTickness(value: number);
  85628. /** Gets or sets the color of minor lines (DarkGray by default) */
  85629. get minorLineColor(): string;
  85630. set minorLineColor(value: string);
  85631. /** Gets or sets the tickness of major lines (2 by default) */
  85632. get majorLineTickness(): number;
  85633. set majorLineTickness(value: number);
  85634. /** Gets or sets the color of major lines (White by default) */
  85635. get majorLineColor(): string;
  85636. set majorLineColor(value: string);
  85637. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85638. get majorLineFrequency(): number;
  85639. set majorLineFrequency(value: number);
  85640. /**
  85641. * Creates a new GridDisplayRectangle
  85642. * @param name defines the control name
  85643. */
  85644. constructor(name?: string | undefined);
  85645. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85646. protected _getTypeName(): string;
  85647. }
  85648. }
  85649. declare module BABYLON.GUI {
  85650. /**
  85651. * Class used to create slider controls based on images
  85652. */
  85653. export class ImageBasedSlider extends BaseSlider {
  85654. name?: string | undefined;
  85655. private _backgroundImage;
  85656. private _thumbImage;
  85657. private _valueBarImage;
  85658. private _tempMeasure;
  85659. get displayThumb(): boolean;
  85660. set displayThumb(value: boolean);
  85661. /**
  85662. * Gets or sets the image used to render the background
  85663. */
  85664. get backgroundImage(): Image;
  85665. set backgroundImage(value: Image);
  85666. /**
  85667. * Gets or sets the image used to render the value bar
  85668. */
  85669. get valueBarImage(): Image;
  85670. set valueBarImage(value: Image);
  85671. /**
  85672. * Gets or sets the image used to render the thumb
  85673. */
  85674. get thumbImage(): Image;
  85675. set thumbImage(value: Image);
  85676. /**
  85677. * Creates a new ImageBasedSlider
  85678. * @param name defines the control name
  85679. */
  85680. constructor(name?: string | undefined);
  85681. protected _getTypeName(): string;
  85682. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85683. }
  85684. }
  85685. declare module BABYLON.GUI {
  85686. /**
  85687. * Forcing an export so that this code will execute
  85688. * @hidden
  85689. */
  85690. const name = "Statics";
  85691. }
  85692. declare module BABYLON.GUI {
  85693. /**
  85694. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85695. */
  85696. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85697. /**
  85698. * Define the instrumented AdvancedDynamicTexture.
  85699. */
  85700. texture: AdvancedDynamicTexture;
  85701. private _captureRenderTime;
  85702. private _renderTime;
  85703. private _captureLayoutTime;
  85704. private _layoutTime;
  85705. private _onBeginRenderObserver;
  85706. private _onEndRenderObserver;
  85707. private _onBeginLayoutObserver;
  85708. private _onEndLayoutObserver;
  85709. /**
  85710. * Gets the perf counter used to capture render time
  85711. */
  85712. get renderTimeCounter(): BABYLON.PerfCounter;
  85713. /**
  85714. * Gets the perf counter used to capture layout time
  85715. */
  85716. get layoutTimeCounter(): BABYLON.PerfCounter;
  85717. /**
  85718. * Enable or disable the render time capture
  85719. */
  85720. get captureRenderTime(): boolean;
  85721. set captureRenderTime(value: boolean);
  85722. /**
  85723. * Enable or disable the layout time capture
  85724. */
  85725. get captureLayoutTime(): boolean;
  85726. set captureLayoutTime(value: boolean);
  85727. /**
  85728. * Instantiates a new advanced dynamic texture instrumentation.
  85729. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85730. * @param texture Defines the AdvancedDynamicTexture to instrument
  85731. */
  85732. constructor(
  85733. /**
  85734. * Define the instrumented AdvancedDynamicTexture.
  85735. */
  85736. texture: AdvancedDynamicTexture);
  85737. /**
  85738. * Dispose and release associated resources.
  85739. */
  85740. dispose(): void;
  85741. }
  85742. }
  85743. declare module BABYLON.GUI {
  85744. /**
  85745. * Class used to load GUI via XML.
  85746. */
  85747. export class XmlLoader {
  85748. private _nodes;
  85749. private _nodeTypes;
  85750. private _isLoaded;
  85751. private _objectAttributes;
  85752. private _parentClass;
  85753. /**
  85754. * Create a new xml loader
  85755. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85756. */
  85757. constructor(parentClass?: null);
  85758. private _getChainElement;
  85759. private _getClassAttribute;
  85760. private _createGuiElement;
  85761. private _parseGrid;
  85762. private _parseElement;
  85763. private _prepareSourceElement;
  85764. private _parseElementsFromSource;
  85765. private _parseXml;
  85766. /**
  85767. * Gets if the loading has finished.
  85768. * @returns whether the loading has finished or not
  85769. */
  85770. isLoaded(): boolean;
  85771. /**
  85772. * Gets a loaded node / control by id.
  85773. * @param id the Controls id set in the xml
  85774. * @returns element of type Control
  85775. */
  85776. getNodeById(id: string): any;
  85777. /**
  85778. * Gets all loaded nodes / controls
  85779. * @returns Array of controls
  85780. */
  85781. getNodes(): any;
  85782. /**
  85783. * Initiates the xml layout loading
  85784. * @param xmlFile defines the xml layout to load
  85785. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85786. * @param callback defines the callback called on layout load.
  85787. */
  85788. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85789. }
  85790. }
  85791. declare module BABYLON.GUI {
  85792. /**
  85793. * Class used to create containers for controls
  85794. */
  85795. export class Container3D extends Control3D {
  85796. private _blockLayout;
  85797. /**
  85798. * Gets the list of child controls
  85799. */
  85800. protected _children: Control3D[];
  85801. /**
  85802. * Gets the list of child controls
  85803. */
  85804. get children(): Array<Control3D>;
  85805. /**
  85806. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85807. * This is helpful to optimize layout operation when adding multiple children in a row
  85808. */
  85809. get blockLayout(): boolean;
  85810. set blockLayout(value: boolean);
  85811. /**
  85812. * Creates a new container
  85813. * @param name defines the container name
  85814. */
  85815. constructor(name?: string);
  85816. /**
  85817. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85818. * @returns the current container
  85819. */
  85820. updateLayout(): Container3D;
  85821. /**
  85822. * Gets a boolean indicating if the given control is in the children of this control
  85823. * @param control defines the control to check
  85824. * @returns true if the control is in the child list
  85825. */
  85826. containsControl(control: Control3D): boolean;
  85827. /**
  85828. * Adds a control to the children of this control
  85829. * @param control defines the control to add
  85830. * @returns the current container
  85831. */
  85832. addControl(control: Control3D): Container3D;
  85833. /**
  85834. * This function will be called everytime a new control is added
  85835. */
  85836. protected _arrangeChildren(): void;
  85837. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85838. /**
  85839. * Removes a control from the children of this control
  85840. * @param control defines the control to remove
  85841. * @returns the current container
  85842. */
  85843. removeControl(control: Control3D): Container3D;
  85844. protected _getTypeName(): string;
  85845. /**
  85846. * Releases all associated resources
  85847. */
  85848. dispose(): void;
  85849. /** Control rotation will remain unchanged */
  85850. static readonly UNSET_ORIENTATION: number;
  85851. /** Control will rotate to make it look at sphere central axis */
  85852. static readonly FACEORIGIN_ORIENTATION: number;
  85853. /** Control will rotate to make it look back at sphere central axis */
  85854. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85855. /** Control will rotate to look at z axis (0, 0, 1) */
  85856. static readonly FACEFORWARD_ORIENTATION: number;
  85857. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85858. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85859. }
  85860. }
  85861. declare module BABYLON.GUI {
  85862. /**
  85863. * Class used to manage 3D user interface
  85864. * @see https://doc.babylonjs.com/how_to/gui3d
  85865. */
  85866. export class GUI3DManager implements BABYLON.IDisposable {
  85867. private _scene;
  85868. private _sceneDisposeObserver;
  85869. private _utilityLayer;
  85870. private _rootContainer;
  85871. private _pointerObserver;
  85872. private _pointerOutObserver;
  85873. /** @hidden */
  85874. _lastPickedControl: Control3D;
  85875. /** @hidden */
  85876. _lastControlOver: {
  85877. [pointerId: number]: Control3D;
  85878. };
  85879. /** @hidden */
  85880. _lastControlDown: {
  85881. [pointerId: number]: Control3D;
  85882. };
  85883. /**
  85884. * BABYLON.Observable raised when the point picked by the pointer events changed
  85885. */
  85886. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85887. /** @hidden */
  85888. _sharedMaterials: {
  85889. [key: string]: BABYLON.Material;
  85890. };
  85891. /** Gets the hosting scene */
  85892. get scene(): BABYLON.Scene;
  85893. /** Gets associated utility layer */
  85894. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85895. /**
  85896. * Creates a new GUI3DManager
  85897. * @param scene
  85898. */
  85899. constructor(scene?: BABYLON.Scene);
  85900. private _handlePointerOut;
  85901. private _doPicking;
  85902. /**
  85903. * Gets the root container
  85904. */
  85905. get rootContainer(): Container3D;
  85906. /**
  85907. * Gets a boolean indicating if the given control is in the root child list
  85908. * @param control defines the control to check
  85909. * @returns true if the control is in the root child list
  85910. */
  85911. containsControl(control: Control3D): boolean;
  85912. /**
  85913. * Adds a control to the root child list
  85914. * @param control defines the control to add
  85915. * @returns the current manager
  85916. */
  85917. addControl(control: Control3D): GUI3DManager;
  85918. /**
  85919. * Removes a control from the root child list
  85920. * @param control defines the control to remove
  85921. * @returns the current container
  85922. */
  85923. removeControl(control: Control3D): GUI3DManager;
  85924. /**
  85925. * Releases all associated resources
  85926. */
  85927. dispose(): void;
  85928. }
  85929. }
  85930. declare module BABYLON.GUI {
  85931. /**
  85932. * Class used to transport BABYLON.Vector3 information for pointer events
  85933. */
  85934. export class Vector3WithInfo extends BABYLON.Vector3 {
  85935. /** defines the current mouse button index */
  85936. buttonIndex: number;
  85937. /**
  85938. * Creates a new Vector3WithInfo
  85939. * @param source defines the vector3 data to transport
  85940. * @param buttonIndex defines the current mouse button index
  85941. */
  85942. constructor(source: BABYLON.Vector3,
  85943. /** defines the current mouse button index */
  85944. buttonIndex?: number);
  85945. }
  85946. }
  85947. declare module BABYLON.GUI {
  85948. /**
  85949. * Class used as base class for controls
  85950. */
  85951. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85952. /** Defines the control name */
  85953. name?: string | undefined;
  85954. /** @hidden */
  85955. _host: GUI3DManager;
  85956. private _node;
  85957. private _downCount;
  85958. private _enterCount;
  85959. private _downPointerIds;
  85960. private _isVisible;
  85961. /** Gets or sets the control position in world space */
  85962. get position(): BABYLON.Vector3;
  85963. set position(value: BABYLON.Vector3);
  85964. /** Gets or sets the control scaling in world space */
  85965. get scaling(): BABYLON.Vector3;
  85966. set scaling(value: BABYLON.Vector3);
  85967. /** Callback used to start pointer enter animation */
  85968. pointerEnterAnimation: () => void;
  85969. /** Callback used to start pointer out animation */
  85970. pointerOutAnimation: () => void;
  85971. /** Callback used to start pointer down animation */
  85972. pointerDownAnimation: () => void;
  85973. /** Callback used to start pointer up animation */
  85974. pointerUpAnimation: () => void;
  85975. /**
  85976. * An event triggered when the pointer move over the control
  85977. */
  85978. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85979. /**
  85980. * An event triggered when the pointer move out of the control
  85981. */
  85982. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85983. /**
  85984. * An event triggered when the pointer taps the control
  85985. */
  85986. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85987. /**
  85988. * An event triggered when pointer is up
  85989. */
  85990. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85991. /**
  85992. * An event triggered when a control is clicked on (with a mouse)
  85993. */
  85994. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85995. /**
  85996. * An event triggered when pointer enters the control
  85997. */
  85998. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85999. /**
  86000. * Gets or sets the parent container
  86001. */
  86002. parent: BABYLON.Nullable<Container3D>;
  86003. private _behaviors;
  86004. /**
  86005. * Gets the list of attached behaviors
  86006. * @see https://doc.babylonjs.com/features/behaviour
  86007. */
  86008. get behaviors(): BABYLON.Behavior<Control3D>[];
  86009. /**
  86010. * Attach a behavior to the control
  86011. * @see https://doc.babylonjs.com/features/behaviour
  86012. * @param behavior defines the behavior to attach
  86013. * @returns the current control
  86014. */
  86015. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86016. /**
  86017. * Remove an attached behavior
  86018. * @see https://doc.babylonjs.com/features/behaviour
  86019. * @param behavior defines the behavior to attach
  86020. * @returns the current control
  86021. */
  86022. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86023. /**
  86024. * Gets an attached behavior by name
  86025. * @param name defines the name of the behavior to look for
  86026. * @see https://doc.babylonjs.com/features/behaviour
  86027. * @returns null if behavior was not found else the requested behavior
  86028. */
  86029. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86030. /** Gets or sets a boolean indicating if the control is visible */
  86031. get isVisible(): boolean;
  86032. set isVisible(value: boolean);
  86033. /**
  86034. * Creates a new control
  86035. * @param name defines the control name
  86036. */
  86037. constructor(
  86038. /** Defines the control name */
  86039. name?: string | undefined);
  86040. /**
  86041. * Gets a string representing the class name
  86042. */
  86043. get typeName(): string;
  86044. /**
  86045. * Get the current class name of the control.
  86046. * @returns current class name
  86047. */
  86048. getClassName(): string;
  86049. protected _getTypeName(): string;
  86050. /**
  86051. * Gets the transform node used by this control
  86052. */
  86053. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86054. /**
  86055. * Gets the mesh used to render this control
  86056. */
  86057. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86058. /**
  86059. * Link the control as child of the given node
  86060. * @param node defines the node to link to. Use null to unlink the control
  86061. * @returns the current control
  86062. */
  86063. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86064. /** @hidden **/
  86065. _prepareNode(scene: BABYLON.Scene): void;
  86066. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86067. /**
  86068. * Node creation.
  86069. * Can be overriden by children
  86070. * @param scene defines the scene where the node must be attached
  86071. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86072. */
  86073. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86074. /**
  86075. * Affect a material to the given mesh
  86076. * @param mesh defines the mesh which will represent the control
  86077. */
  86078. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86079. /** @hidden */
  86080. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86081. /** @hidden */
  86082. _onPointerEnter(target: Control3D): boolean;
  86083. /** @hidden */
  86084. _onPointerOut(target: Control3D): void;
  86085. /** @hidden */
  86086. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86087. /** @hidden */
  86088. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86089. /** @hidden */
  86090. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86091. /** @hidden */
  86092. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86093. /** @hidden */
  86094. _disposeNode(): void;
  86095. /**
  86096. * Releases all associated resources
  86097. */
  86098. dispose(): void;
  86099. }
  86100. }
  86101. declare module BABYLON.GUI {
  86102. /**
  86103. * Class used as a root to all buttons
  86104. */
  86105. export class AbstractButton3D extends Control3D {
  86106. /**
  86107. * Creates a new button
  86108. * @param name defines the control name
  86109. */
  86110. constructor(name?: string);
  86111. protected _getTypeName(): string;
  86112. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86113. }
  86114. }
  86115. declare module BABYLON.GUI {
  86116. /**
  86117. * Class used to create a button in 3D
  86118. */
  86119. export class Button3D extends AbstractButton3D {
  86120. /** @hidden */
  86121. protected _currentMaterial: BABYLON.Material;
  86122. private _facadeTexture;
  86123. private _content;
  86124. private _contentResolution;
  86125. private _contentScaleRatio;
  86126. /**
  86127. * Gets or sets the texture resolution used to render content (512 by default)
  86128. */
  86129. get contentResolution(): BABYLON.int;
  86130. set contentResolution(value: BABYLON.int);
  86131. /**
  86132. * Gets or sets the texture scale ratio used to render content (2 by default)
  86133. */
  86134. get contentScaleRatio(): number;
  86135. set contentScaleRatio(value: number);
  86136. protected _disposeFacadeTexture(): void;
  86137. protected _resetContent(): void;
  86138. /**
  86139. * Creates a new button
  86140. * @param name defines the control name
  86141. */
  86142. constructor(name?: string);
  86143. /**
  86144. * Gets or sets the GUI 2D content used to display the button's facade
  86145. */
  86146. get content(): Control;
  86147. set content(value: Control);
  86148. /**
  86149. * Apply the facade texture (created from the content property).
  86150. * This function can be overloaded by child classes
  86151. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86152. */
  86153. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86154. protected _getTypeName(): string;
  86155. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86156. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86157. /**
  86158. * Releases all associated resources
  86159. */
  86160. dispose(): void;
  86161. }
  86162. }
  86163. declare module BABYLON.GUI {
  86164. /**
  86165. * Abstract class used to create a container panel deployed on the surface of a volume
  86166. */
  86167. export abstract class VolumeBasedPanel extends Container3D {
  86168. private _columns;
  86169. private _rows;
  86170. private _rowThenColum;
  86171. private _orientation;
  86172. protected _cellWidth: number;
  86173. protected _cellHeight: number;
  86174. /**
  86175. * Gets or sets the distance between elements
  86176. */
  86177. margin: number;
  86178. /**
  86179. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86180. * | Value | Type | Description |
  86181. * | ----- | ----------------------------------- | ----------- |
  86182. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86183. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86184. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86185. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86186. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86187. */
  86188. get orientation(): number;
  86189. set orientation(value: number);
  86190. /**
  86191. * Gets or sets the number of columns requested (10 by default).
  86192. * The panel will automatically compute the number of rows based on number of child controls.
  86193. */
  86194. get columns(): BABYLON.int;
  86195. set columns(value: BABYLON.int);
  86196. /**
  86197. * Gets or sets a the number of rows requested.
  86198. * The panel will automatically compute the number of columns based on number of child controls.
  86199. */
  86200. get rows(): BABYLON.int;
  86201. set rows(value: BABYLON.int);
  86202. /**
  86203. * Creates new VolumeBasedPanel
  86204. */
  86205. constructor();
  86206. protected _arrangeChildren(): void;
  86207. /** Child classes must implement this function to provide correct control positioning */
  86208. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86209. /** Child classes can implement this function to provide additional processing */
  86210. protected _finalProcessing(): void;
  86211. }
  86212. }
  86213. declare module BABYLON.GUI {
  86214. /**
  86215. * Class used to create a container panel deployed on the surface of a cylinder
  86216. */
  86217. export class CylinderPanel extends VolumeBasedPanel {
  86218. private _radius;
  86219. /**
  86220. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86221. */
  86222. get radius(): BABYLON.float;
  86223. set radius(value: BABYLON.float);
  86224. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86225. private _cylindricalMapping;
  86226. }
  86227. }
  86228. declare module BABYLON.GUI {
  86229. /** @hidden */
  86230. export var fluentVertexShader: {
  86231. name: string;
  86232. shader: string;
  86233. };
  86234. }
  86235. declare module BABYLON.GUI {
  86236. /** @hidden */
  86237. export var fluentPixelShader: {
  86238. name: string;
  86239. shader: string;
  86240. };
  86241. }
  86242. declare module BABYLON.GUI {
  86243. /** @hidden */
  86244. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86245. INNERGLOW: boolean;
  86246. BORDER: boolean;
  86247. HOVERLIGHT: boolean;
  86248. TEXTURE: boolean;
  86249. constructor();
  86250. }
  86251. /**
  86252. * Class used to render controls with fluent desgin
  86253. */
  86254. export class FluentMaterial extends BABYLON.PushMaterial {
  86255. /**
  86256. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86257. */
  86258. innerGlowColorIntensity: number;
  86259. /**
  86260. * Gets or sets the inner glow color (white by default)
  86261. */
  86262. innerGlowColor: BABYLON.Color3;
  86263. /**
  86264. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86265. */
  86266. albedoColor: BABYLON.Color3;
  86267. /**
  86268. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86269. */
  86270. renderBorders: boolean;
  86271. /**
  86272. * Gets or sets border width (default is 0.5)
  86273. */
  86274. borderWidth: number;
  86275. /**
  86276. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86277. */
  86278. edgeSmoothingValue: number;
  86279. /**
  86280. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86281. */
  86282. borderMinValue: number;
  86283. /**
  86284. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86285. */
  86286. renderHoverLight: boolean;
  86287. /**
  86288. * Gets or sets the radius used to render the hover light (default is 1.0)
  86289. */
  86290. hoverRadius: number;
  86291. /**
  86292. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86293. */
  86294. hoverColor: BABYLON.Color4;
  86295. /**
  86296. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86297. */
  86298. hoverPosition: BABYLON.Vector3;
  86299. private _albedoTexture;
  86300. /** Gets or sets the texture to use for albedo color */
  86301. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86302. /**
  86303. * Creates a new Fluent material
  86304. * @param name defines the name of the material
  86305. * @param scene defines the hosting scene
  86306. */
  86307. constructor(name: string, scene: BABYLON.Scene);
  86308. needAlphaBlending(): boolean;
  86309. needAlphaTesting(): boolean;
  86310. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86311. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86312. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86313. getActiveTextures(): BABYLON.BaseTexture[];
  86314. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86315. dispose(forceDisposeEffect?: boolean): void;
  86316. clone(name: string): FluentMaterial;
  86317. serialize(): any;
  86318. getClassName(): string;
  86319. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86320. }
  86321. }
  86322. declare module BABYLON.GUI {
  86323. /**
  86324. * Class used to create a holographic button in 3D
  86325. */
  86326. export class HolographicButton extends Button3D {
  86327. private _backPlate;
  86328. private _textPlate;
  86329. private _frontPlate;
  86330. private _text;
  86331. private _imageUrl;
  86332. private _shareMaterials;
  86333. private _frontMaterial;
  86334. private _backMaterial;
  86335. private _plateMaterial;
  86336. private _pickedPointObserver;
  86337. private _tooltipFade;
  86338. private _tooltipTextBlock;
  86339. private _tooltipTexture;
  86340. private _tooltipMesh;
  86341. private _tooltipHoverObserver;
  86342. private _tooltipOutObserver;
  86343. private _disposeTooltip;
  86344. /**
  86345. * Rendering ground id of all the mesh in the button
  86346. */
  86347. set renderingGroupId(id: number);
  86348. get renderingGroupId(): number;
  86349. /**
  86350. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86351. */
  86352. set tooltipText(text: BABYLON.Nullable<string>);
  86353. get tooltipText(): BABYLON.Nullable<string>;
  86354. /**
  86355. * Gets or sets text for the button
  86356. */
  86357. get text(): string;
  86358. set text(value: string);
  86359. /**
  86360. * Gets or sets the image url for the button
  86361. */
  86362. get imageUrl(): string;
  86363. set imageUrl(value: string);
  86364. /**
  86365. * Gets the back material used by this button
  86366. */
  86367. get backMaterial(): FluentMaterial;
  86368. /**
  86369. * Gets the front material used by this button
  86370. */
  86371. get frontMaterial(): FluentMaterial;
  86372. /**
  86373. * Gets the plate material used by this button
  86374. */
  86375. get plateMaterial(): BABYLON.StandardMaterial;
  86376. /**
  86377. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86378. */
  86379. get shareMaterials(): boolean;
  86380. /**
  86381. * Creates a new button
  86382. * @param name defines the control name
  86383. */
  86384. constructor(name?: string, shareMaterials?: boolean);
  86385. protected _getTypeName(): string;
  86386. private _rebuildContent;
  86387. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86388. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86389. private _createBackMaterial;
  86390. private _createFrontMaterial;
  86391. private _createPlateMaterial;
  86392. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86393. /**
  86394. * Releases all associated resources
  86395. */
  86396. dispose(): void;
  86397. }
  86398. }
  86399. declare module BABYLON.GUI {
  86400. /**
  86401. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86402. */
  86403. export class MeshButton3D extends Button3D {
  86404. /** @hidden */
  86405. protected _currentMesh: BABYLON.Mesh;
  86406. /**
  86407. * Creates a new 3D button based on a mesh
  86408. * @param mesh mesh to become a 3D button
  86409. * @param name defines the control name
  86410. */
  86411. constructor(mesh: BABYLON.Mesh, name?: string);
  86412. protected _getTypeName(): string;
  86413. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86414. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86415. }
  86416. }
  86417. declare module BABYLON.GUI {
  86418. /**
  86419. * Class used to create a container panel deployed on the surface of a plane
  86420. */
  86421. export class PlanePanel extends VolumeBasedPanel {
  86422. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86423. }
  86424. }
  86425. declare module BABYLON.GUI {
  86426. /**
  86427. * Class used to create a container panel where items get randomized planar mapping
  86428. */
  86429. export class ScatterPanel extends VolumeBasedPanel {
  86430. private _iteration;
  86431. /**
  86432. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86433. */
  86434. get iteration(): BABYLON.float;
  86435. set iteration(value: BABYLON.float);
  86436. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86437. private _scatterMapping;
  86438. protected _finalProcessing(): void;
  86439. }
  86440. }
  86441. declare module BABYLON.GUI {
  86442. /**
  86443. * Class used to create a container panel deployed on the surface of a sphere
  86444. */
  86445. export class SpherePanel extends VolumeBasedPanel {
  86446. private _radius;
  86447. /**
  86448. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86449. */
  86450. get radius(): BABYLON.float;
  86451. set radius(value: BABYLON.float);
  86452. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86453. private _sphericalMapping;
  86454. }
  86455. }
  86456. declare module BABYLON.GUI {
  86457. /**
  86458. * Class used to create a stack panel in 3D on XY plane
  86459. */
  86460. export class StackPanel3D extends Container3D {
  86461. private _isVertical;
  86462. /**
  86463. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86464. */
  86465. get isVertical(): boolean;
  86466. set isVertical(value: boolean);
  86467. /**
  86468. * Gets or sets the distance between elements
  86469. */
  86470. margin: number;
  86471. /**
  86472. * Creates new StackPanel
  86473. * @param isVertical
  86474. */
  86475. constructor(isVertical?: boolean);
  86476. protected _arrangeChildren(): void;
  86477. }
  86478. }
  86479. declare module BABYLON {
  86480. /**
  86481. * Configuration for glTF validation
  86482. */
  86483. export interface IGLTFValidationConfiguration {
  86484. /**
  86485. * The url of the glTF validator.
  86486. */
  86487. url: string;
  86488. }
  86489. /**
  86490. * glTF validation
  86491. */
  86492. export class GLTFValidation {
  86493. /**
  86494. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86495. */
  86496. static Configuration: IGLTFValidationConfiguration;
  86497. private static _LoadScriptPromise;
  86498. /**
  86499. * Validate a glTF asset using the glTF-Validator.
  86500. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86501. * @param rootUrl The root url for the glTF
  86502. * @param fileName The file name for the glTF
  86503. * @param getExternalResource The callback to get external resources for the glTF validator
  86504. * @returns A promise that resolves with the glTF validation results once complete
  86505. */
  86506. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86507. }
  86508. }
  86509. declare module BABYLON {
  86510. /**
  86511. * Mode that determines the coordinate system to use.
  86512. */
  86513. export enum GLTFLoaderCoordinateSystemMode {
  86514. /**
  86515. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86516. */
  86517. AUTO = 0,
  86518. /**
  86519. * Sets the useRightHandedSystem flag on the scene.
  86520. */
  86521. FORCE_RIGHT_HANDED = 1
  86522. }
  86523. /**
  86524. * Mode that determines what animations will start.
  86525. */
  86526. export enum GLTFLoaderAnimationStartMode {
  86527. /**
  86528. * No animation will start.
  86529. */
  86530. NONE = 0,
  86531. /**
  86532. * The first animation will start.
  86533. */
  86534. FIRST = 1,
  86535. /**
  86536. * All animations will start.
  86537. */
  86538. ALL = 2
  86539. }
  86540. /**
  86541. * Interface that contains the data for the glTF asset.
  86542. */
  86543. export interface IGLTFLoaderData {
  86544. /**
  86545. * The object that represents the glTF JSON.
  86546. */
  86547. json: Object;
  86548. /**
  86549. * The BIN chunk of a binary glTF.
  86550. */
  86551. bin: Nullable<IDataBuffer>;
  86552. }
  86553. /**
  86554. * Interface for extending the loader.
  86555. */
  86556. export interface IGLTFLoaderExtension {
  86557. /**
  86558. * The name of this extension.
  86559. */
  86560. readonly name: string;
  86561. /**
  86562. * Defines whether this extension is enabled.
  86563. */
  86564. enabled: boolean;
  86565. /**
  86566. * Defines the order of this extension.
  86567. * The loader sorts the extensions using these values when loading.
  86568. */
  86569. order?: number;
  86570. }
  86571. /**
  86572. * Loader state.
  86573. */
  86574. export enum GLTFLoaderState {
  86575. /**
  86576. * The asset is loading.
  86577. */
  86578. LOADING = 0,
  86579. /**
  86580. * The asset is ready for rendering.
  86581. */
  86582. READY = 1,
  86583. /**
  86584. * The asset is completely loaded.
  86585. */
  86586. COMPLETE = 2
  86587. }
  86588. /** @hidden */
  86589. export interface IGLTFLoader extends IDisposable {
  86590. readonly state: Nullable<GLTFLoaderState>;
  86591. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86592. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86593. }
  86594. /**
  86595. * File loader for loading glTF files into a scene.
  86596. */
  86597. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86598. /** @hidden */
  86599. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86600. /** @hidden */
  86601. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86602. /**
  86603. * Raised when the asset has been parsed
  86604. */
  86605. onParsedObservable: Observable<IGLTFLoaderData>;
  86606. private _onParsedObserver;
  86607. /**
  86608. * Raised when the asset has been parsed
  86609. */
  86610. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86611. /**
  86612. * 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.
  86613. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86614. * Defaults to true.
  86615. * @hidden
  86616. */
  86617. static IncrementalLoading: boolean;
  86618. /**
  86619. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86620. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86621. * @hidden
  86622. */
  86623. static HomogeneousCoordinates: boolean;
  86624. /**
  86625. * The coordinate system mode. Defaults to AUTO.
  86626. */
  86627. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86628. /**
  86629. * The animation start mode. Defaults to FIRST.
  86630. */
  86631. animationStartMode: GLTFLoaderAnimationStartMode;
  86632. /**
  86633. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86634. */
  86635. compileMaterials: boolean;
  86636. /**
  86637. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86638. */
  86639. useClipPlane: boolean;
  86640. /**
  86641. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86642. */
  86643. compileShadowGenerators: boolean;
  86644. /**
  86645. * Defines if the Alpha blended materials are only applied as coverage.
  86646. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86647. * If true, no extra effects are applied to transparent pixels.
  86648. */
  86649. transparencyAsCoverage: boolean;
  86650. /**
  86651. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86652. * Enabling will disable offline support and glTF validator.
  86653. * Defaults to false.
  86654. */
  86655. useRangeRequests: boolean;
  86656. /**
  86657. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86658. */
  86659. createInstances: boolean;
  86660. /**
  86661. * 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.
  86662. */
  86663. alwaysComputeBoundingBox: boolean;
  86664. /**
  86665. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86666. */
  86667. loadAllMaterials: boolean;
  86668. /**
  86669. * Function called before loading a url referenced by the asset.
  86670. */
  86671. preprocessUrlAsync: (url: string) => Promise<string>;
  86672. /**
  86673. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86674. * 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, ...)
  86675. */
  86676. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86677. private _onMeshLoadedObserver;
  86678. /**
  86679. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86680. * 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, ...)
  86681. */
  86682. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86683. /**
  86684. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86685. */
  86686. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86687. private _onTextureLoadedObserver;
  86688. /**
  86689. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86690. */
  86691. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86692. /**
  86693. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86694. */
  86695. readonly onMaterialLoadedObservable: Observable<Material>;
  86696. private _onMaterialLoadedObserver;
  86697. /**
  86698. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86699. */
  86700. set onMaterialLoaded(callback: (material: Material) => void);
  86701. /**
  86702. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86703. */
  86704. readonly onCameraLoadedObservable: Observable<Camera>;
  86705. private _onCameraLoadedObserver;
  86706. /**
  86707. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86708. */
  86709. set onCameraLoaded(callback: (camera: Camera) => void);
  86710. /**
  86711. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86712. * For assets with LODs, raised when all of the LODs are complete.
  86713. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86714. */
  86715. readonly onCompleteObservable: Observable<void>;
  86716. private _onCompleteObserver;
  86717. /**
  86718. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86719. * For assets with LODs, raised when all of the LODs are complete.
  86720. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86721. */
  86722. set onComplete(callback: () => void);
  86723. /**
  86724. * Observable raised when an error occurs.
  86725. */
  86726. readonly onErrorObservable: Observable<any>;
  86727. private _onErrorObserver;
  86728. /**
  86729. * Callback raised when an error occurs.
  86730. */
  86731. set onError(callback: (reason: any) => void);
  86732. /**
  86733. * Observable raised after the loader is disposed.
  86734. */
  86735. readonly onDisposeObservable: Observable<void>;
  86736. private _onDisposeObserver;
  86737. /**
  86738. * Callback raised after the loader is disposed.
  86739. */
  86740. set onDispose(callback: () => void);
  86741. /**
  86742. * Observable raised after a loader extension is created.
  86743. * Set additional options for a loader extension in this event.
  86744. */
  86745. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86746. private _onExtensionLoadedObserver;
  86747. /**
  86748. * Callback raised after a loader extension is created.
  86749. */
  86750. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86751. /**
  86752. * Defines if the loader logging is enabled.
  86753. */
  86754. get loggingEnabled(): boolean;
  86755. set loggingEnabled(value: boolean);
  86756. /**
  86757. * Defines if the loader should capture performance counters.
  86758. */
  86759. get capturePerformanceCounters(): boolean;
  86760. set capturePerformanceCounters(value: boolean);
  86761. /**
  86762. * Defines if the loader should validate the asset.
  86763. */
  86764. validate: boolean;
  86765. /**
  86766. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86767. */
  86768. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86769. private _onValidatedObserver;
  86770. /**
  86771. * Callback raised after a loader extension is created.
  86772. */
  86773. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86774. private _loader;
  86775. private _progressCallback?;
  86776. private _requests;
  86777. private static magicBase64Encoded;
  86778. /**
  86779. * Name of the loader ("gltf")
  86780. */
  86781. name: string;
  86782. /** @hidden */
  86783. extensions: ISceneLoaderPluginExtensions;
  86784. /**
  86785. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86786. */
  86787. dispose(): void;
  86788. /** @hidden */
  86789. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86790. /** @hidden */
  86791. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86792. /** @hidden */
  86793. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86794. /** @hidden */
  86795. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86796. /** @hidden */
  86797. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86798. /** @hidden */
  86799. canDirectLoad(data: string): boolean;
  86800. /** @hidden */
  86801. directLoad(scene: Scene, data: string): Promise<any>;
  86802. /**
  86803. * The callback that allows custom handling of the root url based on the response url.
  86804. * @param rootUrl the original root url
  86805. * @param responseURL the response url if available
  86806. * @returns the new root url
  86807. */
  86808. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86809. /** @hidden */
  86810. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86811. /**
  86812. * The loader state or null if the loader is not active.
  86813. */
  86814. get loaderState(): Nullable<GLTFLoaderState>;
  86815. /**
  86816. * Returns a promise that resolves when the asset is completely loaded.
  86817. * @returns a promise that resolves when the asset is completely loaded.
  86818. */
  86819. whenCompleteAsync(): Promise<void>;
  86820. /** @hidden */
  86821. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86822. /** @hidden */
  86823. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86824. private _onProgress;
  86825. private _validate;
  86826. private _getLoader;
  86827. private _parseJson;
  86828. private _unpackBinaryAsync;
  86829. private _unpackBinaryV1Async;
  86830. private _unpackBinaryV2Async;
  86831. private static _parseVersion;
  86832. private static _compareVersion;
  86833. private static readonly _logSpaces;
  86834. private _logIndentLevel;
  86835. private _loggingEnabled;
  86836. /** @hidden */
  86837. _log: (message: string) => void;
  86838. /** @hidden */
  86839. _logOpen(message: string): void;
  86840. /** @hidden */
  86841. _logClose(): void;
  86842. private _logEnabled;
  86843. private _logDisabled;
  86844. private _capturePerformanceCounters;
  86845. /** @hidden */
  86846. _startPerformanceCounter: (counterName: string) => void;
  86847. /** @hidden */
  86848. _endPerformanceCounter: (counterName: string) => void;
  86849. private _startPerformanceCounterEnabled;
  86850. private _startPerformanceCounterDisabled;
  86851. private _endPerformanceCounterEnabled;
  86852. private _endPerformanceCounterDisabled;
  86853. }
  86854. }
  86855. declare module BABYLON.GLTF1 {
  86856. /**
  86857. * Enums
  86858. * @hidden
  86859. */
  86860. export enum EComponentType {
  86861. BYTE = 5120,
  86862. UNSIGNED_BYTE = 5121,
  86863. SHORT = 5122,
  86864. UNSIGNED_SHORT = 5123,
  86865. FLOAT = 5126
  86866. }
  86867. /** @hidden */
  86868. export enum EShaderType {
  86869. FRAGMENT = 35632,
  86870. VERTEX = 35633
  86871. }
  86872. /** @hidden */
  86873. export enum EParameterType {
  86874. BYTE = 5120,
  86875. UNSIGNED_BYTE = 5121,
  86876. SHORT = 5122,
  86877. UNSIGNED_SHORT = 5123,
  86878. INT = 5124,
  86879. UNSIGNED_INT = 5125,
  86880. FLOAT = 5126,
  86881. FLOAT_VEC2 = 35664,
  86882. FLOAT_VEC3 = 35665,
  86883. FLOAT_VEC4 = 35666,
  86884. INT_VEC2 = 35667,
  86885. INT_VEC3 = 35668,
  86886. INT_VEC4 = 35669,
  86887. BOOL = 35670,
  86888. BOOL_VEC2 = 35671,
  86889. BOOL_VEC3 = 35672,
  86890. BOOL_VEC4 = 35673,
  86891. FLOAT_MAT2 = 35674,
  86892. FLOAT_MAT3 = 35675,
  86893. FLOAT_MAT4 = 35676,
  86894. SAMPLER_2D = 35678
  86895. }
  86896. /** @hidden */
  86897. export enum ETextureWrapMode {
  86898. CLAMP_TO_EDGE = 33071,
  86899. MIRRORED_REPEAT = 33648,
  86900. REPEAT = 10497
  86901. }
  86902. /** @hidden */
  86903. export enum ETextureFilterType {
  86904. NEAREST = 9728,
  86905. LINEAR = 9728,
  86906. NEAREST_MIPMAP_NEAREST = 9984,
  86907. LINEAR_MIPMAP_NEAREST = 9985,
  86908. NEAREST_MIPMAP_LINEAR = 9986,
  86909. LINEAR_MIPMAP_LINEAR = 9987
  86910. }
  86911. /** @hidden */
  86912. export enum ETextureFormat {
  86913. ALPHA = 6406,
  86914. RGB = 6407,
  86915. RGBA = 6408,
  86916. LUMINANCE = 6409,
  86917. LUMINANCE_ALPHA = 6410
  86918. }
  86919. /** @hidden */
  86920. export enum ECullingType {
  86921. FRONT = 1028,
  86922. BACK = 1029,
  86923. FRONT_AND_BACK = 1032
  86924. }
  86925. /** @hidden */
  86926. export enum EBlendingFunction {
  86927. ZERO = 0,
  86928. ONE = 1,
  86929. SRC_COLOR = 768,
  86930. ONE_MINUS_SRC_COLOR = 769,
  86931. DST_COLOR = 774,
  86932. ONE_MINUS_DST_COLOR = 775,
  86933. SRC_ALPHA = 770,
  86934. ONE_MINUS_SRC_ALPHA = 771,
  86935. DST_ALPHA = 772,
  86936. ONE_MINUS_DST_ALPHA = 773,
  86937. CONSTANT_COLOR = 32769,
  86938. ONE_MINUS_CONSTANT_COLOR = 32770,
  86939. CONSTANT_ALPHA = 32771,
  86940. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86941. SRC_ALPHA_SATURATE = 776
  86942. }
  86943. /** @hidden */
  86944. export interface IGLTFProperty {
  86945. extensions?: {
  86946. [key: string]: any;
  86947. };
  86948. extras?: Object;
  86949. }
  86950. /** @hidden */
  86951. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86952. name?: string;
  86953. }
  86954. /** @hidden */
  86955. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86956. bufferView: string;
  86957. byteOffset: number;
  86958. byteStride: number;
  86959. count: number;
  86960. type: string;
  86961. componentType: EComponentType;
  86962. max?: number[];
  86963. min?: number[];
  86964. name?: string;
  86965. }
  86966. /** @hidden */
  86967. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86968. buffer: string;
  86969. byteOffset: number;
  86970. byteLength: number;
  86971. byteStride: number;
  86972. target?: number;
  86973. }
  86974. /** @hidden */
  86975. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86976. uri: string;
  86977. byteLength?: number;
  86978. type?: string;
  86979. }
  86980. /** @hidden */
  86981. export interface IGLTFShader extends IGLTFChildRootProperty {
  86982. uri: string;
  86983. type: EShaderType;
  86984. }
  86985. /** @hidden */
  86986. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86987. attributes: string[];
  86988. fragmentShader: string;
  86989. vertexShader: string;
  86990. }
  86991. /** @hidden */
  86992. export interface IGLTFTechniqueParameter {
  86993. type: number;
  86994. count?: number;
  86995. semantic?: string;
  86996. node?: string;
  86997. value?: number | boolean | string | Array<any>;
  86998. source?: string;
  86999. babylonValue?: any;
  87000. }
  87001. /** @hidden */
  87002. export interface IGLTFTechniqueCommonProfile {
  87003. lightingModel: string;
  87004. texcoordBindings: Object;
  87005. parameters?: Array<any>;
  87006. }
  87007. /** @hidden */
  87008. export interface IGLTFTechniqueStatesFunctions {
  87009. blendColor?: number[];
  87010. blendEquationSeparate?: number[];
  87011. blendFuncSeparate?: number[];
  87012. colorMask: boolean[];
  87013. cullFace: number[];
  87014. }
  87015. /** @hidden */
  87016. export interface IGLTFTechniqueStates {
  87017. enable: number[];
  87018. functions: IGLTFTechniqueStatesFunctions;
  87019. }
  87020. /** @hidden */
  87021. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87022. parameters: {
  87023. [key: string]: IGLTFTechniqueParameter;
  87024. };
  87025. program: string;
  87026. attributes: {
  87027. [key: string]: string;
  87028. };
  87029. uniforms: {
  87030. [key: string]: string;
  87031. };
  87032. states: IGLTFTechniqueStates;
  87033. }
  87034. /** @hidden */
  87035. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87036. technique?: string;
  87037. values: string[];
  87038. }
  87039. /** @hidden */
  87040. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87041. attributes: {
  87042. [key: string]: string;
  87043. };
  87044. indices: string;
  87045. material: string;
  87046. mode?: number;
  87047. }
  87048. /** @hidden */
  87049. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87050. primitives: IGLTFMeshPrimitive[];
  87051. }
  87052. /** @hidden */
  87053. export interface IGLTFImage extends IGLTFChildRootProperty {
  87054. uri: string;
  87055. }
  87056. /** @hidden */
  87057. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87058. magFilter?: number;
  87059. minFilter?: number;
  87060. wrapS?: number;
  87061. wrapT?: number;
  87062. }
  87063. /** @hidden */
  87064. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87065. sampler: string;
  87066. source: string;
  87067. format?: ETextureFormat;
  87068. internalFormat?: ETextureFormat;
  87069. target?: number;
  87070. type?: number;
  87071. babylonTexture?: Texture;
  87072. }
  87073. /** @hidden */
  87074. export interface IGLTFAmbienLight {
  87075. color?: number[];
  87076. }
  87077. /** @hidden */
  87078. export interface IGLTFDirectionalLight {
  87079. color?: number[];
  87080. }
  87081. /** @hidden */
  87082. export interface IGLTFPointLight {
  87083. color?: number[];
  87084. constantAttenuation?: number;
  87085. linearAttenuation?: number;
  87086. quadraticAttenuation?: number;
  87087. }
  87088. /** @hidden */
  87089. export interface IGLTFSpotLight {
  87090. color?: number[];
  87091. constantAttenuation?: number;
  87092. fallOfAngle?: number;
  87093. fallOffExponent?: number;
  87094. linearAttenuation?: number;
  87095. quadraticAttenuation?: number;
  87096. }
  87097. /** @hidden */
  87098. export interface IGLTFLight extends IGLTFChildRootProperty {
  87099. type: string;
  87100. }
  87101. /** @hidden */
  87102. export interface IGLTFCameraOrthographic {
  87103. xmag: number;
  87104. ymag: number;
  87105. zfar: number;
  87106. znear: number;
  87107. }
  87108. /** @hidden */
  87109. export interface IGLTFCameraPerspective {
  87110. aspectRatio: number;
  87111. yfov: number;
  87112. zfar: number;
  87113. znear: number;
  87114. }
  87115. /** @hidden */
  87116. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87117. type: string;
  87118. }
  87119. /** @hidden */
  87120. export interface IGLTFAnimationChannelTarget {
  87121. id: string;
  87122. path: string;
  87123. }
  87124. /** @hidden */
  87125. export interface IGLTFAnimationChannel {
  87126. sampler: string;
  87127. target: IGLTFAnimationChannelTarget;
  87128. }
  87129. /** @hidden */
  87130. export interface IGLTFAnimationSampler {
  87131. input: string;
  87132. output: string;
  87133. interpolation?: string;
  87134. }
  87135. /** @hidden */
  87136. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87137. channels?: IGLTFAnimationChannel[];
  87138. parameters?: {
  87139. [key: string]: string;
  87140. };
  87141. samplers?: {
  87142. [key: string]: IGLTFAnimationSampler;
  87143. };
  87144. }
  87145. /** @hidden */
  87146. export interface IGLTFNodeInstanceSkin {
  87147. skeletons: string[];
  87148. skin: string;
  87149. meshes: string[];
  87150. }
  87151. /** @hidden */
  87152. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87153. bindShapeMatrix: number[];
  87154. inverseBindMatrices: string;
  87155. jointNames: string[];
  87156. babylonSkeleton?: Skeleton;
  87157. }
  87158. /** @hidden */
  87159. export interface IGLTFNode extends IGLTFChildRootProperty {
  87160. camera?: string;
  87161. children: string[];
  87162. skin?: string;
  87163. jointName?: string;
  87164. light?: string;
  87165. matrix: number[];
  87166. mesh?: string;
  87167. meshes?: string[];
  87168. rotation?: number[];
  87169. scale?: number[];
  87170. translation?: number[];
  87171. babylonNode?: Node;
  87172. }
  87173. /** @hidden */
  87174. export interface IGLTFScene extends IGLTFChildRootProperty {
  87175. nodes: string[];
  87176. }
  87177. /** @hidden */
  87178. export interface IGLTFRuntime {
  87179. extensions: {
  87180. [key: string]: any;
  87181. };
  87182. accessors: {
  87183. [key: string]: IGLTFAccessor;
  87184. };
  87185. buffers: {
  87186. [key: string]: IGLTFBuffer;
  87187. };
  87188. bufferViews: {
  87189. [key: string]: IGLTFBufferView;
  87190. };
  87191. meshes: {
  87192. [key: string]: IGLTFMesh;
  87193. };
  87194. lights: {
  87195. [key: string]: IGLTFLight;
  87196. };
  87197. cameras: {
  87198. [key: string]: IGLTFCamera;
  87199. };
  87200. nodes: {
  87201. [key: string]: IGLTFNode;
  87202. };
  87203. images: {
  87204. [key: string]: IGLTFImage;
  87205. };
  87206. textures: {
  87207. [key: string]: IGLTFTexture;
  87208. };
  87209. shaders: {
  87210. [key: string]: IGLTFShader;
  87211. };
  87212. programs: {
  87213. [key: string]: IGLTFProgram;
  87214. };
  87215. samplers: {
  87216. [key: string]: IGLTFSampler;
  87217. };
  87218. techniques: {
  87219. [key: string]: IGLTFTechnique;
  87220. };
  87221. materials: {
  87222. [key: string]: IGLTFMaterial;
  87223. };
  87224. animations: {
  87225. [key: string]: IGLTFAnimation;
  87226. };
  87227. skins: {
  87228. [key: string]: IGLTFSkins;
  87229. };
  87230. currentScene?: Object;
  87231. scenes: {
  87232. [key: string]: IGLTFScene;
  87233. };
  87234. extensionsUsed: string[];
  87235. extensionsRequired?: string[];
  87236. buffersCount: number;
  87237. shaderscount: number;
  87238. scene: Scene;
  87239. rootUrl: string;
  87240. loadedBufferCount: number;
  87241. loadedBufferViews: {
  87242. [name: string]: ArrayBufferView;
  87243. };
  87244. loadedShaderCount: number;
  87245. importOnlyMeshes: boolean;
  87246. importMeshesNames?: string[];
  87247. dummyNodes: Node[];
  87248. forAssetContainer: boolean;
  87249. }
  87250. /** @hidden */
  87251. export interface INodeToRoot {
  87252. bone: Bone;
  87253. node: IGLTFNode;
  87254. id: string;
  87255. }
  87256. /** @hidden */
  87257. export interface IJointNode {
  87258. node: IGLTFNode;
  87259. id: string;
  87260. }
  87261. }
  87262. declare module BABYLON.GLTF1 {
  87263. /**
  87264. * Utils functions for GLTF
  87265. * @hidden
  87266. */
  87267. export class GLTFUtils {
  87268. /**
  87269. * Sets the given "parameter" matrix
  87270. * @param scene: the Scene object
  87271. * @param source: the source node where to pick the matrix
  87272. * @param parameter: the GLTF technique parameter
  87273. * @param uniformName: the name of the shader's uniform
  87274. * @param shaderMaterial: the shader material
  87275. */
  87276. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87277. /**
  87278. * Sets the given "parameter" matrix
  87279. * @param shaderMaterial: the shader material
  87280. * @param uniform: the name of the shader's uniform
  87281. * @param value: the value of the uniform
  87282. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87283. */
  87284. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87285. /**
  87286. * Returns the wrap mode of the texture
  87287. * @param mode: the mode value
  87288. */
  87289. static GetWrapMode(mode: number): number;
  87290. /**
  87291. * Returns the byte stride giving an accessor
  87292. * @param accessor: the GLTF accessor objet
  87293. */
  87294. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87295. /**
  87296. * Returns the texture filter mode giving a mode value
  87297. * @param mode: the filter mode value
  87298. */
  87299. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87300. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87301. /**
  87302. * Returns a buffer from its accessor
  87303. * @param gltfRuntime: the GLTF runtime
  87304. * @param accessor: the GLTF accessor
  87305. */
  87306. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87307. /**
  87308. * Decodes a buffer view into a string
  87309. * @param view: the buffer view
  87310. */
  87311. static DecodeBufferToText(view: ArrayBufferView): string;
  87312. /**
  87313. * Returns the default material of gltf. Related to
  87314. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87315. * @param scene: the Babylon.js scene
  87316. */
  87317. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87318. private static _DefaultMaterial;
  87319. }
  87320. }
  87321. declare module BABYLON.GLTF1 {
  87322. /**
  87323. * Implementation of the base glTF spec
  87324. * @hidden
  87325. */
  87326. export class GLTFLoaderBase {
  87327. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87328. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87329. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87330. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87331. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87332. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87333. }
  87334. /**
  87335. * glTF V1 Loader
  87336. * @hidden
  87337. */
  87338. export class GLTFLoader implements IGLTFLoader {
  87339. static Extensions: {
  87340. [name: string]: GLTFLoaderExtension;
  87341. };
  87342. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87343. state: Nullable<GLTFLoaderState>;
  87344. dispose(): void;
  87345. private _importMeshAsync;
  87346. /**
  87347. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87348. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87349. * @param scene the scene the meshes should be added to
  87350. * @param forAssetContainer defines if the entities must be stored in the scene
  87351. * @param data gltf data containing information of the meshes in a loaded file
  87352. * @param rootUrl root url to load from
  87353. * @param onProgress event that fires when loading progress has occured
  87354. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87355. */
  87356. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87357. private _loadAsync;
  87358. /**
  87359. * Imports all objects from a loaded gltf file and adds them to the scene
  87360. * @param scene the scene the objects should be added to
  87361. * @param data gltf data containing information of the meshes in a loaded file
  87362. * @param rootUrl root url to load from
  87363. * @param onProgress event that fires when loading progress has occured
  87364. * @returns a promise which completes when objects have been loaded to the scene
  87365. */
  87366. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87367. private _loadShadersAsync;
  87368. private _loadBuffersAsync;
  87369. private _createNodes;
  87370. }
  87371. /** @hidden */
  87372. export abstract class GLTFLoaderExtension {
  87373. private _name;
  87374. constructor(name: string);
  87375. get name(): string;
  87376. /**
  87377. * Defines an override for loading the runtime
  87378. * Return true to stop further extensions from loading the runtime
  87379. */
  87380. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87381. /**
  87382. * Defines an onverride for creating gltf runtime
  87383. * Return true to stop further extensions from creating the runtime
  87384. */
  87385. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87386. /**
  87387. * Defines an override for loading buffers
  87388. * Return true to stop further extensions from loading this buffer
  87389. */
  87390. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87391. /**
  87392. * Defines an override for loading texture buffers
  87393. * Return true to stop further extensions from loading this texture data
  87394. */
  87395. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87396. /**
  87397. * Defines an override for creating textures
  87398. * Return true to stop further extensions from loading this texture
  87399. */
  87400. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87401. /**
  87402. * Defines an override for loading shader strings
  87403. * Return true to stop further extensions from loading this shader data
  87404. */
  87405. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87406. /**
  87407. * Defines an override for loading materials
  87408. * Return true to stop further extensions from loading this material
  87409. */
  87410. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87411. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87412. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87413. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87414. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87415. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87416. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87417. private static LoadTextureBufferAsync;
  87418. private static CreateTextureAsync;
  87419. private static ApplyExtensions;
  87420. }
  87421. }
  87422. declare module BABYLON.GLTF1 {
  87423. /** @hidden */
  87424. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87425. private _bin;
  87426. constructor();
  87427. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87428. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87429. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87430. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87431. }
  87432. }
  87433. declare module BABYLON.GLTF1 {
  87434. /** @hidden */
  87435. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87436. constructor();
  87437. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87438. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87439. private _loadTexture;
  87440. }
  87441. }
  87442. declare module BABYLON.GLTF2.Loader {
  87443. /**
  87444. * Loader interface with an index field.
  87445. */
  87446. export interface IArrayItem {
  87447. /**
  87448. * The index of this item in the array.
  87449. */
  87450. index: number;
  87451. }
  87452. /**
  87453. * Loader interface with additional members.
  87454. */
  87455. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87456. /** @hidden */
  87457. _data?: Promise<ArrayBufferView>;
  87458. /** @hidden */
  87459. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87460. }
  87461. /**
  87462. * Loader interface with additional members.
  87463. */
  87464. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87465. }
  87466. /** @hidden */
  87467. export interface _IAnimationSamplerData {
  87468. input: Float32Array;
  87469. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87470. output: Float32Array;
  87471. }
  87472. /**
  87473. * Loader interface with additional members.
  87474. */
  87475. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87476. /** @hidden */
  87477. _data?: Promise<_IAnimationSamplerData>;
  87478. }
  87479. /**
  87480. * Loader interface with additional members.
  87481. */
  87482. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87483. channels: IAnimationChannel[];
  87484. samplers: IAnimationSampler[];
  87485. /** @hidden */
  87486. _babylonAnimationGroup?: AnimationGroup;
  87487. }
  87488. /**
  87489. * Loader interface with additional members.
  87490. */
  87491. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87492. /** @hidden */
  87493. _data?: Promise<ArrayBufferView>;
  87494. }
  87495. /**
  87496. * Loader interface with additional members.
  87497. */
  87498. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87499. /** @hidden */
  87500. _data?: Promise<ArrayBufferView>;
  87501. /** @hidden */
  87502. _babylonBuffer?: Promise<Buffer>;
  87503. }
  87504. /**
  87505. * Loader interface with additional members.
  87506. */
  87507. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87508. }
  87509. /**
  87510. * Loader interface with additional members.
  87511. */
  87512. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87513. /** @hidden */
  87514. _data?: Promise<ArrayBufferView>;
  87515. }
  87516. /**
  87517. * Loader interface with additional members.
  87518. */
  87519. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87520. }
  87521. /**
  87522. * Loader interface with additional members.
  87523. */
  87524. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87525. }
  87526. /**
  87527. * Loader interface with additional members.
  87528. */
  87529. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87530. baseColorTexture?: ITextureInfo;
  87531. metallicRoughnessTexture?: ITextureInfo;
  87532. }
  87533. /**
  87534. * Loader interface with additional members.
  87535. */
  87536. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87537. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87538. normalTexture?: IMaterialNormalTextureInfo;
  87539. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87540. emissiveTexture?: ITextureInfo;
  87541. /** @hidden */
  87542. _data?: {
  87543. [babylonDrawMode: number]: {
  87544. babylonMaterial: Material;
  87545. babylonMeshes: AbstractMesh[];
  87546. promise: Promise<void>;
  87547. };
  87548. };
  87549. }
  87550. /**
  87551. * Loader interface with additional members.
  87552. */
  87553. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87554. primitives: IMeshPrimitive[];
  87555. }
  87556. /**
  87557. * Loader interface with additional members.
  87558. */
  87559. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87560. /** @hidden */
  87561. _instanceData?: {
  87562. babylonSourceMesh: Mesh;
  87563. promise: Promise<any>;
  87564. };
  87565. }
  87566. /**
  87567. * Loader interface with additional members.
  87568. */
  87569. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87570. /**
  87571. * The parent glTF node.
  87572. */
  87573. parent?: INode;
  87574. /** @hidden */
  87575. _babylonTransformNode?: TransformNode;
  87576. /** @hidden */
  87577. _primitiveBabylonMeshes?: AbstractMesh[];
  87578. /** @hidden */
  87579. _babylonBones?: Bone[];
  87580. /** @hidden */
  87581. _numMorphTargets?: number;
  87582. }
  87583. /** @hidden */
  87584. export interface _ISamplerData {
  87585. noMipMaps: boolean;
  87586. samplingMode: number;
  87587. wrapU: number;
  87588. wrapV: number;
  87589. }
  87590. /**
  87591. * Loader interface with additional members.
  87592. */
  87593. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87594. /** @hidden */
  87595. _data?: _ISamplerData;
  87596. }
  87597. /**
  87598. * Loader interface with additional members.
  87599. */
  87600. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87601. }
  87602. /**
  87603. * Loader interface with additional members.
  87604. */
  87605. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87606. /** @hidden */
  87607. _data?: {
  87608. babylonSkeleton: Skeleton;
  87609. promise: Promise<void>;
  87610. };
  87611. }
  87612. /**
  87613. * Loader interface with additional members.
  87614. */
  87615. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87616. /** @hidden */
  87617. _textureInfo: ITextureInfo;
  87618. }
  87619. /**
  87620. * Loader interface with additional members.
  87621. */
  87622. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87623. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87624. nonColorData?: boolean;
  87625. }
  87626. /**
  87627. * Loader interface with additional members.
  87628. */
  87629. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87630. accessors?: IAccessor[];
  87631. animations?: IAnimation[];
  87632. buffers?: IBuffer[];
  87633. bufferViews?: IBufferView[];
  87634. cameras?: ICamera[];
  87635. images?: IImage[];
  87636. materials?: IMaterial[];
  87637. meshes?: IMesh[];
  87638. nodes?: INode[];
  87639. samplers?: ISampler[];
  87640. scenes?: IScene[];
  87641. skins?: ISkin[];
  87642. textures?: ITexture[];
  87643. }
  87644. }
  87645. declare module BABYLON.GLTF2 {
  87646. /**
  87647. * Interface for a glTF loader extension.
  87648. */
  87649. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87650. /**
  87651. * Called after the loader state changes to LOADING.
  87652. */
  87653. onLoading?(): void;
  87654. /**
  87655. * Called after the loader state changes to READY.
  87656. */
  87657. onReady?(): void;
  87658. /**
  87659. * Define this method to modify the default behavior when loading scenes.
  87660. * @param context The context when loading the asset
  87661. * @param scene The glTF scene property
  87662. * @returns A promise that resolves when the load is complete or null if not handled
  87663. */
  87664. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87665. /**
  87666. * Define this method to modify the default behavior when loading nodes.
  87667. * @param context The context when loading the asset
  87668. * @param node The glTF node property
  87669. * @param assign A function called synchronously after parsing the glTF properties
  87670. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87671. */
  87672. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87673. /**
  87674. * Define this method to modify the default behavior when loading cameras.
  87675. * @param context The context when loading the asset
  87676. * @param camera The glTF camera property
  87677. * @param assign A function called synchronously after parsing the glTF properties
  87678. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87679. */
  87680. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87681. /**
  87682. * @hidden
  87683. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87684. * @param context The context when loading the asset
  87685. * @param primitive The glTF mesh primitive property
  87686. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87687. */
  87688. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87689. /**
  87690. * @hidden
  87691. * Define this method to modify the default behavior when loading data for mesh primitives.
  87692. * @param context The context when loading the asset
  87693. * @param name The mesh name when loading the asset
  87694. * @param node The glTF node when loading the asset
  87695. * @param mesh The glTF mesh when loading the asset
  87696. * @param primitive The glTF mesh primitive property
  87697. * @param assign A function called synchronously after parsing the glTF properties
  87698. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87699. */
  87700. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87701. /**
  87702. * @hidden
  87703. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87704. * @param context The context when loading the asset
  87705. * @param material The glTF material property
  87706. * @param assign A function called synchronously after parsing the glTF properties
  87707. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87708. */
  87709. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87710. /**
  87711. * Define this method to modify the default behavior when creating materials.
  87712. * @param context The context when loading the asset
  87713. * @param material The glTF material property
  87714. * @param babylonDrawMode The draw mode for the Babylon material
  87715. * @returns The Babylon material or null if not handled
  87716. */
  87717. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87718. /**
  87719. * Define this method to modify the default behavior when loading material properties.
  87720. * @param context The context when loading the asset
  87721. * @param material The glTF material property
  87722. * @param babylonMaterial The Babylon material
  87723. * @returns A promise that resolves when the load is complete or null if not handled
  87724. */
  87725. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87726. /**
  87727. * Define this method to modify the default behavior when loading texture infos.
  87728. * @param context The context when loading the asset
  87729. * @param textureInfo The glTF texture info property
  87730. * @param assign A function called synchronously after parsing the glTF properties
  87731. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87732. */
  87733. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87734. /**
  87735. * @hidden
  87736. * Define this method to modify the default behavior when loading textures.
  87737. * @param context The context when loading the asset
  87738. * @param texture The glTF texture property
  87739. * @param assign A function called synchronously after parsing the glTF properties
  87740. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87741. */
  87742. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87743. /**
  87744. * Define this method to modify the default behavior when loading animations.
  87745. * @param context The context when loading the asset
  87746. * @param animation The glTF animation property
  87747. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87748. */
  87749. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87750. /**
  87751. * @hidden
  87752. * Define this method to modify the default behavior when loading skins.
  87753. * @param context The context when loading the asset
  87754. * @param node The glTF node property
  87755. * @param skin The glTF skin property
  87756. * @returns A promise that resolves when the load is complete or null if not handled
  87757. */
  87758. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87759. /**
  87760. * @hidden
  87761. * Define this method to modify the default behavior when loading uris.
  87762. * @param context The context when loading the asset
  87763. * @param property The glTF property associated with the uri
  87764. * @param uri The uri to load
  87765. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87766. */
  87767. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87768. /**
  87769. * Define this method to modify the default behavior when loading buffer views.
  87770. * @param context The context when loading the asset
  87771. * @param bufferView The glTF buffer view property
  87772. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87773. */
  87774. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87775. /**
  87776. * Define this method to modify the default behavior when loading buffers.
  87777. * @param context The context when loading the asset
  87778. * @param buffer The glTF buffer property
  87779. * @param byteOffset The byte offset to load
  87780. * @param byteLength The byte length to load
  87781. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87782. */
  87783. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87784. }
  87785. }
  87786. declare module BABYLON.GLTF2 {
  87787. /**
  87788. * Helper class for working with arrays when loading the glTF asset
  87789. */
  87790. export class ArrayItem {
  87791. /**
  87792. * Gets an item from the given array.
  87793. * @param context The context when loading the asset
  87794. * @param array The array to get the item from
  87795. * @param index The index to the array
  87796. * @returns The array item
  87797. */
  87798. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87799. /**
  87800. * Assign an `index` field to each item of the given array.
  87801. * @param array The array of items
  87802. */
  87803. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87804. }
  87805. /**
  87806. * The glTF 2.0 loader
  87807. */
  87808. export class GLTFLoader implements IGLTFLoader {
  87809. /** @hidden */
  87810. _completePromises: Promise<any>[];
  87811. /** @hidden */
  87812. _forAssetContainer: boolean;
  87813. /** Storage */
  87814. _babylonLights: Light[];
  87815. /** @hidden */
  87816. _disableInstancedMesh: number;
  87817. private _disposed;
  87818. private _parent;
  87819. private _state;
  87820. private _extensions;
  87821. private _rootUrl;
  87822. private _fileName;
  87823. private _uniqueRootUrl;
  87824. private _gltf;
  87825. private _bin;
  87826. private _babylonScene;
  87827. private _rootBabylonMesh;
  87828. private _defaultBabylonMaterialData;
  87829. private static _RegisteredExtensions;
  87830. /**
  87831. * The default glTF sampler.
  87832. */
  87833. static readonly DefaultSampler: ISampler;
  87834. /**
  87835. * Registers a loader extension.
  87836. * @param name The name of the loader extension.
  87837. * @param factory The factory function that creates the loader extension.
  87838. */
  87839. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87840. /**
  87841. * Unregisters a loader extension.
  87842. * @param name The name of the loader extension.
  87843. * @returns A boolean indicating whether the extension has been unregistered
  87844. */
  87845. static UnregisterExtension(name: string): boolean;
  87846. /**
  87847. * The loader state.
  87848. */
  87849. get state(): Nullable<GLTFLoaderState>;
  87850. /**
  87851. * The object that represents the glTF JSON.
  87852. */
  87853. get gltf(): IGLTF;
  87854. /**
  87855. * The BIN chunk of a binary glTF.
  87856. */
  87857. get bin(): Nullable<IDataBuffer>;
  87858. /**
  87859. * The parent file loader.
  87860. */
  87861. get parent(): GLTFFileLoader;
  87862. /**
  87863. * The Babylon scene when loading the asset.
  87864. */
  87865. get babylonScene(): Scene;
  87866. /**
  87867. * The root Babylon mesh when loading the asset.
  87868. */
  87869. get rootBabylonMesh(): Mesh;
  87870. /** @hidden */
  87871. constructor(parent: GLTFFileLoader);
  87872. /** @hidden */
  87873. dispose(): void;
  87874. /** @hidden */
  87875. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87876. /** @hidden */
  87877. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87878. private _loadAsync;
  87879. private _loadData;
  87880. private _setupData;
  87881. private _loadExtensions;
  87882. private _checkExtensions;
  87883. private _setState;
  87884. private _createRootNode;
  87885. /**
  87886. * Loads a glTF scene.
  87887. * @param context The context when loading the asset
  87888. * @param scene The glTF scene property
  87889. * @returns A promise that resolves when the load is complete
  87890. */
  87891. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87892. private _forEachPrimitive;
  87893. private _getGeometries;
  87894. private _getMeshes;
  87895. private _getTransformNodes;
  87896. private _getSkeletons;
  87897. private _getAnimationGroups;
  87898. private _startAnimations;
  87899. /**
  87900. * Loads a glTF node.
  87901. * @param context The context when loading the asset
  87902. * @param node The glTF node property
  87903. * @param assign A function called synchronously after parsing the glTF properties
  87904. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87905. */
  87906. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87907. private _loadMeshAsync;
  87908. /**
  87909. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87910. * @param context The context when loading the asset
  87911. * @param name The mesh name when loading the asset
  87912. * @param node The glTF node when loading the asset
  87913. * @param mesh The glTF mesh when loading the asset
  87914. * @param primitive The glTF mesh primitive property
  87915. * @param assign A function called synchronously after parsing the glTF properties
  87916. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87917. */
  87918. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87919. private _loadVertexDataAsync;
  87920. private _createMorphTargets;
  87921. private _loadMorphTargetsAsync;
  87922. private _loadMorphTargetVertexDataAsync;
  87923. private static _LoadTransform;
  87924. private _loadSkinAsync;
  87925. private _loadBones;
  87926. private _loadBone;
  87927. private _loadSkinInverseBindMatricesDataAsync;
  87928. private _updateBoneMatrices;
  87929. private _getNodeMatrix;
  87930. /**
  87931. * Loads a glTF camera.
  87932. * @param context The context when loading the asset
  87933. * @param camera The glTF camera property
  87934. * @param assign A function called synchronously after parsing the glTF properties
  87935. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87936. */
  87937. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87938. private _loadAnimationsAsync;
  87939. /**
  87940. * Loads a glTF animation.
  87941. * @param context The context when loading the asset
  87942. * @param animation The glTF animation property
  87943. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87944. */
  87945. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87946. /**
  87947. * @hidden Loads a glTF animation channel.
  87948. * @param context The context when loading the asset
  87949. * @param animationContext The context of the animation when loading the asset
  87950. * @param animation The glTF animation property
  87951. * @param channel The glTF animation channel property
  87952. * @param babylonAnimationGroup The babylon animation group property
  87953. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87954. * @returns A void promise when the channel load is complete
  87955. */
  87956. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87957. private _loadAnimationSamplerAsync;
  87958. /**
  87959. * Loads a glTF buffer.
  87960. * @param context The context when loading the asset
  87961. * @param buffer The glTF buffer property
  87962. * @param byteOffset The byte offset to use
  87963. * @param byteLength The byte length to use
  87964. * @returns A promise that resolves with the loaded data when the load is complete
  87965. */
  87966. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87967. /**
  87968. * Loads a glTF buffer view.
  87969. * @param context The context when loading the asset
  87970. * @param bufferView The glTF buffer view property
  87971. * @returns A promise that resolves with the loaded data when the load is complete
  87972. */
  87973. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87974. private _loadAccessorAsync;
  87975. /** @hidden */
  87976. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87977. private _loadIndicesAccessorAsync;
  87978. private _loadVertexBufferViewAsync;
  87979. private _loadVertexAccessorAsync;
  87980. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87981. /** @hidden */
  87982. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87983. private _createDefaultMaterial;
  87984. /**
  87985. * Creates a Babylon material from a glTF material.
  87986. * @param context The context when loading the asset
  87987. * @param material The glTF material property
  87988. * @param babylonDrawMode The draw mode for the Babylon material
  87989. * @returns The Babylon material
  87990. */
  87991. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87992. /**
  87993. * Loads properties from a glTF material into a Babylon material.
  87994. * @param context The context when loading the asset
  87995. * @param material The glTF material property
  87996. * @param babylonMaterial The Babylon material
  87997. * @returns A promise that resolves when the load is complete
  87998. */
  87999. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88000. /**
  88001. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88002. * @param context The context when loading the asset
  88003. * @param material The glTF material property
  88004. * @param babylonMaterial The Babylon material
  88005. * @returns A promise that resolves when the load is complete
  88006. */
  88007. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88008. /**
  88009. * Loads the alpha properties from a glTF material into a Babylon material.
  88010. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88011. * @param context The context when loading the asset
  88012. * @param material The glTF material property
  88013. * @param babylonMaterial The Babylon material
  88014. */
  88015. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88016. /**
  88017. * Loads a glTF texture info.
  88018. * @param context The context when loading the asset
  88019. * @param textureInfo The glTF texture info property
  88020. * @param assign A function called synchronously after parsing the glTF properties
  88021. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88022. */
  88023. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88024. /** @hidden */
  88025. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88026. /** @hidden */
  88027. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88028. private _loadSampler;
  88029. /**
  88030. * Loads a glTF image.
  88031. * @param context The context when loading the asset
  88032. * @param image The glTF image property
  88033. * @returns A promise that resolves with the loaded data when the load is complete
  88034. */
  88035. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88036. /**
  88037. * Loads a glTF uri.
  88038. * @param context The context when loading the asset
  88039. * @param property The glTF property associated with the uri
  88040. * @param uri The base64 or relative uri
  88041. * @returns A promise that resolves with the loaded data when the load is complete
  88042. */
  88043. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88044. /**
  88045. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88046. * @param babylonObject the Babylon object with metadata
  88047. * @param pointer the JSON pointer
  88048. */
  88049. static AddPointerMetadata(babylonObject: {
  88050. metadata: any;
  88051. }, pointer: string): void;
  88052. private static _GetTextureWrapMode;
  88053. private static _GetTextureSamplingMode;
  88054. private static _GetTypedArrayConstructor;
  88055. private static _GetTypedArray;
  88056. private static _GetNumComponents;
  88057. private static _ValidateUri;
  88058. /** @hidden */
  88059. static _GetDrawMode(context: string, mode: number | undefined): number;
  88060. private _compileMaterialsAsync;
  88061. private _compileShadowGeneratorsAsync;
  88062. private _forEachExtensions;
  88063. private _applyExtensions;
  88064. private _extensionsOnLoading;
  88065. private _extensionsOnReady;
  88066. private _extensionsLoadSceneAsync;
  88067. private _extensionsLoadNodeAsync;
  88068. private _extensionsLoadCameraAsync;
  88069. private _extensionsLoadVertexDataAsync;
  88070. private _extensionsLoadMeshPrimitiveAsync;
  88071. private _extensionsLoadMaterialAsync;
  88072. private _extensionsCreateMaterial;
  88073. private _extensionsLoadMaterialPropertiesAsync;
  88074. private _extensionsLoadTextureInfoAsync;
  88075. private _extensionsLoadTextureAsync;
  88076. private _extensionsLoadAnimationAsync;
  88077. private _extensionsLoadSkinAsync;
  88078. private _extensionsLoadUriAsync;
  88079. private _extensionsLoadBufferViewAsync;
  88080. private _extensionsLoadBufferAsync;
  88081. /**
  88082. * Helper method called by a loader extension to load an glTF extension.
  88083. * @param context The context when loading the asset
  88084. * @param property The glTF property to load the extension from
  88085. * @param extensionName The name of the extension to load
  88086. * @param actionAsync The action to run
  88087. * @returns The promise returned by actionAsync or null if the extension does not exist
  88088. */
  88089. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88090. /**
  88091. * Helper method called by a loader extension to load a glTF extra.
  88092. * @param context The context when loading the asset
  88093. * @param property The glTF property to load the extra from
  88094. * @param extensionName The name of the extension to load
  88095. * @param actionAsync The action to run
  88096. * @returns The promise returned by actionAsync or null if the extra does not exist
  88097. */
  88098. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88099. /**
  88100. * Checks for presence of an extension.
  88101. * @param name The name of the extension to check
  88102. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88103. */
  88104. isExtensionUsed(name: string): boolean;
  88105. /**
  88106. * Increments the indentation level and logs a message.
  88107. * @param message The message to log
  88108. */
  88109. logOpen(message: string): void;
  88110. /**
  88111. * Decrements the indentation level.
  88112. */
  88113. logClose(): void;
  88114. /**
  88115. * Logs a message
  88116. * @param message The message to log
  88117. */
  88118. log(message: string): void;
  88119. /**
  88120. * Starts a performance counter.
  88121. * @param counterName The name of the performance counter
  88122. */
  88123. startPerformanceCounter(counterName: string): void;
  88124. /**
  88125. * Ends a performance counter.
  88126. * @param counterName The name of the performance counter
  88127. */
  88128. endPerformanceCounter(counterName: string): void;
  88129. }
  88130. }
  88131. declare module BABYLON.GLTF2.Loader.Extensions {
  88132. /** @hidden */
  88133. interface IEXTLightsImageBased_LightImageBased {
  88134. _babylonTexture?: BaseTexture;
  88135. _loaded?: Promise<void>;
  88136. }
  88137. /**
  88138. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88139. */
  88140. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88141. /**
  88142. * The name of this extension.
  88143. */
  88144. readonly name: string;
  88145. /**
  88146. * Defines whether this extension is enabled.
  88147. */
  88148. enabled: boolean;
  88149. private _loader;
  88150. private _lights?;
  88151. /** @hidden */
  88152. constructor(loader: GLTFLoader);
  88153. /** @hidden */
  88154. dispose(): void;
  88155. /** @hidden */
  88156. onLoading(): void;
  88157. /** @hidden */
  88158. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88159. private _loadLightAsync;
  88160. }
  88161. }
  88162. declare module BABYLON.GLTF2.Loader.Extensions {
  88163. /**
  88164. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88165. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88166. * !!! Experimental Extension Subject to Changes !!!
  88167. */
  88168. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88169. /**
  88170. * The name of this extension.
  88171. */
  88172. readonly name: string;
  88173. /**
  88174. * Defines whether this extension is enabled.
  88175. */
  88176. enabled: boolean;
  88177. private _loader;
  88178. /** @hidden */
  88179. constructor(loader: GLTFLoader);
  88180. /** @hidden */
  88181. dispose(): void;
  88182. /** @hidden */
  88183. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88184. }
  88185. }
  88186. declare module BABYLON.GLTF2.Loader.Extensions {
  88187. /**
  88188. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88189. *
  88190. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88191. */
  88192. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88193. /**
  88194. * The name of this extension.
  88195. */
  88196. readonly name: string;
  88197. /**
  88198. * Defines whether this extension is enabled.
  88199. */
  88200. enabled: boolean;
  88201. /**
  88202. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88203. */
  88204. static DecoderPath: string;
  88205. private _loader;
  88206. private _decoderPromise?;
  88207. /** @hidden */
  88208. constructor(loader: GLTFLoader);
  88209. /** @hidden */
  88210. dispose(): void;
  88211. /** @hidden */
  88212. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88213. }
  88214. }
  88215. declare module BABYLON.GLTF2.Loader.Extensions {
  88216. /**
  88217. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88218. */
  88219. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88220. /** The name of this extension. */
  88221. readonly name: string;
  88222. /** Defines whether this extension is enabled. */
  88223. enabled: boolean;
  88224. private _loader;
  88225. /** @hidden */
  88226. constructor(loader: GLTFLoader);
  88227. /** @hidden */
  88228. dispose(): void;
  88229. /** @hidden */
  88230. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88231. }
  88232. }
  88233. declare module BABYLON.GLTF2.Loader.Extensions {
  88234. /**
  88235. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88236. */
  88237. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88238. /**
  88239. * The name of this extension.
  88240. */
  88241. readonly name: string;
  88242. /**
  88243. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88244. */
  88245. dracoCompression?: DracoCompression;
  88246. /**
  88247. * Defines whether this extension is enabled.
  88248. */
  88249. enabled: boolean;
  88250. private _loader;
  88251. /** @hidden */
  88252. constructor(loader: GLTFLoader);
  88253. /** @hidden */
  88254. dispose(): void;
  88255. /** @hidden */
  88256. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88257. }
  88258. }
  88259. declare module BABYLON.GLTF2.Loader.Extensions {
  88260. /**
  88261. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88262. */
  88263. export class KHR_lights implements IGLTFLoaderExtension {
  88264. /**
  88265. * The name of this extension.
  88266. */
  88267. readonly name: string;
  88268. /**
  88269. * Defines whether this extension is enabled.
  88270. */
  88271. enabled: boolean;
  88272. private _loader;
  88273. private _lights?;
  88274. /** @hidden */
  88275. constructor(loader: GLTFLoader);
  88276. /** @hidden */
  88277. dispose(): void;
  88278. /** @hidden */
  88279. onLoading(): void;
  88280. /** @hidden */
  88281. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88282. }
  88283. }
  88284. declare module BABYLON.GLTF2.Loader.Extensions {
  88285. /**
  88286. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88287. */
  88288. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88289. /**
  88290. * The name of this extension.
  88291. */
  88292. readonly name: string;
  88293. /**
  88294. * Defines whether this extension is enabled.
  88295. */
  88296. enabled: boolean;
  88297. /**
  88298. * Defines a number that determines the order the extensions are applied.
  88299. */
  88300. order: number;
  88301. private _loader;
  88302. /** @hidden */
  88303. constructor(loader: GLTFLoader);
  88304. /** @hidden */
  88305. dispose(): void;
  88306. /** @hidden */
  88307. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88308. private _loadSpecularGlossinessPropertiesAsync;
  88309. }
  88310. }
  88311. declare module BABYLON.GLTF2.Loader.Extensions {
  88312. /**
  88313. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88314. */
  88315. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88316. /**
  88317. * The name of this extension.
  88318. */
  88319. readonly name: string;
  88320. /**
  88321. * Defines whether this extension is enabled.
  88322. */
  88323. enabled: boolean;
  88324. /**
  88325. * Defines a number that determines the order the extensions are applied.
  88326. */
  88327. order: number;
  88328. private _loader;
  88329. /** @hidden */
  88330. constructor(loader: GLTFLoader);
  88331. /** @hidden */
  88332. dispose(): void;
  88333. /** @hidden */
  88334. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88335. private _loadUnlitPropertiesAsync;
  88336. }
  88337. }
  88338. declare module BABYLON.GLTF2.Loader.Extensions {
  88339. /**
  88340. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88341. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88342. */
  88343. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88344. /**
  88345. * The name of this extension.
  88346. */
  88347. readonly name: string;
  88348. /**
  88349. * Defines whether this extension is enabled.
  88350. */
  88351. enabled: boolean;
  88352. /**
  88353. * Defines a number that determines the order the extensions are applied.
  88354. */
  88355. order: number;
  88356. private _loader;
  88357. /** @hidden */
  88358. constructor(loader: GLTFLoader);
  88359. /** @hidden */
  88360. dispose(): void;
  88361. /** @hidden */
  88362. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88363. private _loadClearCoatPropertiesAsync;
  88364. }
  88365. }
  88366. declare module BABYLON.GLTF2.Loader.Extensions {
  88367. /**
  88368. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88369. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88370. * !!! Experimental Extension Subject to Changes !!!
  88371. */
  88372. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88373. /**
  88374. * The name of this extension.
  88375. */
  88376. readonly name: string;
  88377. /**
  88378. * Defines whether this extension is enabled.
  88379. */
  88380. enabled: boolean;
  88381. /**
  88382. * Defines a number that determines the order the extensions are applied.
  88383. */
  88384. order: number;
  88385. private _loader;
  88386. /** @hidden */
  88387. constructor(loader: GLTFLoader);
  88388. /** @hidden */
  88389. dispose(): void;
  88390. /** @hidden */
  88391. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88392. private _loadSheenPropertiesAsync;
  88393. }
  88394. }
  88395. declare module BABYLON.GLTF2.Loader.Extensions {
  88396. /**
  88397. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88398. * !!! Experimental Extension Subject to Changes !!!
  88399. */
  88400. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88401. /**
  88402. * The name of this extension.
  88403. */
  88404. readonly name: string;
  88405. /**
  88406. * Defines whether this extension is enabled.
  88407. */
  88408. enabled: boolean;
  88409. /**
  88410. * Defines a number that determines the order the extensions are applied.
  88411. */
  88412. order: number;
  88413. private _loader;
  88414. /** @hidden */
  88415. constructor(loader: GLTFLoader);
  88416. /** @hidden */
  88417. dispose(): void;
  88418. /** @hidden */
  88419. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88420. private _loadSpecularPropertiesAsync;
  88421. }
  88422. }
  88423. declare module BABYLON.GLTF2.Loader.Extensions {
  88424. /**
  88425. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88426. * !!! Experimental Extension Subject to Changes !!!
  88427. */
  88428. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88429. /**
  88430. * Default ior Value from the spec.
  88431. */
  88432. private static readonly _DEFAULT_IOR;
  88433. /**
  88434. * The name of this extension.
  88435. */
  88436. readonly name: string;
  88437. /**
  88438. * Defines whether this extension is enabled.
  88439. */
  88440. enabled: boolean;
  88441. /**
  88442. * Defines a number that determines the order the extensions are applied.
  88443. */
  88444. order: number;
  88445. private _loader;
  88446. /** @hidden */
  88447. constructor(loader: GLTFLoader);
  88448. /** @hidden */
  88449. dispose(): void;
  88450. /** @hidden */
  88451. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88452. private _loadIorPropertiesAsync;
  88453. }
  88454. }
  88455. declare module BABYLON.GLTF2.Loader.Extensions {
  88456. /**
  88457. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88458. */
  88459. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88460. /**
  88461. * The name of this extension.
  88462. */
  88463. readonly name: string;
  88464. /**
  88465. * Defines whether this extension is enabled.
  88466. */
  88467. enabled: boolean;
  88468. private _loader;
  88469. private _variants?;
  88470. /** @hidden */
  88471. constructor(loader: GLTFLoader);
  88472. /** @hidden */
  88473. dispose(): void;
  88474. /**
  88475. * Gets the list of available variant names for this asset.
  88476. * @param rootMesh The glTF root mesh
  88477. * @returns the list of all the variant names for this model
  88478. */
  88479. static GetAvailableVariants(rootMesh: Mesh): string[];
  88480. /**
  88481. * Gets the list of available variant names for this asset.
  88482. * @param rootMesh The glTF root mesh
  88483. * @returns the list of all the variant names for this model
  88484. */
  88485. getAvailableVariants(rootMesh: Mesh): string[];
  88486. /**
  88487. * Select a variant given a variant name or a list of variant names.
  88488. * @param rootMesh The glTF root mesh
  88489. * @param variantName The variant name(s) to select.
  88490. */
  88491. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88492. /**
  88493. * Select a variant given a variant name or a list of variant names.
  88494. * @param rootMesh The glTF root mesh
  88495. * @param variantName The variant name(s) to select.
  88496. */
  88497. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88498. /**
  88499. * Reset back to the original before selecting a variant.
  88500. * @param rootMesh The glTF root mesh
  88501. */
  88502. static Reset(rootMesh: Mesh): void;
  88503. /**
  88504. * Reset back to the original before selecting a variant.
  88505. * @param rootMesh The glTF root mesh
  88506. */
  88507. reset(rootMesh: Mesh): void;
  88508. /**
  88509. * Gets the last selected variant name(s) or null if original.
  88510. * @param rootMesh The glTF root mesh
  88511. * @returns The selected variant name(s).
  88512. */
  88513. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88514. /**
  88515. * Gets the last selected variant name(s) or null if original.
  88516. * @param rootMesh The glTF root mesh
  88517. * @returns The selected variant name(s).
  88518. */
  88519. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88520. private static _GetExtensionMetadata;
  88521. /** @hidden */
  88522. onLoading(): void;
  88523. /** @hidden */
  88524. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88525. }
  88526. }
  88527. declare module BABYLON.GLTF2.Loader.Extensions {
  88528. /**
  88529. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88530. */
  88531. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88532. /**
  88533. * The name of this extension.
  88534. */
  88535. readonly name: string;
  88536. /**
  88537. * Defines whether this extension is enabled.
  88538. */
  88539. enabled: boolean;
  88540. /**
  88541. * Defines a number that determines the order the extensions are applied.
  88542. */
  88543. order: number;
  88544. private _loader;
  88545. /** @hidden */
  88546. constructor(loader: GLTFLoader);
  88547. /** @hidden */
  88548. dispose(): void;
  88549. /** @hidden */
  88550. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88551. private _loadTransparentPropertiesAsync;
  88552. }
  88553. }
  88554. declare module BABYLON.GLTF2.Loader.Extensions {
  88555. /**
  88556. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88557. * !!! Experimental Extension Subject to Changes !!!
  88558. */
  88559. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88560. /**
  88561. * The name of this extension.
  88562. */
  88563. readonly name: string;
  88564. /**
  88565. * Defines whether this extension is enabled.
  88566. */
  88567. enabled: boolean;
  88568. /**
  88569. * Defines a number that determines the order the extensions are applied.
  88570. */
  88571. order: number;
  88572. private _loader;
  88573. /** @hidden */
  88574. constructor(loader: GLTFLoader);
  88575. /** @hidden */
  88576. dispose(): void;
  88577. /** @hidden */
  88578. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88579. private _loadTranslucentPropertiesAsync;
  88580. }
  88581. }
  88582. declare module BABYLON.GLTF2.Loader.Extensions {
  88583. /**
  88584. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88585. */
  88586. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88587. /**
  88588. * The name of this extension.
  88589. */
  88590. readonly name: string;
  88591. /**
  88592. * Defines whether this extension is enabled.
  88593. */
  88594. enabled: boolean;
  88595. /** @hidden */
  88596. constructor(loader: GLTFLoader);
  88597. /** @hidden */
  88598. dispose(): void;
  88599. }
  88600. }
  88601. declare module BABYLON.GLTF2.Loader.Extensions {
  88602. /**
  88603. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88604. * !!! Experimental Extension Subject to Changes !!!
  88605. */
  88606. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88607. /** The name of this extension. */
  88608. readonly name: string;
  88609. /** Defines whether this extension is enabled. */
  88610. enabled: boolean;
  88611. private _loader;
  88612. /** @hidden */
  88613. constructor(loader: GLTFLoader);
  88614. /** @hidden */
  88615. dispose(): void;
  88616. /** @hidden */
  88617. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88618. }
  88619. }
  88620. declare module BABYLON.GLTF2.Loader.Extensions {
  88621. /**
  88622. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88623. */
  88624. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88625. /**
  88626. * The name of this extension.
  88627. */
  88628. readonly name: string;
  88629. /**
  88630. * Defines whether this extension is enabled.
  88631. */
  88632. enabled: boolean;
  88633. private _loader;
  88634. /** @hidden */
  88635. constructor(loader: GLTFLoader);
  88636. /** @hidden */
  88637. dispose(): void;
  88638. /** @hidden */
  88639. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88640. }
  88641. }
  88642. declare module BABYLON.GLTF2.Loader.Extensions {
  88643. /**
  88644. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  88645. * !!! Experimental Extension Subject to Changes !!!
  88646. */
  88647. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  88648. /**
  88649. * The name of this extension.
  88650. */
  88651. readonly name: string;
  88652. /**
  88653. * Defines whether this extension is enabled.
  88654. */
  88655. enabled: boolean;
  88656. /**
  88657. * Defines a number that determines the order the extensions are applied.
  88658. */
  88659. order: number;
  88660. private _loader;
  88661. /** @hidden */
  88662. constructor(loader: GLTFLoader);
  88663. /** @hidden */
  88664. dispose(): void;
  88665. /**
  88666. * Called after the loader state changes to LOADING.
  88667. */
  88668. onLoading(): void;
  88669. }
  88670. }
  88671. declare module BABYLON.GLTF2.Loader.Extensions {
  88672. /**
  88673. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88674. */
  88675. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88676. /**
  88677. * The name of this extension.
  88678. */
  88679. readonly name: string;
  88680. /**
  88681. * Defines whether this extension is enabled.
  88682. */
  88683. enabled: boolean;
  88684. private _loader;
  88685. private _clips;
  88686. private _emitters;
  88687. /** @hidden */
  88688. constructor(loader: GLTFLoader);
  88689. /** @hidden */
  88690. dispose(): void;
  88691. /** @hidden */
  88692. onLoading(): void;
  88693. /** @hidden */
  88694. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88695. /** @hidden */
  88696. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88697. /** @hidden */
  88698. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88699. private _loadClipAsync;
  88700. private _loadEmitterAsync;
  88701. private _getEventAction;
  88702. private _loadAnimationEventAsync;
  88703. }
  88704. }
  88705. declare module BABYLON.GLTF2.Loader.Extensions {
  88706. /**
  88707. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88708. */
  88709. export class MSFT_lod implements IGLTFLoaderExtension {
  88710. /**
  88711. * The name of this extension.
  88712. */
  88713. readonly name: string;
  88714. /**
  88715. * Defines whether this extension is enabled.
  88716. */
  88717. enabled: boolean;
  88718. /**
  88719. * Defines a number that determines the order the extensions are applied.
  88720. */
  88721. order: number;
  88722. /**
  88723. * Maximum number of LODs to load, starting from the lowest LOD.
  88724. */
  88725. maxLODsToLoad: number;
  88726. /**
  88727. * Observable raised when all node LODs of one level are loaded.
  88728. * The event data is the index of the loaded LOD starting from zero.
  88729. * Dispose the loader to cancel the loading of the next level of LODs.
  88730. */
  88731. onNodeLODsLoadedObservable: Observable<number>;
  88732. /**
  88733. * Observable raised when all material LODs of one level are loaded.
  88734. * The event data is the index of the loaded LOD starting from zero.
  88735. * Dispose the loader to cancel the loading of the next level of LODs.
  88736. */
  88737. onMaterialLODsLoadedObservable: Observable<number>;
  88738. private _loader;
  88739. private _bufferLODs;
  88740. private _nodeIndexLOD;
  88741. private _nodeSignalLODs;
  88742. private _nodePromiseLODs;
  88743. private _nodeBufferLODs;
  88744. private _materialIndexLOD;
  88745. private _materialSignalLODs;
  88746. private _materialPromiseLODs;
  88747. private _materialBufferLODs;
  88748. /** @hidden */
  88749. constructor(loader: GLTFLoader);
  88750. /** @hidden */
  88751. dispose(): void;
  88752. /** @hidden */
  88753. onReady(): void;
  88754. /** @hidden */
  88755. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88756. /** @hidden */
  88757. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88758. /** @hidden */
  88759. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88760. /** @hidden */
  88761. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88762. /** @hidden */
  88763. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88764. private _loadBufferLOD;
  88765. /**
  88766. * Gets an array of LOD properties from lowest to highest.
  88767. */
  88768. private _getLODs;
  88769. private _disposeTransformNode;
  88770. private _disposeMaterials;
  88771. }
  88772. }
  88773. declare module BABYLON.GLTF2.Loader.Extensions {
  88774. /** @hidden */
  88775. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88776. readonly name: string;
  88777. enabled: boolean;
  88778. private _loader;
  88779. constructor(loader: GLTFLoader);
  88780. dispose(): void;
  88781. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88782. }
  88783. }
  88784. declare module BABYLON.GLTF2.Loader.Extensions {
  88785. /** @hidden */
  88786. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88787. readonly name: string;
  88788. enabled: boolean;
  88789. private _loader;
  88790. constructor(loader: GLTFLoader);
  88791. dispose(): void;
  88792. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88793. }
  88794. }
  88795. declare module BABYLON.GLTF2.Loader.Extensions {
  88796. /**
  88797. * Store glTF extras (if present) in BJS objects' metadata
  88798. */
  88799. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88800. /**
  88801. * The name of this extension.
  88802. */
  88803. readonly name: string;
  88804. /**
  88805. * Defines whether this extension is enabled.
  88806. */
  88807. enabled: boolean;
  88808. private _loader;
  88809. private _assignExtras;
  88810. /** @hidden */
  88811. constructor(loader: GLTFLoader);
  88812. /** @hidden */
  88813. dispose(): void;
  88814. /** @hidden */
  88815. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88816. /** @hidden */
  88817. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88818. /** @hidden */
  88819. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88820. }
  88821. }
  88822. declare module BABYLON {
  88823. /**
  88824. * Class reading and parsing the MTL file bundled with the obj file.
  88825. */
  88826. export class MTLFileLoader {
  88827. /**
  88828. * Invert Y-Axis of referenced textures on load
  88829. */
  88830. static INVERT_TEXTURE_Y: boolean;
  88831. /**
  88832. * All material loaded from the mtl will be set here
  88833. */
  88834. materials: StandardMaterial[];
  88835. /**
  88836. * This function will read the mtl file and create each material described inside
  88837. * This function could be improve by adding :
  88838. * -some component missing (Ni, Tf...)
  88839. * -including the specific options available
  88840. *
  88841. * @param scene defines the scene the material will be created in
  88842. * @param data defines the mtl data to parse
  88843. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88844. * @param forAssetContainer defines if the material should be registered in the scene
  88845. */
  88846. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88847. /**
  88848. * Gets the texture for the material.
  88849. *
  88850. * If the material is imported from input file,
  88851. * We sanitize the url to ensure it takes the textre from aside the material.
  88852. *
  88853. * @param rootUrl The root url to load from
  88854. * @param value The value stored in the mtl
  88855. * @return The Texture
  88856. */
  88857. private static _getTexture;
  88858. }
  88859. }
  88860. declare module BABYLON {
  88861. /**
  88862. * Options for loading OBJ/MTL files
  88863. */
  88864. type MeshLoadOptions = {
  88865. /**
  88866. * Defines if UVs are optimized by default during load.
  88867. */
  88868. OptimizeWithUV: boolean;
  88869. /**
  88870. * Defines custom scaling of UV coordinates of loaded meshes.
  88871. */
  88872. UVScaling: Vector2;
  88873. /**
  88874. * Invert model on y-axis (does a model scaling inversion)
  88875. */
  88876. InvertY: boolean;
  88877. /**
  88878. * Invert Y-Axis of referenced textures on load
  88879. */
  88880. InvertTextureY: boolean;
  88881. /**
  88882. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88883. */
  88884. ImportVertexColors: boolean;
  88885. /**
  88886. * Compute the normals for the model, even if normals are present in the file.
  88887. */
  88888. ComputeNormals: boolean;
  88889. /**
  88890. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88891. */
  88892. SkipMaterials: boolean;
  88893. /**
  88894. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88895. */
  88896. MaterialLoadingFailsSilently: boolean;
  88897. };
  88898. /**
  88899. * OBJ file type loader.
  88900. * This is a babylon scene loader plugin.
  88901. */
  88902. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88903. /**
  88904. * Defines if UVs are optimized by default during load.
  88905. */
  88906. static OPTIMIZE_WITH_UV: boolean;
  88907. /**
  88908. * Invert model on y-axis (does a model scaling inversion)
  88909. */
  88910. static INVERT_Y: boolean;
  88911. /**
  88912. * Invert Y-Axis of referenced textures on load
  88913. */
  88914. static get INVERT_TEXTURE_Y(): boolean;
  88915. static set INVERT_TEXTURE_Y(value: boolean);
  88916. /**
  88917. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88918. */
  88919. static IMPORT_VERTEX_COLORS: boolean;
  88920. /**
  88921. * Compute the normals for the model, even if normals are present in the file.
  88922. */
  88923. static COMPUTE_NORMALS: boolean;
  88924. /**
  88925. * Defines custom scaling of UV coordinates of loaded meshes.
  88926. */
  88927. static UV_SCALING: Vector2;
  88928. /**
  88929. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88930. */
  88931. static SKIP_MATERIALS: boolean;
  88932. /**
  88933. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88934. *
  88935. * Defaults to true for backwards compatibility.
  88936. */
  88937. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88938. /**
  88939. * Defines the name of the plugin.
  88940. */
  88941. name: string;
  88942. /**
  88943. * Defines the extension the plugin is able to load.
  88944. */
  88945. extensions: string;
  88946. /** @hidden */
  88947. obj: RegExp;
  88948. /** @hidden */
  88949. group: RegExp;
  88950. /** @hidden */
  88951. mtllib: RegExp;
  88952. /** @hidden */
  88953. usemtl: RegExp;
  88954. /** @hidden */
  88955. smooth: RegExp;
  88956. /** @hidden */
  88957. vertexPattern: RegExp;
  88958. /** @hidden */
  88959. normalPattern: RegExp;
  88960. /** @hidden */
  88961. uvPattern: RegExp;
  88962. /** @hidden */
  88963. facePattern1: RegExp;
  88964. /** @hidden */
  88965. facePattern2: RegExp;
  88966. /** @hidden */
  88967. facePattern3: RegExp;
  88968. /** @hidden */
  88969. facePattern4: RegExp;
  88970. /** @hidden */
  88971. facePattern5: RegExp;
  88972. private _forAssetContainer;
  88973. private _meshLoadOptions;
  88974. /**
  88975. * Creates loader for .OBJ files
  88976. *
  88977. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88978. */
  88979. constructor(meshLoadOptions?: MeshLoadOptions);
  88980. private static get currentMeshLoadOptions();
  88981. /**
  88982. * Calls synchronously the MTL file attached to this obj.
  88983. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88984. * Without this function materials are not displayed in the first frame (but displayed after).
  88985. * In consequence it is impossible to get material information in your HTML file
  88986. *
  88987. * @param url The URL of the MTL file
  88988. * @param rootUrl
  88989. * @param onSuccess Callback function to be called when the MTL file is loaded
  88990. * @private
  88991. */
  88992. private _loadMTL;
  88993. /**
  88994. * Instantiates a OBJ file loader plugin.
  88995. * @returns the created plugin
  88996. */
  88997. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88998. /**
  88999. * If the data string can be loaded directly.
  89000. *
  89001. * @param data string containing the file data
  89002. * @returns if the data can be loaded directly
  89003. */
  89004. canDirectLoad(data: string): boolean;
  89005. /**
  89006. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89007. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89008. * @param scene the scene the meshes should be added to
  89009. * @param data the OBJ data to load
  89010. * @param rootUrl root url to load from
  89011. * @param onProgress event that fires when loading progress has occured
  89012. * @param fileName Defines the name of the file to load
  89013. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89014. */
  89015. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89016. /**
  89017. * Imports all objects from the loaded OBJ data and adds them to the scene
  89018. * @param scene the scene the objects should be added to
  89019. * @param data the OBJ data to load
  89020. * @param rootUrl root url to load from
  89021. * @param onProgress event that fires when loading progress has occured
  89022. * @param fileName Defines the name of the file to load
  89023. * @returns a promise which completes when objects have been loaded to the scene
  89024. */
  89025. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89026. /**
  89027. * Load into an asset container.
  89028. * @param scene The scene to load into
  89029. * @param data The data to import
  89030. * @param rootUrl The root url for scene and resources
  89031. * @param onProgress The callback when the load progresses
  89032. * @param fileName Defines the name of the file to load
  89033. * @returns The loaded asset container
  89034. */
  89035. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89036. /**
  89037. * Read the OBJ file and create an Array of meshes.
  89038. * Each mesh contains all information given by the OBJ and the MTL file.
  89039. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89040. *
  89041. * @param meshesNames
  89042. * @param scene Scene The scene where are displayed the data
  89043. * @param data String The content of the obj file
  89044. * @param rootUrl String The path to the folder
  89045. * @returns Array<AbstractMesh>
  89046. * @private
  89047. */
  89048. private _parseSolid;
  89049. }
  89050. }
  89051. declare module BABYLON {
  89052. /**
  89053. * STL file type loader.
  89054. * This is a babylon scene loader plugin.
  89055. */
  89056. export class STLFileLoader implements ISceneLoaderPlugin {
  89057. /** @hidden */
  89058. solidPattern: RegExp;
  89059. /** @hidden */
  89060. facetsPattern: RegExp;
  89061. /** @hidden */
  89062. normalPattern: RegExp;
  89063. /** @hidden */
  89064. vertexPattern: RegExp;
  89065. /**
  89066. * Defines the name of the plugin.
  89067. */
  89068. name: string;
  89069. /**
  89070. * Defines the extensions the stl loader is able to load.
  89071. * force data to come in as an ArrayBuffer
  89072. * we'll convert to string if it looks like it's an ASCII .stl
  89073. */
  89074. extensions: ISceneLoaderPluginExtensions;
  89075. /**
  89076. * Import meshes into a scene.
  89077. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89078. * @param scene The scene to import into
  89079. * @param data The data to import
  89080. * @param rootUrl The root url for scene and resources
  89081. * @param meshes The meshes array to import into
  89082. * @param particleSystems The particle systems array to import into
  89083. * @param skeletons The skeletons array to import into
  89084. * @param onError The callback when import fails
  89085. * @returns True if successful or false otherwise
  89086. */
  89087. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89088. /**
  89089. * Load into a scene.
  89090. * @param scene The scene to load into
  89091. * @param data The data to import
  89092. * @param rootUrl The root url for scene and resources
  89093. * @param onError The callback when import fails
  89094. * @returns true if successful or false otherwise
  89095. */
  89096. load(scene: Scene, data: any, rootUrl: string): boolean;
  89097. /**
  89098. * Load into an asset container.
  89099. * @param scene The scene to load into
  89100. * @param data The data to import
  89101. * @param rootUrl The root url for scene and resources
  89102. * @param onError The callback when import fails
  89103. * @returns The loaded asset container
  89104. */
  89105. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89106. private _isBinary;
  89107. private _parseBinary;
  89108. private _parseASCII;
  89109. }
  89110. }
  89111. declare module BABYLON {
  89112. /**
  89113. * Class for generating OBJ data from a Babylon scene.
  89114. */
  89115. export class OBJExport {
  89116. /**
  89117. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89118. * @param mesh defines the list of meshes to serialize
  89119. * @param materials defines if materials should be exported
  89120. * @param matlibname defines the name of the associated mtl file
  89121. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89122. * @returns the OBJ content
  89123. */
  89124. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89125. /**
  89126. * Exports the material(s) of a mesh in .MTL file format (text)
  89127. * @param mesh defines the mesh to extract the material from
  89128. * @returns the mtl content
  89129. */
  89130. static MTL(mesh: Mesh): string;
  89131. }
  89132. }
  89133. declare module BABYLON {
  89134. /** @hidden */
  89135. export var __IGLTFExporterExtension: number;
  89136. /**
  89137. * Interface for extending the exporter
  89138. * @hidden
  89139. */
  89140. export interface IGLTFExporterExtension {
  89141. /**
  89142. * The name of this extension
  89143. */
  89144. readonly name: string;
  89145. /**
  89146. * Defines whether this extension is enabled
  89147. */
  89148. enabled: boolean;
  89149. /**
  89150. * Defines whether this extension is required
  89151. */
  89152. required: boolean;
  89153. }
  89154. }
  89155. declare module BABYLON.GLTF2.Exporter {
  89156. /** @hidden */
  89157. export var __IGLTFExporterExtensionV2: number;
  89158. /**
  89159. * Interface for a glTF exporter extension
  89160. * @hidden
  89161. */
  89162. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89163. /**
  89164. * Define this method to modify the default behavior before exporting a texture
  89165. * @param context The context when loading the asset
  89166. * @param babylonTexture The Babylon.js texture
  89167. * @param mimeType The mime-type of the generated image
  89168. * @returns A promise that resolves with the exported texture
  89169. */
  89170. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89171. /**
  89172. * Define this method to get notified when a texture info is created
  89173. * @param context The context when loading the asset
  89174. * @param textureInfo The glTF texture info
  89175. * @param babylonTexture The Babylon.js texture
  89176. */
  89177. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89178. /**
  89179. * Define this method to modify the default behavior when exporting texture info
  89180. * @param context The context when loading the asset
  89181. * @param meshPrimitive glTF mesh primitive
  89182. * @param babylonSubMesh Babylon submesh
  89183. * @param binaryWriter glTF serializer binary writer instance
  89184. * @returns nullable IMeshPrimitive promise
  89185. */
  89186. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89187. /**
  89188. * Define this method to modify the default behavior when exporting a node
  89189. * @param context The context when exporting the node
  89190. * @param node glTF node
  89191. * @param babylonNode BabylonJS node
  89192. * @returns nullable INode promise
  89193. */
  89194. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89195. [key: number]: number;
  89196. }): Promise<Nullable<INode>>;
  89197. /**
  89198. * Define this method to modify the default behavior when exporting a material
  89199. * @param material glTF material
  89200. * @param babylonMaterial BabylonJS material
  89201. * @returns nullable IMaterial promise
  89202. */
  89203. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89204. /**
  89205. * Define this method to return additional textures to export from a material
  89206. * @param material glTF material
  89207. * @param babylonMaterial BabylonJS material
  89208. * @returns List of textures
  89209. */
  89210. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89211. /** Gets a boolean indicating that this extension was used */
  89212. wasUsed: boolean;
  89213. /** Gets a boolean indicating that this extension is required for the file to work */
  89214. required: boolean;
  89215. /**
  89216. * Called after the exporter state changes to EXPORTING
  89217. */
  89218. onExporting?(): void;
  89219. }
  89220. }
  89221. declare module BABYLON.GLTF2.Exporter {
  89222. /**
  89223. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89224. * @hidden
  89225. */
  89226. export class _GLTFMaterialExporter {
  89227. /**
  89228. * Represents the dielectric specular values for R, G and B
  89229. */
  89230. private static readonly _DielectricSpecular;
  89231. /**
  89232. * Allows the maximum specular power to be defined for material calculations
  89233. */
  89234. private static readonly _MaxSpecularPower;
  89235. /**
  89236. * Mapping to store textures
  89237. */
  89238. private _textureMap;
  89239. /**
  89240. * Numeric tolerance value
  89241. */
  89242. private static readonly _Epsilon;
  89243. /**
  89244. * Reference to the glTF Exporter
  89245. */
  89246. private _exporter;
  89247. constructor(exporter: _Exporter);
  89248. /**
  89249. * Specifies if two colors are approximately equal in value
  89250. * @param color1 first color to compare to
  89251. * @param color2 second color to compare to
  89252. * @param epsilon threshold value
  89253. */
  89254. private static FuzzyEquals;
  89255. /**
  89256. * Gets the materials from a Babylon scene and converts them to glTF materials
  89257. * @param scene babylonjs scene
  89258. * @param mimeType texture mime type
  89259. * @param images array of images
  89260. * @param textures array of textures
  89261. * @param materials array of materials
  89262. * @param imageData mapping of texture names to base64 textures
  89263. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89264. */
  89265. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89266. /**
  89267. * Makes a copy of the glTF material without the texture parameters
  89268. * @param originalMaterial original glTF material
  89269. * @returns glTF material without texture parameters
  89270. */
  89271. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89272. /**
  89273. * Specifies if the material has any texture parameters present
  89274. * @param material glTF Material
  89275. * @returns boolean specifying if texture parameters are present
  89276. */
  89277. _hasTexturesPresent(material: IMaterial): boolean;
  89278. /**
  89279. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89280. * @param babylonStandardMaterial
  89281. * @returns glTF Metallic Roughness Material representation
  89282. */
  89283. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89284. /**
  89285. * Computes the metallic factor
  89286. * @param diffuse diffused value
  89287. * @param specular specular value
  89288. * @param oneMinusSpecularStrength one minus the specular strength
  89289. * @returns metallic value
  89290. */
  89291. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89292. /**
  89293. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89294. * @param glTFMaterial glTF material
  89295. * @param babylonMaterial Babylon material
  89296. */
  89297. private static _SetAlphaMode;
  89298. /**
  89299. * Converts a Babylon Standard Material to a glTF Material
  89300. * @param babylonStandardMaterial BJS Standard Material
  89301. * @param mimeType mime type to use for the textures
  89302. * @param images array of glTF image interfaces
  89303. * @param textures array of glTF texture interfaces
  89304. * @param materials array of glTF material interfaces
  89305. * @param imageData map of image file name to data
  89306. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89307. */
  89308. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89309. private _finishMaterial;
  89310. /**
  89311. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89312. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89313. * @param mimeType mime type to use for the textures
  89314. * @param images array of glTF image interfaces
  89315. * @param textures array of glTF texture interfaces
  89316. * @param materials array of glTF material interfaces
  89317. * @param imageData map of image file name to data
  89318. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89319. */
  89320. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89321. /**
  89322. * Converts an image typed array buffer to a base64 image
  89323. * @param buffer typed array buffer
  89324. * @param width width of the image
  89325. * @param height height of the image
  89326. * @param mimeType mimetype of the image
  89327. * @returns base64 image string
  89328. */
  89329. private _createBase64FromCanvasAsync;
  89330. /**
  89331. * Generates a white texture based on the specified width and height
  89332. * @param width width of the texture in pixels
  89333. * @param height height of the texture in pixels
  89334. * @param scene babylonjs scene
  89335. * @returns white texture
  89336. */
  89337. private _createWhiteTexture;
  89338. /**
  89339. * 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
  89340. * @param texture1 first texture to resize
  89341. * @param texture2 second texture to resize
  89342. * @param scene babylonjs scene
  89343. * @returns resized textures or null
  89344. */
  89345. private _resizeTexturesToSameDimensions;
  89346. /**
  89347. * Converts an array of pixels to a Float32Array
  89348. * Throws an error if the pixel format is not supported
  89349. * @param pixels - array buffer containing pixel values
  89350. * @returns Float32 of pixels
  89351. */
  89352. private _convertPixelArrayToFloat32;
  89353. /**
  89354. * Convert Specular Glossiness Textures to Metallic Roughness
  89355. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89356. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89357. * @param diffuseTexture texture used to store diffuse information
  89358. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89359. * @param factors specular glossiness material factors
  89360. * @param mimeType the mime type to use for the texture
  89361. * @returns pbr metallic roughness interface or null
  89362. */
  89363. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89364. /**
  89365. * Converts specular glossiness material properties to metallic roughness
  89366. * @param specularGlossiness interface with specular glossiness material properties
  89367. * @returns interface with metallic roughness material properties
  89368. */
  89369. private _convertSpecularGlossinessToMetallicRoughness;
  89370. /**
  89371. * Calculates the surface reflectance, independent of lighting conditions
  89372. * @param color Color source to calculate brightness from
  89373. * @returns number representing the perceived brightness, or zero if color is undefined
  89374. */
  89375. private _getPerceivedBrightness;
  89376. /**
  89377. * Returns the maximum color component value
  89378. * @param color
  89379. * @returns maximum color component value, or zero if color is null or undefined
  89380. */
  89381. private _getMaxComponent;
  89382. /**
  89383. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89384. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89385. * @param mimeType mime type to use for the textures
  89386. * @param images array of glTF image interfaces
  89387. * @param textures array of glTF texture interfaces
  89388. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89389. * @param imageData map of image file name to data
  89390. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89391. * @returns glTF PBR Metallic Roughness factors
  89392. */
  89393. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89394. private _getGLTFTextureSampler;
  89395. private _getGLTFTextureWrapMode;
  89396. private _getGLTFTextureWrapModesSampler;
  89397. /**
  89398. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89399. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89400. * @param mimeType mime type to use for the textures
  89401. * @param images array of glTF image interfaces
  89402. * @param textures array of glTF texture interfaces
  89403. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89404. * @param imageData map of image file name to data
  89405. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89406. * @returns glTF PBR Metallic Roughness factors
  89407. */
  89408. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89409. /**
  89410. * Converts a Babylon PBR Base Material to a glTF Material
  89411. * @param babylonPBRMaterial BJS PBR Base Material
  89412. * @param mimeType mime type to use for the textures
  89413. * @param images array of glTF image interfaces
  89414. * @param textures array of glTF texture interfaces
  89415. * @param materials array of glTF material interfaces
  89416. * @param imageData map of image file name to data
  89417. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89418. */
  89419. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89420. private setMetallicRoughnessPbrMaterial;
  89421. private getPixelsFromTexture;
  89422. /**
  89423. * Extracts a texture from a Babylon texture into file data and glTF data
  89424. * @param babylonTexture Babylon texture to extract
  89425. * @param mimeType Mime Type of the babylonTexture
  89426. * @return glTF texture info, or null if the texture format is not supported
  89427. */
  89428. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89429. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89430. /**
  89431. * Builds a texture from base64 string
  89432. * @param base64Texture base64 texture string
  89433. * @param baseTextureName Name to use for the texture
  89434. * @param mimeType image mime type for the texture
  89435. * @param images array of images
  89436. * @param textures array of textures
  89437. * @param imageData map of image data
  89438. * @returns glTF texture info, or null if the texture format is not supported
  89439. */
  89440. private _getTextureInfoFromBase64;
  89441. }
  89442. }
  89443. declare module BABYLON {
  89444. /**
  89445. * Class for holding and downloading glTF file data
  89446. */
  89447. export class GLTFData {
  89448. /**
  89449. * Object which contains the file name as the key and its data as the value
  89450. */
  89451. glTFFiles: {
  89452. [fileName: string]: string | Blob;
  89453. };
  89454. /**
  89455. * Initializes the glTF file object
  89456. */
  89457. constructor();
  89458. /**
  89459. * Downloads the glTF data as files based on their names and data
  89460. */
  89461. downloadFiles(): void;
  89462. }
  89463. }
  89464. declare module BABYLON {
  89465. /**
  89466. * Holds a collection of exporter options and parameters
  89467. */
  89468. export interface IExportOptions {
  89469. /**
  89470. * Function which indicates whether a babylon node should be exported or not
  89471. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89472. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89473. */
  89474. shouldExportNode?(node: Node): boolean;
  89475. /**
  89476. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89477. * @param metadata source metadata to read from
  89478. * @returns the data to store to glTF node extras
  89479. */
  89480. metadataSelector?(metadata: any): any;
  89481. /**
  89482. * The sample rate to bake animation curves
  89483. */
  89484. animationSampleRate?: number;
  89485. /**
  89486. * Begin serialization without waiting for the scene to be ready
  89487. */
  89488. exportWithoutWaitingForScene?: boolean;
  89489. /**
  89490. * Indicates if coordinate system swapping root nodes should be included in export
  89491. */
  89492. includeCoordinateSystemConversionNodes?: boolean;
  89493. }
  89494. /**
  89495. * Class for generating glTF data from a Babylon scene.
  89496. */
  89497. export class GLTF2Export {
  89498. /**
  89499. * Exports the geometry of the scene to .gltf file format asynchronously
  89500. * @param scene Babylon scene with scene hierarchy information
  89501. * @param filePrefix File prefix to use when generating the glTF file
  89502. * @param options Exporter options
  89503. * @returns Returns an object with a .gltf file and associates texture names
  89504. * as keys and their data and paths as values
  89505. */
  89506. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89507. private static _PreExportAsync;
  89508. private static _PostExportAsync;
  89509. /**
  89510. * Exports the geometry of the scene to .glb file format asychronously
  89511. * @param scene Babylon scene with scene hierarchy information
  89512. * @param filePrefix File prefix to use when generating glb file
  89513. * @param options Exporter options
  89514. * @returns Returns an object with a .glb filename as key and data as value
  89515. */
  89516. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89517. }
  89518. }
  89519. declare module BABYLON.GLTF2.Exporter {
  89520. /**
  89521. * @hidden
  89522. */
  89523. export class _GLTFUtilities {
  89524. /**
  89525. * Creates a buffer view based on the supplied arguments
  89526. * @param bufferIndex index value of the specified buffer
  89527. * @param byteOffset byte offset value
  89528. * @param byteLength byte length of the bufferView
  89529. * @param byteStride byte distance between conequential elements
  89530. * @param name name of the buffer view
  89531. * @returns bufferView for glTF
  89532. */
  89533. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89534. /**
  89535. * Creates an accessor based on the supplied arguments
  89536. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89537. * @param name The name of the accessor
  89538. * @param type The type of the accessor
  89539. * @param componentType The datatype of components in the attribute
  89540. * @param count The number of attributes referenced by this accessor
  89541. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89542. * @param min Minimum value of each component in this attribute
  89543. * @param max Maximum value of each component in this attribute
  89544. * @returns accessor for glTF
  89545. */
  89546. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89547. /**
  89548. * Calculates the minimum and maximum values of an array of position floats
  89549. * @param positions Positions array of a mesh
  89550. * @param vertexStart Starting vertex offset to calculate min and max values
  89551. * @param vertexCount Number of vertices to check for min and max values
  89552. * @returns min number array and max number array
  89553. */
  89554. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89555. min: number[];
  89556. max: number[];
  89557. };
  89558. /**
  89559. * Converts a new right-handed Vector3
  89560. * @param vector vector3 array
  89561. * @returns right-handed Vector3
  89562. */
  89563. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89564. /**
  89565. * Converts a Vector3 to right-handed
  89566. * @param vector Vector3 to convert to right-handed
  89567. */
  89568. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89569. /**
  89570. * Converts a three element number array to right-handed
  89571. * @param vector number array to convert to right-handed
  89572. */
  89573. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89574. /**
  89575. * Converts a new right-handed Vector3
  89576. * @param vector vector3 array
  89577. * @returns right-handed Vector3
  89578. */
  89579. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89580. /**
  89581. * Converts a Vector3 to right-handed
  89582. * @param vector Vector3 to convert to right-handed
  89583. */
  89584. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89585. /**
  89586. * Converts a three element number array to right-handed
  89587. * @param vector number array to convert to right-handed
  89588. */
  89589. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89590. /**
  89591. * Converts a Vector4 to right-handed
  89592. * @param vector Vector4 to convert to right-handed
  89593. */
  89594. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89595. /**
  89596. * Converts a Vector4 to right-handed
  89597. * @param vector Vector4 to convert to right-handed
  89598. */
  89599. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89600. /**
  89601. * Converts a Quaternion to right-handed
  89602. * @param quaternion Source quaternion to convert to right-handed
  89603. */
  89604. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89605. /**
  89606. * Converts a Quaternion to right-handed
  89607. * @param quaternion Source quaternion to convert to right-handed
  89608. */
  89609. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89610. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89611. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89612. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89613. }
  89614. }
  89615. declare module BABYLON.GLTF2.Exporter {
  89616. /**
  89617. * Converts Babylon Scene into glTF 2.0.
  89618. * @hidden
  89619. */
  89620. export class _Exporter {
  89621. /**
  89622. * Stores the glTF to export
  89623. */
  89624. _glTF: IGLTF;
  89625. /**
  89626. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89627. */
  89628. _bufferViews: IBufferView[];
  89629. /**
  89630. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89631. */
  89632. _accessors: IAccessor[];
  89633. /**
  89634. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89635. */
  89636. _nodes: INode[];
  89637. /**
  89638. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89639. */
  89640. private _scenes;
  89641. /**
  89642. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89643. */
  89644. private _meshes;
  89645. /**
  89646. * Stores all the generated material information, which represents the appearance of each primitive
  89647. */
  89648. _materials: IMaterial[];
  89649. _materialMap: {
  89650. [materialID: number]: number;
  89651. };
  89652. /**
  89653. * Stores all the generated texture information, which is referenced by glTF materials
  89654. */
  89655. _textures: ITexture[];
  89656. /**
  89657. * Stores all the generated image information, which is referenced by glTF textures
  89658. */
  89659. _images: IImage[];
  89660. /**
  89661. * Stores all the texture samplers
  89662. */
  89663. _samplers: ISampler[];
  89664. /**
  89665. * Stores all the generated glTF skins
  89666. */
  89667. _skins: ISkin[];
  89668. /**
  89669. * Stores all the generated animation samplers, which is referenced by glTF animations
  89670. */
  89671. /**
  89672. * Stores the animations for glTF models
  89673. */
  89674. private _animations;
  89675. /**
  89676. * Stores the total amount of bytes stored in the glTF buffer
  89677. */
  89678. private _totalByteLength;
  89679. /**
  89680. * Stores a reference to the Babylon scene containing the source geometry and material information
  89681. */
  89682. _babylonScene: Scene;
  89683. /**
  89684. * Stores a map of the image data, where the key is the file name and the value
  89685. * is the image data
  89686. */
  89687. _imageData: {
  89688. [fileName: string]: {
  89689. data: Uint8Array;
  89690. mimeType: ImageMimeType;
  89691. };
  89692. };
  89693. protected _orderedImageData: Array<{
  89694. data: Uint8Array;
  89695. mimeType: ImageMimeType;
  89696. }>;
  89697. /**
  89698. * Stores a map of the unique id of a node to its index in the node array
  89699. */
  89700. _nodeMap: {
  89701. [key: number]: number;
  89702. };
  89703. /**
  89704. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89705. */
  89706. _convertToRightHandedSystem: boolean;
  89707. /**
  89708. * Specifies if a Babylon node should be converted to right-handed on export
  89709. */
  89710. _convertToRightHandedSystemMap: {
  89711. [nodeId: number]: boolean;
  89712. };
  89713. _includeCoordinateSystemConversionNodes: boolean;
  89714. /**
  89715. * Baked animation sample rate
  89716. */
  89717. private _animationSampleRate;
  89718. private _options;
  89719. private _localEngine;
  89720. _glTFMaterialExporter: _GLTFMaterialExporter;
  89721. private _extensions;
  89722. private static _ExtensionNames;
  89723. private static _ExtensionFactories;
  89724. private _applyExtension;
  89725. private _applyExtensions;
  89726. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89727. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89728. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89729. [key: number]: number;
  89730. }): Promise<Nullable<INode>>;
  89731. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89732. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89733. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89734. private _forEachExtensions;
  89735. private _extensionsOnExporting;
  89736. /**
  89737. * Load glTF serializer extensions
  89738. */
  89739. private _loadExtensions;
  89740. /**
  89741. * Creates a glTF Exporter instance, which can accept optional exporter options
  89742. * @param babylonScene Babylon scene object
  89743. * @param options Options to modify the behavior of the exporter
  89744. */
  89745. constructor(babylonScene: Scene, options?: IExportOptions);
  89746. dispose(): void;
  89747. /**
  89748. * Registers a glTF exporter extension
  89749. * @param name Name of the extension to export
  89750. * @param factory The factory function that creates the exporter extension
  89751. */
  89752. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89753. /**
  89754. * Un-registers an exporter extension
  89755. * @param name The name fo the exporter extension
  89756. * @returns A boolean indicating whether the extension has been un-registered
  89757. */
  89758. static UnregisterExtension(name: string): boolean;
  89759. private reorderIndicesBasedOnPrimitiveMode;
  89760. /**
  89761. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89762. * clock-wise during export to glTF
  89763. * @param submesh BabylonJS submesh
  89764. * @param primitiveMode Primitive mode of the mesh
  89765. * @param sideOrientation the winding order of the submesh
  89766. * @param vertexBufferKind The type of vertex attribute
  89767. * @param meshAttributeArray The vertex attribute data
  89768. * @param byteOffset The offset to the binary data
  89769. * @param binaryWriter The binary data for the glTF file
  89770. * @param convertToRightHandedSystem Converts the values to right-handed
  89771. */
  89772. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89773. /**
  89774. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89775. * clock-wise during export to glTF
  89776. * @param submesh BabylonJS submesh
  89777. * @param primitiveMode Primitive mode of the mesh
  89778. * @param sideOrientation the winding order of the submesh
  89779. * @param vertexBufferKind The type of vertex attribute
  89780. * @param meshAttributeArray The vertex attribute data
  89781. * @param byteOffset The offset to the binary data
  89782. * @param binaryWriter The binary data for the glTF file
  89783. * @param convertToRightHandedSystem Converts the values to right-handed
  89784. */
  89785. private reorderTriangleFillMode;
  89786. /**
  89787. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89788. * clock-wise during export to glTF
  89789. * @param submesh BabylonJS submesh
  89790. * @param primitiveMode Primitive mode of the mesh
  89791. * @param sideOrientation the winding order of the submesh
  89792. * @param vertexBufferKind The type of vertex attribute
  89793. * @param meshAttributeArray The vertex attribute data
  89794. * @param byteOffset The offset to the binary data
  89795. * @param binaryWriter The binary data for the glTF file
  89796. * @param convertToRightHandedSystem Converts the values to right-handed
  89797. */
  89798. private reorderTriangleStripDrawMode;
  89799. /**
  89800. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89801. * clock-wise during export to glTF
  89802. * @param submesh BabylonJS submesh
  89803. * @param primitiveMode Primitive mode of the mesh
  89804. * @param sideOrientation the winding order of the submesh
  89805. * @param vertexBufferKind The type of vertex attribute
  89806. * @param meshAttributeArray The vertex attribute data
  89807. * @param byteOffset The offset to the binary data
  89808. * @param binaryWriter The binary data for the glTF file
  89809. * @param convertToRightHandedSystem Converts the values to right-handed
  89810. */
  89811. private reorderTriangleFanMode;
  89812. /**
  89813. * Writes the vertex attribute data to binary
  89814. * @param vertices The vertices to write to the binary writer
  89815. * @param byteOffset The offset into the binary writer to overwrite binary data
  89816. * @param vertexAttributeKind The vertex attribute type
  89817. * @param meshAttributeArray The vertex attribute data
  89818. * @param binaryWriter The writer containing the binary data
  89819. * @param convertToRightHandedSystem Converts the values to right-handed
  89820. */
  89821. private writeVertexAttributeData;
  89822. /**
  89823. * Writes mesh attribute data to a data buffer
  89824. * Returns the bytelength of the data
  89825. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89826. * @param meshAttributeArray Array containing the attribute data
  89827. * @param byteStride Specifies the space between data
  89828. * @param binaryWriter The buffer to write the binary data to
  89829. * @param convertToRightHandedSystem Converts the values to right-handed
  89830. */
  89831. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89832. /**
  89833. * Writes mesh attribute data to a data buffer
  89834. * Returns the bytelength of the data
  89835. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89836. * @param meshAttributeArray Array containing the attribute data
  89837. * @param byteStride Specifies the space between data
  89838. * @param binaryWriter The buffer to write the binary data to
  89839. * @param convertToRightHandedSystem Converts the values to right-handed
  89840. */
  89841. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89842. /**
  89843. * Generates glTF json data
  89844. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89845. * @param glTFPrefix Text to use when prefixing a glTF file
  89846. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89847. * @returns json data as string
  89848. */
  89849. private generateJSON;
  89850. /**
  89851. * Generates data for .gltf and .bin files based on the glTF prefix string
  89852. * @param glTFPrefix Text to use when prefixing a glTF file
  89853. * @param dispose Dispose the exporter
  89854. * @returns GLTFData with glTF file data
  89855. */
  89856. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89857. /**
  89858. * Creates a binary buffer for glTF
  89859. * @returns array buffer for binary data
  89860. */
  89861. private _generateBinaryAsync;
  89862. /**
  89863. * Pads the number to a multiple of 4
  89864. * @param num number to pad
  89865. * @returns padded number
  89866. */
  89867. private _getPadding;
  89868. /**
  89869. * @hidden
  89870. */
  89871. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89872. /**
  89873. * Sets the TRS for each node
  89874. * @param node glTF Node for storing the transformation data
  89875. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89876. * @param convertToRightHandedSystem Converts the values to right-handed
  89877. */
  89878. private setNodeTransformation;
  89879. private getVertexBufferFromMesh;
  89880. /**
  89881. * Creates a bufferview based on the vertices type for the Babylon mesh
  89882. * @param kind Indicates the type of vertices data
  89883. * @param componentType Indicates the numerical type used to store the data
  89884. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89885. * @param binaryWriter The buffer to write the bufferview data to
  89886. * @param convertToRightHandedSystem Converts the values to right-handed
  89887. */
  89888. private createBufferViewKind;
  89889. /**
  89890. * Creates a bufferview based on the vertices type for the Babylon mesh
  89891. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89892. * @param babylonMorphTarget the morph target to be exported
  89893. * @param binaryWriter The buffer to write the bufferview data to
  89894. * @param convertToRightHandedSystem Converts the values to right-handed
  89895. */
  89896. private setMorphTargetAttributes;
  89897. /**
  89898. * The primitive mode of the Babylon mesh
  89899. * @param babylonMesh The BabylonJS mesh
  89900. */
  89901. private getMeshPrimitiveMode;
  89902. /**
  89903. * Sets the primitive mode of the glTF mesh primitive
  89904. * @param meshPrimitive glTF mesh primitive
  89905. * @param primitiveMode The primitive mode
  89906. */
  89907. private setPrimitiveMode;
  89908. /**
  89909. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89910. * @param meshPrimitive glTF mesh primitive
  89911. * @param attributeKind vertex attribute
  89912. * @returns boolean specifying if uv coordinates are present
  89913. */
  89914. private setAttributeKind;
  89915. /**
  89916. * Sets data for the primitive attributes of each submesh
  89917. * @param mesh glTF Mesh object to store the primitive attribute information
  89918. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89919. * @param binaryWriter Buffer to write the attribute data to
  89920. * @param convertToRightHandedSystem Converts the values to right-handed
  89921. */
  89922. private setPrimitiveAttributesAsync;
  89923. /**
  89924. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89925. * @param node The node to check
  89926. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89927. */
  89928. private isBabylonCoordinateSystemConvertingNode;
  89929. /**
  89930. * Creates a glTF scene based on the array of meshes
  89931. * Returns the the total byte offset
  89932. * @param babylonScene Babylon scene to get the mesh data from
  89933. * @param binaryWriter Buffer to write binary data to
  89934. */
  89935. private createSceneAsync;
  89936. /**
  89937. * Creates a mapping of Node unique id to node index and handles animations
  89938. * @param babylonScene Babylon Scene
  89939. * @param nodes Babylon transform nodes
  89940. * @param binaryWriter Buffer to write binary data to
  89941. * @returns Node mapping of unique id to index
  89942. */
  89943. private createNodeMapAndAnimationsAsync;
  89944. /**
  89945. * Creates a glTF node from a Babylon mesh
  89946. * @param babylonMesh Source Babylon mesh
  89947. * @param binaryWriter Buffer for storing geometry data
  89948. * @param convertToRightHandedSystem Converts the values to right-handed
  89949. * @param nodeMap Node mapping of unique id to glTF node index
  89950. * @returns glTF node
  89951. */
  89952. private createNodeAsync;
  89953. /**
  89954. * Creates a glTF skin from a Babylon skeleton
  89955. * @param babylonScene Babylon Scene
  89956. * @param nodes Babylon transform nodes
  89957. * @param binaryWriter Buffer to write binary data to
  89958. * @returns Node mapping of unique id to index
  89959. */
  89960. private createSkinsAsync;
  89961. }
  89962. /**
  89963. * @hidden
  89964. *
  89965. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89966. */
  89967. export class _BinaryWriter {
  89968. /**
  89969. * Array buffer which stores all binary data
  89970. */
  89971. private _arrayBuffer;
  89972. /**
  89973. * View of the array buffer
  89974. */
  89975. private _dataView;
  89976. /**
  89977. * byte offset of data in array buffer
  89978. */
  89979. private _byteOffset;
  89980. /**
  89981. * Initialize binary writer with an initial byte length
  89982. * @param byteLength Initial byte length of the array buffer
  89983. */
  89984. constructor(byteLength: number);
  89985. /**
  89986. * Resize the array buffer to the specified byte length
  89987. * @param byteLength
  89988. */
  89989. private resizeBuffer;
  89990. /**
  89991. * Get an array buffer with the length of the byte offset
  89992. * @returns ArrayBuffer resized to the byte offset
  89993. */
  89994. getArrayBuffer(): ArrayBuffer;
  89995. /**
  89996. * Get the byte offset of the array buffer
  89997. * @returns byte offset
  89998. */
  89999. getByteOffset(): number;
  90000. /**
  90001. * Stores an UInt8 in the array buffer
  90002. * @param entry
  90003. * @param byteOffset If defined, specifies where to set the value as an offset.
  90004. */
  90005. setUInt8(entry: number, byteOffset?: number): void;
  90006. /**
  90007. * Stores an UInt16 in the array buffer
  90008. * @param entry
  90009. * @param byteOffset If defined, specifies where to set the value as an offset.
  90010. */
  90011. setUInt16(entry: number, byteOffset?: number): void;
  90012. /**
  90013. * Gets an UInt32 in the array buffer
  90014. * @param entry
  90015. * @param byteOffset If defined, specifies where to set the value as an offset.
  90016. */
  90017. getUInt32(byteOffset: number): number;
  90018. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90019. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90020. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90021. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90022. /**
  90023. * Stores a Float32 in the array buffer
  90024. * @param entry
  90025. */
  90026. setFloat32(entry: number, byteOffset?: number): void;
  90027. /**
  90028. * Stores an UInt32 in the array buffer
  90029. * @param entry
  90030. * @param byteOffset If defined, specifies where to set the value as an offset.
  90031. */
  90032. setUInt32(entry: number, byteOffset?: number): void;
  90033. }
  90034. }
  90035. declare module BABYLON.GLTF2.Exporter {
  90036. /**
  90037. * @hidden
  90038. * Interface to store animation data.
  90039. */
  90040. export interface _IAnimationData {
  90041. /**
  90042. * Keyframe data.
  90043. */
  90044. inputs: number[];
  90045. /**
  90046. * Value data.
  90047. */
  90048. outputs: number[][];
  90049. /**
  90050. * Animation interpolation data.
  90051. */
  90052. samplerInterpolation: AnimationSamplerInterpolation;
  90053. /**
  90054. * Minimum keyframe value.
  90055. */
  90056. inputsMin: number;
  90057. /**
  90058. * Maximum keyframe value.
  90059. */
  90060. inputsMax: number;
  90061. }
  90062. /**
  90063. * @hidden
  90064. */
  90065. export interface _IAnimationInfo {
  90066. /**
  90067. * The target channel for the animation
  90068. */
  90069. animationChannelTargetPath: AnimationChannelTargetPath;
  90070. /**
  90071. * The glTF accessor type for the data.
  90072. */
  90073. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90074. /**
  90075. * Specifies if quaternions should be used.
  90076. */
  90077. useQuaternion: boolean;
  90078. }
  90079. /**
  90080. * @hidden
  90081. * Utility class for generating glTF animation data from BabylonJS.
  90082. */
  90083. export class _GLTFAnimation {
  90084. /**
  90085. * @ignore
  90086. *
  90087. * Creates glTF channel animation from BabylonJS animation.
  90088. * @param babylonTransformNode - BabylonJS mesh.
  90089. * @param animation - animation.
  90090. * @param animationChannelTargetPath - The target animation channel.
  90091. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90092. * @param useQuaternion - Specifies if quaternions are used.
  90093. * @returns nullable IAnimationData
  90094. */
  90095. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90096. private static _DeduceAnimationInfo;
  90097. /**
  90098. * @ignore
  90099. * Create node animations from the transform node animations
  90100. * @param babylonNode
  90101. * @param runtimeGLTFAnimation
  90102. * @param idleGLTFAnimations
  90103. * @param nodeMap
  90104. * @param nodes
  90105. * @param binaryWriter
  90106. * @param bufferViews
  90107. * @param accessors
  90108. * @param convertToRightHandedSystem
  90109. * @param animationSampleRate
  90110. */
  90111. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90112. [key: number]: number;
  90113. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90114. /**
  90115. * @ignore
  90116. * Create individual morph animations from the mesh's morph target animation tracks
  90117. * @param babylonNode
  90118. * @param runtimeGLTFAnimation
  90119. * @param idleGLTFAnimations
  90120. * @param nodeMap
  90121. * @param nodes
  90122. * @param binaryWriter
  90123. * @param bufferViews
  90124. * @param accessors
  90125. * @param convertToRightHandedSystem
  90126. * @param animationSampleRate
  90127. */
  90128. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90129. [key: number]: number;
  90130. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90131. /**
  90132. * @ignore
  90133. * Create node and morph animations from the animation groups
  90134. * @param babylonScene
  90135. * @param glTFAnimations
  90136. * @param nodeMap
  90137. * @param nodes
  90138. * @param binaryWriter
  90139. * @param bufferViews
  90140. * @param accessors
  90141. * @param convertToRightHandedSystemMap
  90142. * @param animationSampleRate
  90143. */
  90144. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90145. [key: number]: number;
  90146. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90147. [nodeId: number]: boolean;
  90148. }, animationSampleRate: number): void;
  90149. private static AddAnimation;
  90150. /**
  90151. * Create a baked animation
  90152. * @param babylonTransformNode BabylonJS mesh
  90153. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90154. * @param animationChannelTargetPath animation target channel
  90155. * @param minFrame minimum animation frame
  90156. * @param maxFrame maximum animation frame
  90157. * @param fps frames per second of the animation
  90158. * @param inputs input key frames of the animation
  90159. * @param outputs output key frame data of the animation
  90160. * @param convertToRightHandedSystem converts the values to right-handed
  90161. * @param useQuaternion specifies if quaternions should be used
  90162. */
  90163. private static _CreateBakedAnimation;
  90164. private static _ConvertFactorToVector3OrQuaternion;
  90165. private static _SetInterpolatedValue;
  90166. /**
  90167. * Creates linear animation from the animation key frames
  90168. * @param babylonTransformNode BabylonJS mesh
  90169. * @param animation BabylonJS animation
  90170. * @param animationChannelTargetPath The target animation channel
  90171. * @param frameDelta The difference between the last and first frame of the animation
  90172. * @param inputs Array to store the key frame times
  90173. * @param outputs Array to store the key frame data
  90174. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90175. * @param useQuaternion Specifies if quaternions are used in the animation
  90176. */
  90177. private static _CreateLinearOrStepAnimation;
  90178. /**
  90179. * Creates cubic spline animation from the animation key frames
  90180. * @param babylonTransformNode BabylonJS mesh
  90181. * @param animation BabylonJS animation
  90182. * @param animationChannelTargetPath The target animation channel
  90183. * @param frameDelta The difference between the last and first frame of the animation
  90184. * @param inputs Array to store the key frame times
  90185. * @param outputs Array to store the key frame data
  90186. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90187. * @param useQuaternion Specifies if quaternions are used in the animation
  90188. */
  90189. private static _CreateCubicSplineAnimation;
  90190. private static _GetBasePositionRotationOrScale;
  90191. /**
  90192. * Adds a key frame value
  90193. * @param keyFrame
  90194. * @param animation
  90195. * @param outputs
  90196. * @param animationChannelTargetPath
  90197. * @param basePositionRotationOrScale
  90198. * @param convertToRightHandedSystem
  90199. * @param useQuaternion
  90200. */
  90201. private static _AddKeyframeValue;
  90202. /**
  90203. * Determine the interpolation based on the key frames
  90204. * @param keyFrames
  90205. * @param animationChannelTargetPath
  90206. * @param useQuaternion
  90207. */
  90208. private static _DeduceInterpolation;
  90209. /**
  90210. * Adds an input tangent or output tangent to the output data
  90211. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90212. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90213. * @param outputs The animation data by keyframe
  90214. * @param animationChannelTargetPath The target animation channel
  90215. * @param interpolation The interpolation type
  90216. * @param keyFrame The key frame with the animation data
  90217. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90218. * @param useQuaternion Specifies if quaternions are used
  90219. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90220. */
  90221. private static AddSplineTangent;
  90222. /**
  90223. * Get the minimum and maximum key frames' frame values
  90224. * @param keyFrames animation key frames
  90225. * @returns the minimum and maximum key frame value
  90226. */
  90227. private static calculateMinMaxKeyFrames;
  90228. }
  90229. }
  90230. declare module BABYLON.GLTF2.Exporter {
  90231. /** @hidden */
  90232. export var textureTransformPixelShader: {
  90233. name: string;
  90234. shader: string;
  90235. };
  90236. }
  90237. declare module BABYLON.GLTF2.Exporter.Extensions {
  90238. /**
  90239. * @hidden
  90240. */
  90241. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90242. private _recordedTextures;
  90243. /** Name of this extension */
  90244. readonly name: string;
  90245. /** Defines whether this extension is enabled */
  90246. enabled: boolean;
  90247. /** Defines whether this extension is required */
  90248. required: boolean;
  90249. /** Reference to the glTF exporter */
  90250. private _wasUsed;
  90251. constructor(exporter: _Exporter);
  90252. dispose(): void;
  90253. /** @hidden */
  90254. get wasUsed(): boolean;
  90255. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90256. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90257. /**
  90258. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90259. * @param babylonTexture
  90260. * @param offset
  90261. * @param rotation
  90262. * @param scale
  90263. * @param scene
  90264. */
  90265. private _textureTransformTextureAsync;
  90266. }
  90267. }
  90268. declare module BABYLON.GLTF2.Exporter.Extensions {
  90269. /**
  90270. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90271. */
  90272. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90273. /** The name of this extension. */
  90274. readonly name: string;
  90275. /** Defines whether this extension is enabled. */
  90276. enabled: boolean;
  90277. /** Defines whether this extension is required */
  90278. required: boolean;
  90279. /** Reference to the glTF exporter */
  90280. private _exporter;
  90281. private _lights;
  90282. /** @hidden */
  90283. constructor(exporter: _Exporter);
  90284. /** @hidden */
  90285. dispose(): void;
  90286. /** @hidden */
  90287. get wasUsed(): boolean;
  90288. /** @hidden */
  90289. onExporting(): void;
  90290. /**
  90291. * Define this method to modify the default behavior when exporting a node
  90292. * @param context The context when exporting the node
  90293. * @param node glTF node
  90294. * @param babylonNode BabylonJS node
  90295. * @param nodeMap Node mapping of unique id to glTF node index
  90296. * @returns nullable INode promise
  90297. */
  90298. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90299. [key: number]: number;
  90300. }): Promise<Nullable<INode>>;
  90301. }
  90302. }
  90303. declare module BABYLON.GLTF2.Exporter.Extensions {
  90304. /**
  90305. * @hidden
  90306. */
  90307. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90308. /** Name of this extension */
  90309. readonly name: string;
  90310. /** Defines whether this extension is enabled */
  90311. enabled: boolean;
  90312. /** Defines whether this extension is required */
  90313. required: boolean;
  90314. /** Reference to the glTF exporter */
  90315. private _textureInfos;
  90316. private _exportedTextures;
  90317. private _wasUsed;
  90318. constructor(exporter: _Exporter);
  90319. dispose(): void;
  90320. /** @hidden */
  90321. get wasUsed(): boolean;
  90322. private _getTextureIndex;
  90323. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90324. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90325. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90326. }
  90327. }
  90328. declare module BABYLON.GLTF2.Exporter.Extensions {
  90329. /**
  90330. * @hidden
  90331. */
  90332. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90333. /** Name of this extension */
  90334. readonly name: string;
  90335. /** Defines whether this extension is enabled */
  90336. enabled: boolean;
  90337. /** Defines whether this extension is required */
  90338. required: boolean;
  90339. private _wasUsed;
  90340. constructor(exporter: _Exporter);
  90341. /** @hidden */
  90342. get wasUsed(): boolean;
  90343. dispose(): void;
  90344. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90345. }
  90346. }
  90347. declare module BABYLON {
  90348. /**
  90349. * Class for generating STL data from a Babylon scene.
  90350. */
  90351. export class STLExport {
  90352. /**
  90353. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90354. * @param meshes list defines the mesh to serialize
  90355. * @param download triggers the automatic download of the file.
  90356. * @param fileName changes the downloads fileName.
  90357. * @param binary changes the STL to a binary type.
  90358. * @param isLittleEndian toggle for binary type exporter.
  90359. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90360. * @returns the STL as UTF8 string
  90361. */
  90362. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90363. }
  90364. }
  90365. declare module "babylonjs-gltf2interface" {
  90366. export = BABYLON.GLTF2;
  90367. }
  90368. /**
  90369. * Module for glTF 2.0 Interface
  90370. */
  90371. declare module BABYLON.GLTF2 {
  90372. /**
  90373. * The datatype of the components in the attribute
  90374. */
  90375. const enum AccessorComponentType {
  90376. /**
  90377. * Byte
  90378. */
  90379. BYTE = 5120,
  90380. /**
  90381. * Unsigned Byte
  90382. */
  90383. UNSIGNED_BYTE = 5121,
  90384. /**
  90385. * Short
  90386. */
  90387. SHORT = 5122,
  90388. /**
  90389. * Unsigned Short
  90390. */
  90391. UNSIGNED_SHORT = 5123,
  90392. /**
  90393. * Unsigned Int
  90394. */
  90395. UNSIGNED_INT = 5125,
  90396. /**
  90397. * Float
  90398. */
  90399. FLOAT = 5126,
  90400. }
  90401. /**
  90402. * Specifies if the attirbute is a scalar, vector, or matrix
  90403. */
  90404. const enum AccessorType {
  90405. /**
  90406. * Scalar
  90407. */
  90408. SCALAR = "SCALAR",
  90409. /**
  90410. * Vector2
  90411. */
  90412. VEC2 = "VEC2",
  90413. /**
  90414. * Vector3
  90415. */
  90416. VEC3 = "VEC3",
  90417. /**
  90418. * Vector4
  90419. */
  90420. VEC4 = "VEC4",
  90421. /**
  90422. * Matrix2x2
  90423. */
  90424. MAT2 = "MAT2",
  90425. /**
  90426. * Matrix3x3
  90427. */
  90428. MAT3 = "MAT3",
  90429. /**
  90430. * Matrix4x4
  90431. */
  90432. MAT4 = "MAT4",
  90433. }
  90434. /**
  90435. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90436. */
  90437. const enum AnimationChannelTargetPath {
  90438. /**
  90439. * Translation
  90440. */
  90441. TRANSLATION = "translation",
  90442. /**
  90443. * Rotation
  90444. */
  90445. ROTATION = "rotation",
  90446. /**
  90447. * Scale
  90448. */
  90449. SCALE = "scale",
  90450. /**
  90451. * Weights
  90452. */
  90453. WEIGHTS = "weights",
  90454. }
  90455. /**
  90456. * Interpolation algorithm
  90457. */
  90458. const enum AnimationSamplerInterpolation {
  90459. /**
  90460. * The animated values are linearly interpolated between keyframes
  90461. */
  90462. LINEAR = "LINEAR",
  90463. /**
  90464. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90465. */
  90466. STEP = "STEP",
  90467. /**
  90468. * The animation's interpolation is computed using a cubic spline with specified tangents
  90469. */
  90470. CUBICSPLINE = "CUBICSPLINE",
  90471. }
  90472. /**
  90473. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90474. */
  90475. const enum CameraType {
  90476. /**
  90477. * A perspective camera containing properties to create a perspective projection matrix
  90478. */
  90479. PERSPECTIVE = "perspective",
  90480. /**
  90481. * An orthographic camera containing properties to create an orthographic projection matrix
  90482. */
  90483. ORTHOGRAPHIC = "orthographic",
  90484. }
  90485. /**
  90486. * The mime-type of the image
  90487. */
  90488. const enum ImageMimeType {
  90489. /**
  90490. * JPEG Mime-type
  90491. */
  90492. JPEG = "image/jpeg",
  90493. /**
  90494. * PNG Mime-type
  90495. */
  90496. PNG = "image/png",
  90497. }
  90498. /**
  90499. * The alpha rendering mode of the material
  90500. */
  90501. const enum MaterialAlphaMode {
  90502. /**
  90503. * The alpha value is ignored and the rendered output is fully opaque
  90504. */
  90505. OPAQUE = "OPAQUE",
  90506. /**
  90507. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90508. */
  90509. MASK = "MASK",
  90510. /**
  90511. * 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)
  90512. */
  90513. BLEND = "BLEND",
  90514. }
  90515. /**
  90516. * The type of the primitives to render
  90517. */
  90518. const enum MeshPrimitiveMode {
  90519. /**
  90520. * Points
  90521. */
  90522. POINTS = 0,
  90523. /**
  90524. * Lines
  90525. */
  90526. LINES = 1,
  90527. /**
  90528. * Line Loop
  90529. */
  90530. LINE_LOOP = 2,
  90531. /**
  90532. * Line Strip
  90533. */
  90534. LINE_STRIP = 3,
  90535. /**
  90536. * Triangles
  90537. */
  90538. TRIANGLES = 4,
  90539. /**
  90540. * Triangle Strip
  90541. */
  90542. TRIANGLE_STRIP = 5,
  90543. /**
  90544. * Triangle Fan
  90545. */
  90546. TRIANGLE_FAN = 6,
  90547. }
  90548. /**
  90549. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90550. */
  90551. const enum TextureMagFilter {
  90552. /**
  90553. * Nearest
  90554. */
  90555. NEAREST = 9728,
  90556. /**
  90557. * Linear
  90558. */
  90559. LINEAR = 9729,
  90560. }
  90561. /**
  90562. * Minification filter. All valid values correspond to WebGL enums
  90563. */
  90564. const enum TextureMinFilter {
  90565. /**
  90566. * Nearest
  90567. */
  90568. NEAREST = 9728,
  90569. /**
  90570. * Linear
  90571. */
  90572. LINEAR = 9729,
  90573. /**
  90574. * Nearest Mip-Map Nearest
  90575. */
  90576. NEAREST_MIPMAP_NEAREST = 9984,
  90577. /**
  90578. * Linear Mipmap Nearest
  90579. */
  90580. LINEAR_MIPMAP_NEAREST = 9985,
  90581. /**
  90582. * Nearest Mipmap Linear
  90583. */
  90584. NEAREST_MIPMAP_LINEAR = 9986,
  90585. /**
  90586. * Linear Mipmap Linear
  90587. */
  90588. LINEAR_MIPMAP_LINEAR = 9987,
  90589. }
  90590. /**
  90591. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90592. */
  90593. const enum TextureWrapMode {
  90594. /**
  90595. * Clamp to Edge
  90596. */
  90597. CLAMP_TO_EDGE = 33071,
  90598. /**
  90599. * Mirrored Repeat
  90600. */
  90601. MIRRORED_REPEAT = 33648,
  90602. /**
  90603. * Repeat
  90604. */
  90605. REPEAT = 10497,
  90606. }
  90607. /**
  90608. * glTF Property
  90609. */
  90610. interface IProperty {
  90611. /**
  90612. * Dictionary object with extension-specific objects
  90613. */
  90614. extensions?: {
  90615. [key: string]: any;
  90616. };
  90617. /**
  90618. * Application-Specific data
  90619. */
  90620. extras?: any;
  90621. }
  90622. /**
  90623. * glTF Child of Root Property
  90624. */
  90625. interface IChildRootProperty extends IProperty {
  90626. /**
  90627. * The user-defined name of this object
  90628. */
  90629. name?: string;
  90630. }
  90631. /**
  90632. * Indices of those attributes that deviate from their initialization value
  90633. */
  90634. interface IAccessorSparseIndices extends IProperty {
  90635. /**
  90636. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90637. */
  90638. bufferView: number;
  90639. /**
  90640. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90641. */
  90642. byteOffset?: number;
  90643. /**
  90644. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90645. */
  90646. componentType: AccessorComponentType;
  90647. }
  90648. /**
  90649. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90650. */
  90651. interface IAccessorSparseValues extends IProperty {
  90652. /**
  90653. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90654. */
  90655. bufferView: number;
  90656. /**
  90657. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90658. */
  90659. byteOffset?: number;
  90660. }
  90661. /**
  90662. * Sparse storage of attributes that deviate from their initialization value
  90663. */
  90664. interface IAccessorSparse extends IProperty {
  90665. /**
  90666. * The number of attributes encoded in this sparse accessor
  90667. */
  90668. count: number;
  90669. /**
  90670. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90671. */
  90672. indices: IAccessorSparseIndices;
  90673. /**
  90674. * 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
  90675. */
  90676. values: IAccessorSparseValues;
  90677. }
  90678. /**
  90679. * 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
  90680. */
  90681. interface IAccessor extends IChildRootProperty {
  90682. /**
  90683. * The index of the bufferview
  90684. */
  90685. bufferView?: number;
  90686. /**
  90687. * The offset relative to the start of the bufferView in bytes
  90688. */
  90689. byteOffset?: number;
  90690. /**
  90691. * The datatype of components in the attribute
  90692. */
  90693. componentType: AccessorComponentType;
  90694. /**
  90695. * Specifies whether integer data values should be normalized
  90696. */
  90697. normalized?: boolean;
  90698. /**
  90699. * The number of attributes referenced by this accessor
  90700. */
  90701. count: number;
  90702. /**
  90703. * Specifies if the attribute is a scalar, vector, or matrix
  90704. */
  90705. type: AccessorType;
  90706. /**
  90707. * Maximum value of each component in this attribute
  90708. */
  90709. max?: number[];
  90710. /**
  90711. * Minimum value of each component in this attribute
  90712. */
  90713. min?: number[];
  90714. /**
  90715. * Sparse storage of attributes that deviate from their initialization value
  90716. */
  90717. sparse?: IAccessorSparse;
  90718. }
  90719. /**
  90720. * Targets an animation's sampler at a node's property
  90721. */
  90722. interface IAnimationChannel extends IProperty {
  90723. /**
  90724. * The index of a sampler in this animation used to compute the value for the target
  90725. */
  90726. sampler: number;
  90727. /**
  90728. * The index of the node and TRS property to target
  90729. */
  90730. target: IAnimationChannelTarget;
  90731. }
  90732. /**
  90733. * The index of the node and TRS property that an animation channel targets
  90734. */
  90735. interface IAnimationChannelTarget extends IProperty {
  90736. /**
  90737. * The index of the node to target
  90738. */
  90739. node: number;
  90740. /**
  90741. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90742. */
  90743. path: AnimationChannelTargetPath;
  90744. }
  90745. /**
  90746. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90747. */
  90748. interface IAnimationSampler extends IProperty {
  90749. /**
  90750. * The index of an accessor containing keyframe input values, e.g., time
  90751. */
  90752. input: number;
  90753. /**
  90754. * Interpolation algorithm
  90755. */
  90756. interpolation?: AnimationSamplerInterpolation;
  90757. /**
  90758. * The index of an accessor, containing keyframe output values
  90759. */
  90760. output: number;
  90761. }
  90762. /**
  90763. * A keyframe animation
  90764. */
  90765. interface IAnimation extends IChildRootProperty {
  90766. /**
  90767. * An array of channels, each of which targets an animation's sampler at a node's property
  90768. */
  90769. channels: IAnimationChannel[];
  90770. /**
  90771. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90772. */
  90773. samplers: IAnimationSampler[];
  90774. }
  90775. /**
  90776. * Metadata about the glTF asset
  90777. */
  90778. interface IAsset extends IChildRootProperty {
  90779. /**
  90780. * A copyright message suitable for display to credit the content creator
  90781. */
  90782. copyright?: string;
  90783. /**
  90784. * Tool that generated this glTF model. Useful for debugging
  90785. */
  90786. generator?: string;
  90787. /**
  90788. * The glTF version that this asset targets
  90789. */
  90790. version: string;
  90791. /**
  90792. * The minimum glTF version that this asset targets
  90793. */
  90794. minVersion?: string;
  90795. }
  90796. /**
  90797. * A buffer points to binary geometry, animation, or skins
  90798. */
  90799. interface IBuffer extends IChildRootProperty {
  90800. /**
  90801. * 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
  90802. */
  90803. uri?: string;
  90804. /**
  90805. * The length of the buffer in bytes
  90806. */
  90807. byteLength: number;
  90808. }
  90809. /**
  90810. * A view into a buffer generally representing a subset of the buffer
  90811. */
  90812. interface IBufferView extends IChildRootProperty {
  90813. /**
  90814. * The index of the buffer
  90815. */
  90816. buffer: number;
  90817. /**
  90818. * The offset into the buffer in bytes
  90819. */
  90820. byteOffset?: number;
  90821. /**
  90822. * The lenth of the bufferView in bytes
  90823. */
  90824. byteLength: number;
  90825. /**
  90826. * The stride, in bytes
  90827. */
  90828. byteStride?: number;
  90829. }
  90830. /**
  90831. * An orthographic camera containing properties to create an orthographic projection matrix
  90832. */
  90833. interface ICameraOrthographic extends IProperty {
  90834. /**
  90835. * The floating-point horizontal magnification of the view. Must not be zero
  90836. */
  90837. xmag: number;
  90838. /**
  90839. * The floating-point vertical magnification of the view. Must not be zero
  90840. */
  90841. ymag: number;
  90842. /**
  90843. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90844. */
  90845. zfar: number;
  90846. /**
  90847. * The floating-point distance to the near clipping plane
  90848. */
  90849. znear: number;
  90850. }
  90851. /**
  90852. * A perspective camera containing properties to create a perspective projection matrix
  90853. */
  90854. interface ICameraPerspective extends IProperty {
  90855. /**
  90856. * The floating-point aspect ratio of the field of view
  90857. */
  90858. aspectRatio?: number;
  90859. /**
  90860. * The floating-point vertical field of view in radians
  90861. */
  90862. yfov: number;
  90863. /**
  90864. * The floating-point distance to the far clipping plane
  90865. */
  90866. zfar?: number;
  90867. /**
  90868. * The floating-point distance to the near clipping plane
  90869. */
  90870. znear: number;
  90871. }
  90872. /**
  90873. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90874. */
  90875. interface ICamera extends IChildRootProperty {
  90876. /**
  90877. * An orthographic camera containing properties to create an orthographic projection matrix
  90878. */
  90879. orthographic?: ICameraOrthographic;
  90880. /**
  90881. * A perspective camera containing properties to create a perspective projection matrix
  90882. */
  90883. perspective?: ICameraPerspective;
  90884. /**
  90885. * Specifies if the camera uses a perspective or orthographic projection
  90886. */
  90887. type: CameraType;
  90888. }
  90889. /**
  90890. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90891. */
  90892. interface IImage extends IChildRootProperty {
  90893. /**
  90894. * 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
  90895. */
  90896. uri?: string;
  90897. /**
  90898. * The image's MIME type
  90899. */
  90900. mimeType?: ImageMimeType;
  90901. /**
  90902. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90903. */
  90904. bufferView?: number;
  90905. }
  90906. /**
  90907. * Material Normal Texture Info
  90908. */
  90909. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90910. /**
  90911. * The scalar multiplier applied to each normal vector of the normal texture
  90912. */
  90913. scale?: number;
  90914. }
  90915. /**
  90916. * Material Occlusion Texture Info
  90917. */
  90918. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90919. /**
  90920. * A scalar multiplier controlling the amount of occlusion applied
  90921. */
  90922. strength?: number;
  90923. }
  90924. /**
  90925. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90926. */
  90927. interface IMaterialPbrMetallicRoughness {
  90928. /**
  90929. * The material's base color factor
  90930. */
  90931. baseColorFactor?: number[];
  90932. /**
  90933. * The base color texture
  90934. */
  90935. baseColorTexture?: ITextureInfo;
  90936. /**
  90937. * The metalness of the material
  90938. */
  90939. metallicFactor?: number;
  90940. /**
  90941. * The roughness of the material
  90942. */
  90943. roughnessFactor?: number;
  90944. /**
  90945. * The metallic-roughness texture
  90946. */
  90947. metallicRoughnessTexture?: ITextureInfo;
  90948. }
  90949. /**
  90950. * The material appearance of a primitive
  90951. */
  90952. interface IMaterial extends IChildRootProperty {
  90953. /**
  90954. * 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
  90955. */
  90956. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90957. /**
  90958. * The normal map texture
  90959. */
  90960. normalTexture?: IMaterialNormalTextureInfo;
  90961. /**
  90962. * The occlusion map texture
  90963. */
  90964. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90965. /**
  90966. * The emissive map texture
  90967. */
  90968. emissiveTexture?: ITextureInfo;
  90969. /**
  90970. * 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
  90971. */
  90972. emissiveFactor?: number[];
  90973. /**
  90974. * The alpha rendering mode of the material
  90975. */
  90976. alphaMode?: MaterialAlphaMode;
  90977. /**
  90978. * The alpha cutoff value of the material
  90979. */
  90980. alphaCutoff?: number;
  90981. /**
  90982. * Specifies whether the material is double sided
  90983. */
  90984. doubleSided?: boolean;
  90985. }
  90986. /**
  90987. * Geometry to be rendered with the given material
  90988. */
  90989. interface IMeshPrimitive extends IProperty {
  90990. /**
  90991. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90992. */
  90993. attributes: {
  90994. [name: string]: number;
  90995. };
  90996. /**
  90997. * The index of the accessor that contains the indices
  90998. */
  90999. indices?: number;
  91000. /**
  91001. * The index of the material to apply to this primitive when rendering
  91002. */
  91003. material?: number;
  91004. /**
  91005. * The type of primitives to render. All valid values correspond to WebGL enums
  91006. */
  91007. mode?: MeshPrimitiveMode;
  91008. /**
  91009. * 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
  91010. */
  91011. targets?: {
  91012. [name: string]: number;
  91013. }[];
  91014. }
  91015. /**
  91016. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91017. */
  91018. interface IMesh extends IChildRootProperty {
  91019. /**
  91020. * An array of primitives, each defining geometry to be rendered with a material
  91021. */
  91022. primitives: IMeshPrimitive[];
  91023. /**
  91024. * Array of weights to be applied to the Morph Targets
  91025. */
  91026. weights?: number[];
  91027. }
  91028. /**
  91029. * A node in the node hierarchy
  91030. */
  91031. interface INode extends IChildRootProperty {
  91032. /**
  91033. * The index of the camera referenced by this node
  91034. */
  91035. camera?: number;
  91036. /**
  91037. * The indices of this node's children
  91038. */
  91039. children?: number[];
  91040. /**
  91041. * The index of the skin referenced by this node
  91042. */
  91043. skin?: number;
  91044. /**
  91045. * A floating-point 4x4 transformation matrix stored in column-major order
  91046. */
  91047. matrix?: number[];
  91048. /**
  91049. * The index of the mesh in this node
  91050. */
  91051. mesh?: number;
  91052. /**
  91053. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91054. */
  91055. rotation?: number[];
  91056. /**
  91057. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91058. */
  91059. scale?: number[];
  91060. /**
  91061. * The node's translation along the x, y, and z axes
  91062. */
  91063. translation?: number[];
  91064. /**
  91065. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91066. */
  91067. weights?: number[];
  91068. }
  91069. /**
  91070. * Texture sampler properties for filtering and wrapping modes
  91071. */
  91072. interface ISampler extends IChildRootProperty {
  91073. /**
  91074. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91075. */
  91076. magFilter?: TextureMagFilter;
  91077. /**
  91078. * Minification filter. All valid values correspond to WebGL enums
  91079. */
  91080. minFilter?: TextureMinFilter;
  91081. /**
  91082. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91083. */
  91084. wrapS?: TextureWrapMode;
  91085. /**
  91086. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91087. */
  91088. wrapT?: TextureWrapMode;
  91089. }
  91090. /**
  91091. * The root nodes of a scene
  91092. */
  91093. interface IScene extends IChildRootProperty {
  91094. /**
  91095. * The indices of each root node
  91096. */
  91097. nodes: number[];
  91098. }
  91099. /**
  91100. * Joints and matrices defining a skin
  91101. */
  91102. interface ISkin extends IChildRootProperty {
  91103. /**
  91104. * 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
  91105. */
  91106. inverseBindMatrices?: number;
  91107. /**
  91108. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91109. */
  91110. skeleton?: number;
  91111. /**
  91112. * 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)
  91113. */
  91114. joints: number[];
  91115. }
  91116. /**
  91117. * A texture and its sampler
  91118. */
  91119. interface ITexture extends IChildRootProperty {
  91120. /**
  91121. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91122. */
  91123. sampler?: number;
  91124. /**
  91125. * The index of the image used by this texture
  91126. */
  91127. source: number;
  91128. }
  91129. /**
  91130. * Reference to a texture
  91131. */
  91132. interface ITextureInfo extends IProperty {
  91133. /**
  91134. * The index of the texture
  91135. */
  91136. index: number;
  91137. /**
  91138. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91139. */
  91140. texCoord?: number;
  91141. }
  91142. /**
  91143. * The root object for a glTF asset
  91144. */
  91145. interface IGLTF extends IProperty {
  91146. /**
  91147. * An array of accessors. An accessor is a typed view into a bufferView
  91148. */
  91149. accessors?: IAccessor[];
  91150. /**
  91151. * An array of keyframe animations
  91152. */
  91153. animations?: IAnimation[];
  91154. /**
  91155. * Metadata about the glTF asset
  91156. */
  91157. asset: IAsset;
  91158. /**
  91159. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91160. */
  91161. buffers?: IBuffer[];
  91162. /**
  91163. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91164. */
  91165. bufferViews?: IBufferView[];
  91166. /**
  91167. * An array of cameras
  91168. */
  91169. cameras?: ICamera[];
  91170. /**
  91171. * Names of glTF extensions used somewhere in this asset
  91172. */
  91173. extensionsUsed?: string[];
  91174. /**
  91175. * Names of glTF extensions required to properly load this asset
  91176. */
  91177. extensionsRequired?: string[];
  91178. /**
  91179. * An array of images. An image defines data used to create a texture
  91180. */
  91181. images?: IImage[];
  91182. /**
  91183. * An array of materials. A material defines the appearance of a primitive
  91184. */
  91185. materials?: IMaterial[];
  91186. /**
  91187. * An array of meshes. A mesh is a set of primitives to be rendered
  91188. */
  91189. meshes?: IMesh[];
  91190. /**
  91191. * An array of nodes
  91192. */
  91193. nodes?: INode[];
  91194. /**
  91195. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91196. */
  91197. samplers?: ISampler[];
  91198. /**
  91199. * The index of the default scene
  91200. */
  91201. scene?: number;
  91202. /**
  91203. * An array of scenes
  91204. */
  91205. scenes?: IScene[];
  91206. /**
  91207. * An array of skins. A skin is defined by joints and matrices
  91208. */
  91209. skins?: ISkin[];
  91210. /**
  91211. * An array of textures
  91212. */
  91213. textures?: ITexture[];
  91214. }
  91215. /**
  91216. * The glTF validation results
  91217. * @ignore
  91218. */
  91219. interface IGLTFValidationResults {
  91220. info: {
  91221. generator: string;
  91222. hasAnimations: boolean;
  91223. hasDefaultScene: boolean;
  91224. hasMaterials: boolean;
  91225. hasMorphTargets: boolean;
  91226. hasSkins: boolean;
  91227. hasTextures: boolean;
  91228. maxAttributesUsed: number;
  91229. primitivesCount: number
  91230. };
  91231. issues: {
  91232. messages: Array<string>;
  91233. numErrors: number;
  91234. numHints: number;
  91235. numInfos: number;
  91236. numWarnings: number;
  91237. truncated: boolean
  91238. };
  91239. mimeType: string;
  91240. uri: string;
  91241. validatedAt: string;
  91242. validatorVersion: string;
  91243. }
  91244. /**
  91245. * The glTF validation options
  91246. */
  91247. interface IGLTFValidationOptions {
  91248. /** Uri to use */
  91249. uri?: string;
  91250. /** Function used to load external resources */
  91251. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91252. /** Boolean indicating that we need to validate accessor data */
  91253. validateAccessorData?: boolean;
  91254. /** max number of issues allowed */
  91255. maxIssues?: number;
  91256. /** Ignored issues */
  91257. ignoredIssues?: Array<string>;
  91258. /** Value to override severy settings */
  91259. severityOverrides?: Object;
  91260. }
  91261. /**
  91262. * The glTF validator object
  91263. * @ignore
  91264. */
  91265. interface IGLTFValidator {
  91266. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91267. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91268. }
  91269. /**
  91270. * Interfaces from the EXT_lights_image_based extension
  91271. */
  91272. /** @hidden */
  91273. interface IEXTLightsImageBased_LightReferenceImageBased {
  91274. light: number;
  91275. }
  91276. /** @hidden */
  91277. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91278. intensity: number;
  91279. rotation: number[];
  91280. specularImageSize: number;
  91281. specularImages: number[][];
  91282. irradianceCoefficients: number[][];
  91283. }
  91284. /** @hidden */
  91285. interface IEXTLightsImageBased {
  91286. lights: IEXTLightsImageBased_LightImageBased[];
  91287. }
  91288. /**
  91289. * Interfaces from the EXT_mesh_gpu_instancing extension
  91290. * !!! Experimental Extension Subject to Changes !!!
  91291. */
  91292. /** @hidden */
  91293. interface IEXTMeshGpuInstancing {
  91294. mesh?: number;
  91295. attributes: { [name: string]: number };
  91296. }
  91297. /**
  91298. * Interfaces from the KHR_draco_mesh_compression extension
  91299. */
  91300. /** @hidden */
  91301. interface IKHRDracoMeshCompression {
  91302. bufferView: number;
  91303. attributes: { [name: string]: number };
  91304. }
  91305. /**
  91306. * Interfaces from the KHR_lights_punctual extension
  91307. */
  91308. /** @hidden */
  91309. const enum IKHRLightsPunctual_LightType {
  91310. DIRECTIONAL = "directional",
  91311. POINT = "point",
  91312. SPOT = "spot"
  91313. }
  91314. /** @hidden */
  91315. interface IKHRLightsPunctual_LightReference {
  91316. light: number;
  91317. }
  91318. /** @hidden */
  91319. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91320. type: IKHRLightsPunctual_LightType;
  91321. color?: number[];
  91322. intensity?: number;
  91323. range?: number;
  91324. spot?: {
  91325. innerConeAngle?: number;
  91326. outerConeAngle?: number;
  91327. };
  91328. }
  91329. /** @hidden */
  91330. interface IKHRLightsPunctual {
  91331. lights: IKHRLightsPunctual_Light[];
  91332. }
  91333. /**
  91334. * Interfaces from the KHR_materials_clearcoat extension
  91335. * !!! Experimental Extension Subject to Changes !!!
  91336. */
  91337. /** @hidden */
  91338. interface IKHRMaterialsClearcoat {
  91339. clearcoatFactor: number;
  91340. clearcoatTexture: ITextureInfo;
  91341. clearcoatRoughnessFactor: number;
  91342. clearcoatRoughnessTexture: ITextureInfo;
  91343. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91344. }
  91345. /**
  91346. * Interfaces from the KHR_materials_ior extension
  91347. * !!! Experimental Extension Subject to Changes !!!
  91348. */
  91349. /** @hidden */
  91350. interface IKHRMaterialsIor {
  91351. ior: number;
  91352. }
  91353. /**
  91354. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91355. */
  91356. /** @hidden */
  91357. interface IKHRMaterialsPbrSpecularGlossiness {
  91358. diffuseFactor: number[];
  91359. diffuseTexture: ITextureInfo;
  91360. specularFactor: number[];
  91361. glossinessFactor: number;
  91362. specularGlossinessTexture: ITextureInfo;
  91363. }
  91364. /**
  91365. * Interfaces from the KHR_materials_sheen extension
  91366. * !!! Experimental Extension Subject to Changes !!!
  91367. */
  91368. /** @hidden */
  91369. interface IKHRMaterialsSheen {
  91370. sheenColorFactor?: number[];
  91371. sheenColorTexture?: ITextureInfo;
  91372. sheenRoughnessFactor?: number;
  91373. sheenRoughnessTexture?: ITextureInfo;
  91374. }
  91375. /**
  91376. * Interfaces from the KHR_materials_specular extension
  91377. * !!! Experimental Extension Subject to Changes !!!
  91378. */
  91379. /** @hidden */
  91380. interface IKHRMaterialsSpecular {
  91381. specularFactor: number;
  91382. specularColorFactor: number[];
  91383. specularTexture: ITextureInfo;
  91384. }
  91385. /**
  91386. * Interfaces from the KHR_materials_transmission extension
  91387. * !!! Experimental Extension Subject to Changes !!!
  91388. */
  91389. /** @hidden */
  91390. interface IKHRMaterialsTransmission {
  91391. transmissionFactor?: number;
  91392. transmissionTexture?: ITextureInfo;
  91393. }
  91394. /**
  91395. * Interfaces from the KHR_materials_translucency extension
  91396. * !!! Experimental Extension Subject to Changes !!!
  91397. */
  91398. /** @hidden */
  91399. interface IKHRMaterialsTranslucency {
  91400. translucencyFactor?: number;
  91401. translucencyTexture?: ITextureInfo;
  91402. }
  91403. /**
  91404. * Interfaces from the KHR_materials_variants extension
  91405. * !!! Experimental Extension Subject to Changes !!!
  91406. */
  91407. /** @hidden */
  91408. interface IKHRMaterialVariants_Mapping extends IProperty {
  91409. mappings: Array<{
  91410. variants: number[];
  91411. material: number;
  91412. }>;
  91413. }
  91414. /** @hidden */
  91415. interface IKHRMaterialVariants_Variant extends IProperty {
  91416. name: string;
  91417. }
  91418. /** @hidden */
  91419. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91420. variants: Array<IKHRMaterialVariants_Variant>;
  91421. }
  91422. /**
  91423. * Interfaces from the KHR_texture_basisu extension
  91424. * !!! Experimental Extension Subject to Changes !!!
  91425. */
  91426. /** @hidden */
  91427. interface IKHRTextureBasisU {
  91428. source: number;
  91429. }
  91430. /**
  91431. * Interfaces from the EXT_texture_webp extension
  91432. */
  91433. /** @hidden */
  91434. interface IEXTTextureWebP {
  91435. source: number;
  91436. }
  91437. /**
  91438. * Interfaces from the KHR_texture_transform extension
  91439. */
  91440. /** @hidden */
  91441. interface IKHRTextureTransform {
  91442. offset?: number[];
  91443. rotation?: number;
  91444. scale?: number[];
  91445. texCoord?: number;
  91446. }
  91447. /**
  91448. * Interfaces from the KHR_xmp_json_ld extension
  91449. * !!! Experimental Extension Subject to Changes !!!
  91450. */
  91451. /** @hidden */
  91452. interface IKHRXmpJsonLd_Gltf {
  91453. packets: Array<{
  91454. [key: string]: unknown;
  91455. }>;
  91456. }
  91457. /** @hidden */
  91458. interface IKHRXmpJsonLd_Node {
  91459. packet: number;
  91460. }
  91461. /**
  91462. * Interfaces from the MSFT_audio_emitter extension
  91463. */
  91464. /** @hidden */
  91465. interface IMSFTAudioEmitter_ClipReference {
  91466. clip: number;
  91467. weight?: number;
  91468. }
  91469. /** @hidden */
  91470. interface IMSFTAudioEmitter_EmittersReference {
  91471. emitters: number[];
  91472. }
  91473. /** @hidden */
  91474. const enum IMSFTAudioEmitter_DistanceModel {
  91475. linear = "linear",
  91476. inverse = "inverse",
  91477. exponential = "exponential",
  91478. }
  91479. /** @hidden */
  91480. interface IMSFTAudioEmitter_Emitter {
  91481. name?: string;
  91482. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91483. refDistance?: number;
  91484. maxDistance?: number;
  91485. rolloffFactor?: number;
  91486. innerAngle?: number;
  91487. outerAngle?: number;
  91488. loop?: boolean;
  91489. volume?: number;
  91490. clips: IMSFTAudioEmitter_ClipReference[];
  91491. }
  91492. /** @hidden */
  91493. const enum IMSFTAudioEmitter_AudioMimeType {
  91494. WAV = "audio/wav",
  91495. }
  91496. /** @hidden */
  91497. interface IMSFTAudioEmitter_Clip extends IProperty {
  91498. uri?: string;
  91499. bufferView?: number;
  91500. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91501. }
  91502. /** @hidden */
  91503. const enum IMSFTAudioEmitter_AnimationEventAction {
  91504. play = "play",
  91505. pause = "pause",
  91506. stop = "stop",
  91507. }
  91508. /** @hidden */
  91509. interface IMSFTAudioEmitter_AnimationEvent {
  91510. action: IMSFTAudioEmitter_AnimationEventAction;
  91511. emitter: number;
  91512. time: number;
  91513. startOffset?: number;
  91514. }
  91515. /**
  91516. * Interfaces from the MSFT_lod extension
  91517. */
  91518. /** @hidden */
  91519. interface IMSFTLOD {
  91520. ids: number[];
  91521. }
  91522. /**
  91523. * Interfaces from the EXT_meshopt_compression extension
  91524. */
  91525. /** @hidden */
  91526. interface IEXTMeshoptCompression {
  91527. buffer: number;
  91528. byteOffset?: number;
  91529. byteLength: number;
  91530. byteStride: number;
  91531. count: number;
  91532. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91533. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91534. }
  91535. }
  91536. declare module BABYLON {
  91537. /** @hidden */
  91538. export var cellPixelShader: {
  91539. name: string;
  91540. shader: string;
  91541. };
  91542. }
  91543. declare module BABYLON {
  91544. /** @hidden */
  91545. export var cellVertexShader: {
  91546. name: string;
  91547. shader: string;
  91548. };
  91549. }
  91550. declare module BABYLON {
  91551. export class CellMaterial extends BABYLON.PushMaterial {
  91552. private _diffuseTexture;
  91553. diffuseTexture: BABYLON.BaseTexture;
  91554. diffuseColor: BABYLON.Color3;
  91555. _computeHighLevel: boolean;
  91556. computeHighLevel: boolean;
  91557. private _disableLighting;
  91558. disableLighting: boolean;
  91559. private _maxSimultaneousLights;
  91560. maxSimultaneousLights: number;
  91561. constructor(name: string, scene: BABYLON.Scene);
  91562. needAlphaBlending(): boolean;
  91563. needAlphaTesting(): boolean;
  91564. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91565. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91566. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91567. getAnimatables(): BABYLON.IAnimatable[];
  91568. getActiveTextures(): BABYLON.BaseTexture[];
  91569. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91570. dispose(forceDisposeEffect?: boolean): void;
  91571. getClassName(): string;
  91572. clone(name: string): CellMaterial;
  91573. serialize(): any;
  91574. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91575. }
  91576. }
  91577. declare module BABYLON {
  91578. export class CustomShaderStructure {
  91579. FragmentStore: string;
  91580. VertexStore: string;
  91581. constructor();
  91582. }
  91583. export class ShaderSpecialParts {
  91584. constructor();
  91585. Fragment_Begin: string;
  91586. Fragment_Definitions: string;
  91587. Fragment_MainBegin: string;
  91588. Fragment_Custom_Diffuse: string;
  91589. Fragment_Before_Lights: string;
  91590. Fragment_Before_Fog: string;
  91591. Fragment_Custom_Alpha: string;
  91592. Fragment_Before_FragColor: string;
  91593. Vertex_Begin: string;
  91594. Vertex_Definitions: string;
  91595. Vertex_MainBegin: string;
  91596. Vertex_Before_PositionUpdated: string;
  91597. Vertex_Before_NormalUpdated: string;
  91598. Vertex_After_WorldPosComputed: string;
  91599. Vertex_MainEnd: string;
  91600. }
  91601. export class CustomMaterial extends BABYLON.StandardMaterial {
  91602. static ShaderIndexer: number;
  91603. CustomParts: ShaderSpecialParts;
  91604. _isCreatedShader: boolean;
  91605. _createdShaderName: string;
  91606. _customUniform: string[];
  91607. _newUniforms: string[];
  91608. _newUniformInstances: {
  91609. [name: string]: any;
  91610. };
  91611. _newSamplerInstances: {
  91612. [name: string]: BABYLON.Texture;
  91613. };
  91614. _customAttributes: string[];
  91615. FragmentShader: string;
  91616. VertexShader: string;
  91617. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91618. ReviewUniform(name: string, arr: string[]): string[];
  91619. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91620. constructor(name: string, scene: BABYLON.Scene);
  91621. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91622. AddAttribute(name: string): CustomMaterial;
  91623. Fragment_Begin(shaderPart: string): CustomMaterial;
  91624. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91625. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91626. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91627. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91628. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91629. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91630. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91631. Vertex_Begin(shaderPart: string): CustomMaterial;
  91632. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91633. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91634. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91635. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91636. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91637. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91638. }
  91639. }
  91640. declare module BABYLON {
  91641. export class ShaderAlebdoParts {
  91642. constructor();
  91643. Fragment_Begin: string;
  91644. Fragment_Definitions: string;
  91645. Fragment_MainBegin: string;
  91646. Fragment_Custom_Albedo: string;
  91647. Fragment_Before_Lights: string;
  91648. Fragment_Custom_MetallicRoughness: string;
  91649. Fragment_Custom_MicroSurface: string;
  91650. Fragment_Before_Fog: string;
  91651. Fragment_Custom_Alpha: string;
  91652. Fragment_Before_FragColor: string;
  91653. Vertex_Begin: string;
  91654. Vertex_Definitions: string;
  91655. Vertex_MainBegin: string;
  91656. Vertex_Before_PositionUpdated: string;
  91657. Vertex_Before_NormalUpdated: string;
  91658. Vertex_After_WorldPosComputed: string;
  91659. Vertex_MainEnd: string;
  91660. }
  91661. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91662. static ShaderIndexer: number;
  91663. CustomParts: ShaderAlebdoParts;
  91664. _isCreatedShader: boolean;
  91665. _createdShaderName: string;
  91666. _customUniform: string[];
  91667. _newUniforms: string[];
  91668. _newUniformInstances: {
  91669. [name: string]: any;
  91670. };
  91671. _newSamplerInstances: {
  91672. [name: string]: BABYLON.Texture;
  91673. };
  91674. _customAttributes: string[];
  91675. FragmentShader: string;
  91676. VertexShader: string;
  91677. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91678. ReviewUniform(name: string, arr: string[]): string[];
  91679. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91680. constructor(name: string, scene: BABYLON.Scene);
  91681. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91682. AddAttribute(name: string): PBRCustomMaterial;
  91683. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91684. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91685. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91686. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91687. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91688. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91689. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91690. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91691. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91692. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91693. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91694. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91695. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91696. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91697. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91698. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91699. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91700. }
  91701. }
  91702. declare module BABYLON {
  91703. /** @hidden */
  91704. export var firePixelShader: {
  91705. name: string;
  91706. shader: string;
  91707. };
  91708. }
  91709. declare module BABYLON {
  91710. /** @hidden */
  91711. export var fireVertexShader: {
  91712. name: string;
  91713. shader: string;
  91714. };
  91715. }
  91716. declare module BABYLON {
  91717. export class FireMaterial extends BABYLON.PushMaterial {
  91718. private _diffuseTexture;
  91719. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91720. private _distortionTexture;
  91721. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91722. private _opacityTexture;
  91723. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91724. diffuseColor: BABYLON.Color3;
  91725. speed: number;
  91726. private _scaledDiffuse;
  91727. private _lastTime;
  91728. constructor(name: string, scene: BABYLON.Scene);
  91729. needAlphaBlending(): boolean;
  91730. needAlphaTesting(): boolean;
  91731. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91732. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91733. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91734. getAnimatables(): BABYLON.IAnimatable[];
  91735. getActiveTextures(): BABYLON.BaseTexture[];
  91736. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91737. getClassName(): string;
  91738. dispose(forceDisposeEffect?: boolean): void;
  91739. clone(name: string): FireMaterial;
  91740. serialize(): any;
  91741. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91742. }
  91743. }
  91744. declare module BABYLON {
  91745. /** @hidden */
  91746. export var furPixelShader: {
  91747. name: string;
  91748. shader: string;
  91749. };
  91750. }
  91751. declare module BABYLON {
  91752. /** @hidden */
  91753. export var furVertexShader: {
  91754. name: string;
  91755. shader: string;
  91756. };
  91757. }
  91758. declare module BABYLON {
  91759. export class FurMaterial extends BABYLON.PushMaterial {
  91760. private _diffuseTexture;
  91761. diffuseTexture: BABYLON.BaseTexture;
  91762. private _heightTexture;
  91763. heightTexture: BABYLON.BaseTexture;
  91764. diffuseColor: BABYLON.Color3;
  91765. furLength: number;
  91766. furAngle: number;
  91767. furColor: BABYLON.Color3;
  91768. furOffset: number;
  91769. furSpacing: number;
  91770. furGravity: BABYLON.Vector3;
  91771. furSpeed: number;
  91772. furDensity: number;
  91773. furOcclusion: number;
  91774. furTexture: BABYLON.DynamicTexture;
  91775. private _disableLighting;
  91776. disableLighting: boolean;
  91777. private _maxSimultaneousLights;
  91778. maxSimultaneousLights: number;
  91779. highLevelFur: boolean;
  91780. _meshes: BABYLON.AbstractMesh[];
  91781. private _furTime;
  91782. constructor(name: string, scene: BABYLON.Scene);
  91783. get furTime(): number;
  91784. set furTime(furTime: number);
  91785. needAlphaBlending(): boolean;
  91786. needAlphaTesting(): boolean;
  91787. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91788. updateFur(): void;
  91789. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91790. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91791. getAnimatables(): BABYLON.IAnimatable[];
  91792. getActiveTextures(): BABYLON.BaseTexture[];
  91793. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91794. dispose(forceDisposeEffect?: boolean): void;
  91795. clone(name: string): FurMaterial;
  91796. serialize(): any;
  91797. getClassName(): string;
  91798. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91799. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91800. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91801. }
  91802. }
  91803. declare module BABYLON {
  91804. /** @hidden */
  91805. export var gradientPixelShader: {
  91806. name: string;
  91807. shader: string;
  91808. };
  91809. }
  91810. declare module BABYLON {
  91811. /** @hidden */
  91812. export var gradientVertexShader: {
  91813. name: string;
  91814. shader: string;
  91815. };
  91816. }
  91817. declare module BABYLON {
  91818. export class GradientMaterial extends BABYLON.PushMaterial {
  91819. private _maxSimultaneousLights;
  91820. maxSimultaneousLights: number;
  91821. topColor: BABYLON.Color3;
  91822. topColorAlpha: number;
  91823. bottomColor: BABYLON.Color3;
  91824. bottomColorAlpha: number;
  91825. offset: number;
  91826. scale: number;
  91827. smoothness: number;
  91828. private _disableLighting;
  91829. disableLighting: boolean;
  91830. constructor(name: string, scene: BABYLON.Scene);
  91831. needAlphaBlending(): boolean;
  91832. needAlphaTesting(): boolean;
  91833. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91834. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91835. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91836. getAnimatables(): BABYLON.IAnimatable[];
  91837. dispose(forceDisposeEffect?: boolean): void;
  91838. clone(name: string): GradientMaterial;
  91839. serialize(): any;
  91840. getClassName(): string;
  91841. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91842. }
  91843. }
  91844. declare module BABYLON {
  91845. /** @hidden */
  91846. export var gridPixelShader: {
  91847. name: string;
  91848. shader: string;
  91849. };
  91850. }
  91851. declare module BABYLON {
  91852. /** @hidden */
  91853. export var gridVertexShader: {
  91854. name: string;
  91855. shader: string;
  91856. };
  91857. }
  91858. declare module BABYLON {
  91859. /**
  91860. * The grid materials allows you to wrap any shape with a grid.
  91861. * Colors are customizable.
  91862. */
  91863. export class GridMaterial extends BABYLON.PushMaterial {
  91864. /**
  91865. * Main color of the grid (e.g. between lines)
  91866. */
  91867. mainColor: BABYLON.Color3;
  91868. /**
  91869. * Color of the grid lines.
  91870. */
  91871. lineColor: BABYLON.Color3;
  91872. /**
  91873. * The scale of the grid compared to unit.
  91874. */
  91875. gridRatio: number;
  91876. /**
  91877. * Allows setting an offset for the grid lines.
  91878. */
  91879. gridOffset: BABYLON.Vector3;
  91880. /**
  91881. * The frequency of thicker lines.
  91882. */
  91883. majorUnitFrequency: number;
  91884. /**
  91885. * The visibility of minor units in the grid.
  91886. */
  91887. minorUnitVisibility: number;
  91888. /**
  91889. * The grid opacity outside of the lines.
  91890. */
  91891. opacity: number;
  91892. /**
  91893. * Determine RBG output is premultiplied by alpha value.
  91894. */
  91895. preMultiplyAlpha: boolean;
  91896. private _opacityTexture;
  91897. opacityTexture: BABYLON.BaseTexture;
  91898. private _gridControl;
  91899. /**
  91900. * constructor
  91901. * @param name The name given to the material in order to identify it afterwards.
  91902. * @param scene The scene the material is used in.
  91903. */
  91904. constructor(name: string, scene: BABYLON.Scene);
  91905. /**
  91906. * Returns wehter or not the grid requires alpha blending.
  91907. */
  91908. needAlphaBlending(): boolean;
  91909. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91912. /**
  91913. * Dispose the material and its associated resources.
  91914. * @param forceDisposeEffect will also dispose the used effect when true
  91915. */
  91916. dispose(forceDisposeEffect?: boolean): void;
  91917. clone(name: string): GridMaterial;
  91918. serialize(): any;
  91919. getClassName(): string;
  91920. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91921. }
  91922. }
  91923. declare module BABYLON {
  91924. /** @hidden */
  91925. export var lavaPixelShader: {
  91926. name: string;
  91927. shader: string;
  91928. };
  91929. }
  91930. declare module BABYLON {
  91931. /** @hidden */
  91932. export var lavaVertexShader: {
  91933. name: string;
  91934. shader: string;
  91935. };
  91936. }
  91937. declare module BABYLON {
  91938. export class LavaMaterial extends BABYLON.PushMaterial {
  91939. private _diffuseTexture;
  91940. diffuseTexture: BABYLON.BaseTexture;
  91941. noiseTexture: BABYLON.BaseTexture;
  91942. fogColor: BABYLON.Color3;
  91943. speed: number;
  91944. movingSpeed: number;
  91945. lowFrequencySpeed: number;
  91946. fogDensity: number;
  91947. private _lastTime;
  91948. diffuseColor: BABYLON.Color3;
  91949. private _disableLighting;
  91950. disableLighting: boolean;
  91951. private _unlit;
  91952. unlit: boolean;
  91953. private _maxSimultaneousLights;
  91954. maxSimultaneousLights: number;
  91955. private _scaledDiffuse;
  91956. constructor(name: string, scene: BABYLON.Scene);
  91957. needAlphaBlending(): boolean;
  91958. needAlphaTesting(): boolean;
  91959. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91960. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91961. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91962. getAnimatables(): BABYLON.IAnimatable[];
  91963. getActiveTextures(): BABYLON.BaseTexture[];
  91964. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91965. dispose(forceDisposeEffect?: boolean): void;
  91966. clone(name: string): LavaMaterial;
  91967. serialize(): any;
  91968. getClassName(): string;
  91969. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91970. }
  91971. }
  91972. declare module BABYLON {
  91973. /** @hidden */
  91974. export var mixPixelShader: {
  91975. name: string;
  91976. shader: string;
  91977. };
  91978. }
  91979. declare module BABYLON {
  91980. /** @hidden */
  91981. export var mixVertexShader: {
  91982. name: string;
  91983. shader: string;
  91984. };
  91985. }
  91986. declare module BABYLON {
  91987. export class MixMaterial extends BABYLON.PushMaterial {
  91988. /**
  91989. * Mix textures
  91990. */
  91991. private _mixTexture1;
  91992. mixTexture1: BABYLON.BaseTexture;
  91993. private _mixTexture2;
  91994. mixTexture2: BABYLON.BaseTexture;
  91995. /**
  91996. * Diffuse textures
  91997. */
  91998. private _diffuseTexture1;
  91999. diffuseTexture1: BABYLON.Texture;
  92000. private _diffuseTexture2;
  92001. diffuseTexture2: BABYLON.Texture;
  92002. private _diffuseTexture3;
  92003. diffuseTexture3: BABYLON.Texture;
  92004. private _diffuseTexture4;
  92005. diffuseTexture4: BABYLON.Texture;
  92006. private _diffuseTexture5;
  92007. diffuseTexture5: BABYLON.Texture;
  92008. private _diffuseTexture6;
  92009. diffuseTexture6: BABYLON.Texture;
  92010. private _diffuseTexture7;
  92011. diffuseTexture7: BABYLON.Texture;
  92012. private _diffuseTexture8;
  92013. diffuseTexture8: BABYLON.Texture;
  92014. /**
  92015. * Uniforms
  92016. */
  92017. diffuseColor: BABYLON.Color3;
  92018. specularColor: BABYLON.Color3;
  92019. specularPower: number;
  92020. private _disableLighting;
  92021. disableLighting: boolean;
  92022. private _maxSimultaneousLights;
  92023. maxSimultaneousLights: number;
  92024. constructor(name: string, scene: BABYLON.Scene);
  92025. needAlphaBlending(): boolean;
  92026. needAlphaTesting(): boolean;
  92027. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92028. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92029. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92030. getAnimatables(): BABYLON.IAnimatable[];
  92031. getActiveTextures(): BABYLON.BaseTexture[];
  92032. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92033. dispose(forceDisposeEffect?: boolean): void;
  92034. clone(name: string): MixMaterial;
  92035. serialize(): any;
  92036. getClassName(): string;
  92037. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92038. }
  92039. }
  92040. declare module BABYLON {
  92041. /** @hidden */
  92042. export var normalPixelShader: {
  92043. name: string;
  92044. shader: string;
  92045. };
  92046. }
  92047. declare module BABYLON {
  92048. /** @hidden */
  92049. export var normalVertexShader: {
  92050. name: string;
  92051. shader: string;
  92052. };
  92053. }
  92054. declare module BABYLON {
  92055. export class NormalMaterial extends BABYLON.PushMaterial {
  92056. private _diffuseTexture;
  92057. diffuseTexture: BABYLON.BaseTexture;
  92058. diffuseColor: BABYLON.Color3;
  92059. private _disableLighting;
  92060. disableLighting: boolean;
  92061. private _maxSimultaneousLights;
  92062. maxSimultaneousLights: number;
  92063. constructor(name: string, scene: BABYLON.Scene);
  92064. needAlphaBlending(): boolean;
  92065. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92066. needAlphaTesting(): boolean;
  92067. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92068. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92069. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92070. getAnimatables(): BABYLON.IAnimatable[];
  92071. getActiveTextures(): BABYLON.BaseTexture[];
  92072. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92073. dispose(forceDisposeEffect?: boolean): void;
  92074. clone(name: string): NormalMaterial;
  92075. serialize(): any;
  92076. getClassName(): string;
  92077. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92078. }
  92079. }
  92080. declare module BABYLON {
  92081. /** @hidden */
  92082. export var shadowOnlyPixelShader: {
  92083. name: string;
  92084. shader: string;
  92085. };
  92086. }
  92087. declare module BABYLON {
  92088. /** @hidden */
  92089. export var shadowOnlyVertexShader: {
  92090. name: string;
  92091. shader: string;
  92092. };
  92093. }
  92094. declare module BABYLON {
  92095. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92096. private _activeLight;
  92097. private _needAlphaBlending;
  92098. constructor(name: string, scene: BABYLON.Scene);
  92099. shadowColor: BABYLON.Color3;
  92100. needAlphaBlending(): boolean;
  92101. needAlphaTesting(): boolean;
  92102. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92103. get activeLight(): BABYLON.IShadowLight;
  92104. set activeLight(light: BABYLON.IShadowLight);
  92105. private _getFirstShadowLightForMesh;
  92106. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92107. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92108. clone(name: string): ShadowOnlyMaterial;
  92109. serialize(): any;
  92110. getClassName(): string;
  92111. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92112. }
  92113. }
  92114. declare module BABYLON {
  92115. /** @hidden */
  92116. export var simplePixelShader: {
  92117. name: string;
  92118. shader: string;
  92119. };
  92120. }
  92121. declare module BABYLON {
  92122. /** @hidden */
  92123. export var simpleVertexShader: {
  92124. name: string;
  92125. shader: string;
  92126. };
  92127. }
  92128. declare module BABYLON {
  92129. export class SimpleMaterial extends BABYLON.PushMaterial {
  92130. private _diffuseTexture;
  92131. diffuseTexture: BABYLON.BaseTexture;
  92132. diffuseColor: BABYLON.Color3;
  92133. private _disableLighting;
  92134. disableLighting: boolean;
  92135. private _maxSimultaneousLights;
  92136. maxSimultaneousLights: number;
  92137. constructor(name: string, scene: BABYLON.Scene);
  92138. needAlphaBlending(): boolean;
  92139. needAlphaTesting(): boolean;
  92140. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92141. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92142. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92143. getAnimatables(): BABYLON.IAnimatable[];
  92144. getActiveTextures(): BABYLON.BaseTexture[];
  92145. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92146. dispose(forceDisposeEffect?: boolean): void;
  92147. clone(name: string): SimpleMaterial;
  92148. serialize(): any;
  92149. getClassName(): string;
  92150. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92151. }
  92152. }
  92153. declare module BABYLON {
  92154. /** @hidden */
  92155. export var skyPixelShader: {
  92156. name: string;
  92157. shader: string;
  92158. };
  92159. }
  92160. declare module BABYLON {
  92161. /** @hidden */
  92162. export var skyVertexShader: {
  92163. name: string;
  92164. shader: string;
  92165. };
  92166. }
  92167. declare module BABYLON {
  92168. /**
  92169. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92170. * @see https://doc.babylonjs.com/extensions/sky
  92171. */
  92172. export class SkyMaterial extends BABYLON.PushMaterial {
  92173. /**
  92174. * Defines the overall luminance of sky in interval ]0, 1[.
  92175. */
  92176. luminance: number;
  92177. /**
  92178. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92179. */
  92180. turbidity: number;
  92181. /**
  92182. * Defines the sky appearance (light intensity).
  92183. */
  92184. rayleigh: number;
  92185. /**
  92186. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92187. */
  92188. mieCoefficient: number;
  92189. /**
  92190. * Defines the amount of haze particles following the Mie scattering theory.
  92191. */
  92192. mieDirectionalG: number;
  92193. /**
  92194. * Defines the distance of the sun according to the active scene camera.
  92195. */
  92196. distance: number;
  92197. /**
  92198. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92199. * "inclined".
  92200. */
  92201. inclination: number;
  92202. /**
  92203. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92204. * an object direction and a reference direction.
  92205. */
  92206. azimuth: number;
  92207. /**
  92208. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92209. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92210. */
  92211. sunPosition: BABYLON.Vector3;
  92212. /**
  92213. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92214. * .sunPosition property.
  92215. */
  92216. useSunPosition: boolean;
  92217. /**
  92218. * Defines an offset vector used to get a horizon offset.
  92219. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92220. */
  92221. cameraOffset: BABYLON.Vector3;
  92222. /**
  92223. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92224. */
  92225. up: BABYLON.Vector3;
  92226. private _cameraPosition;
  92227. private _skyOrientation;
  92228. /**
  92229. * Instantiates a new sky material.
  92230. * This material allows to create dynamic and texture free
  92231. * effects for skyboxes by taking care of the atmosphere state.
  92232. * @see https://doc.babylonjs.com/extensions/sky
  92233. * @param name Define the name of the material in the scene
  92234. * @param scene Define the scene the material belong to
  92235. */
  92236. constructor(name: string, scene: BABYLON.Scene);
  92237. /**
  92238. * Specifies if the material will require alpha blending
  92239. * @returns a boolean specifying if alpha blending is needed
  92240. */
  92241. needAlphaBlending(): boolean;
  92242. /**
  92243. * Specifies if this material should be rendered in alpha test mode
  92244. * @returns false as the sky material doesn't need alpha testing.
  92245. */
  92246. needAlphaTesting(): boolean;
  92247. /**
  92248. * Get the texture used for alpha test purpose.
  92249. * @returns null as the sky material has no texture.
  92250. */
  92251. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92252. /**
  92253. * Get if the submesh is ready to be used and all its information available.
  92254. * Child classes can use it to update shaders
  92255. * @param mesh defines the mesh to check
  92256. * @param subMesh defines which submesh to check
  92257. * @param useInstances specifies that instances should be used
  92258. * @returns a boolean indicating that the submesh is ready or not
  92259. */
  92260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92261. /**
  92262. * Binds the submesh to this material by preparing the effect and shader to draw
  92263. * @param world defines the world transformation matrix
  92264. * @param mesh defines the mesh containing the submesh
  92265. * @param subMesh defines the submesh to bind the material to
  92266. */
  92267. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92268. /**
  92269. * Get the list of animatables in the material.
  92270. * @returns the list of animatables object used in the material
  92271. */
  92272. getAnimatables(): BABYLON.IAnimatable[];
  92273. /**
  92274. * Disposes the material
  92275. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92276. */
  92277. dispose(forceDisposeEffect?: boolean): void;
  92278. /**
  92279. * Makes a duplicate of the material, and gives it a new name
  92280. * @param name defines the new name for the duplicated material
  92281. * @returns the cloned material
  92282. */
  92283. clone(name: string): SkyMaterial;
  92284. /**
  92285. * Serializes this material in a JSON representation
  92286. * @returns the serialized material object
  92287. */
  92288. serialize(): any;
  92289. /**
  92290. * Gets the current class name of the material e.g. "SkyMaterial"
  92291. * Mainly use in serialization.
  92292. * @returns the class name
  92293. */
  92294. getClassName(): string;
  92295. /**
  92296. * Creates a sky material from parsed material data
  92297. * @param source defines the JSON representation of the material
  92298. * @param scene defines the hosting scene
  92299. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92300. * @returns a new sky material
  92301. */
  92302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92303. }
  92304. }
  92305. declare module BABYLON {
  92306. /** @hidden */
  92307. export var terrainPixelShader: {
  92308. name: string;
  92309. shader: string;
  92310. };
  92311. }
  92312. declare module BABYLON {
  92313. /** @hidden */
  92314. export var terrainVertexShader: {
  92315. name: string;
  92316. shader: string;
  92317. };
  92318. }
  92319. declare module BABYLON {
  92320. export class TerrainMaterial extends BABYLON.PushMaterial {
  92321. private _mixTexture;
  92322. mixTexture: BABYLON.BaseTexture;
  92323. private _diffuseTexture1;
  92324. diffuseTexture1: BABYLON.Texture;
  92325. private _diffuseTexture2;
  92326. diffuseTexture2: BABYLON.Texture;
  92327. private _diffuseTexture3;
  92328. diffuseTexture3: BABYLON.Texture;
  92329. private _bumpTexture1;
  92330. bumpTexture1: BABYLON.Texture;
  92331. private _bumpTexture2;
  92332. bumpTexture2: BABYLON.Texture;
  92333. private _bumpTexture3;
  92334. bumpTexture3: BABYLON.Texture;
  92335. diffuseColor: BABYLON.Color3;
  92336. specularColor: BABYLON.Color3;
  92337. specularPower: number;
  92338. private _disableLighting;
  92339. disableLighting: boolean;
  92340. private _maxSimultaneousLights;
  92341. maxSimultaneousLights: number;
  92342. constructor(name: string, scene: BABYLON.Scene);
  92343. needAlphaBlending(): boolean;
  92344. needAlphaTesting(): boolean;
  92345. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92346. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92347. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92348. getAnimatables(): BABYLON.IAnimatable[];
  92349. getActiveTextures(): BABYLON.BaseTexture[];
  92350. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92351. dispose(forceDisposeEffect?: boolean): void;
  92352. clone(name: string): TerrainMaterial;
  92353. serialize(): any;
  92354. getClassName(): string;
  92355. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92356. }
  92357. }
  92358. declare module BABYLON {
  92359. /** @hidden */
  92360. export var triplanarPixelShader: {
  92361. name: string;
  92362. shader: string;
  92363. };
  92364. }
  92365. declare module BABYLON {
  92366. /** @hidden */
  92367. export var triplanarVertexShader: {
  92368. name: string;
  92369. shader: string;
  92370. };
  92371. }
  92372. declare module BABYLON {
  92373. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92374. mixTexture: BABYLON.BaseTexture;
  92375. private _diffuseTextureX;
  92376. diffuseTextureX: BABYLON.BaseTexture;
  92377. private _diffuseTextureY;
  92378. diffuseTextureY: BABYLON.BaseTexture;
  92379. private _diffuseTextureZ;
  92380. diffuseTextureZ: BABYLON.BaseTexture;
  92381. private _normalTextureX;
  92382. normalTextureX: BABYLON.BaseTexture;
  92383. private _normalTextureY;
  92384. normalTextureY: BABYLON.BaseTexture;
  92385. private _normalTextureZ;
  92386. normalTextureZ: BABYLON.BaseTexture;
  92387. tileSize: number;
  92388. diffuseColor: BABYLON.Color3;
  92389. specularColor: BABYLON.Color3;
  92390. specularPower: number;
  92391. private _disableLighting;
  92392. disableLighting: boolean;
  92393. private _maxSimultaneousLights;
  92394. maxSimultaneousLights: number;
  92395. constructor(name: string, scene: BABYLON.Scene);
  92396. needAlphaBlending(): boolean;
  92397. needAlphaTesting(): boolean;
  92398. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92399. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92400. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92401. getAnimatables(): BABYLON.IAnimatable[];
  92402. getActiveTextures(): BABYLON.BaseTexture[];
  92403. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92404. dispose(forceDisposeEffect?: boolean): void;
  92405. clone(name: string): TriPlanarMaterial;
  92406. serialize(): any;
  92407. getClassName(): string;
  92408. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92409. }
  92410. }
  92411. declare module BABYLON {
  92412. /** @hidden */
  92413. export var waterPixelShader: {
  92414. name: string;
  92415. shader: string;
  92416. };
  92417. }
  92418. declare module BABYLON {
  92419. /** @hidden */
  92420. export var waterVertexShader: {
  92421. name: string;
  92422. shader: string;
  92423. };
  92424. }
  92425. declare module BABYLON {
  92426. export class WaterMaterial extends BABYLON.PushMaterial {
  92427. renderTargetSize: BABYLON.Vector2;
  92428. private _bumpTexture;
  92429. bumpTexture: BABYLON.BaseTexture;
  92430. diffuseColor: BABYLON.Color3;
  92431. specularColor: BABYLON.Color3;
  92432. specularPower: number;
  92433. private _disableLighting;
  92434. disableLighting: boolean;
  92435. private _maxSimultaneousLights;
  92436. maxSimultaneousLights: number;
  92437. /**
  92438. * Defines the wind force.
  92439. */
  92440. windForce: number;
  92441. /**
  92442. * Defines the direction of the wind in the plane (X, Z).
  92443. */
  92444. windDirection: BABYLON.Vector2;
  92445. /**
  92446. * Defines the height of the waves.
  92447. */
  92448. waveHeight: number;
  92449. /**
  92450. * Defines the bump height related to the bump map.
  92451. */
  92452. bumpHeight: number;
  92453. /**
  92454. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92455. */
  92456. private _bumpSuperimpose;
  92457. bumpSuperimpose: boolean;
  92458. /**
  92459. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92460. */
  92461. private _fresnelSeparate;
  92462. fresnelSeparate: boolean;
  92463. /**
  92464. * Defines wether or not bump Wwves modify the reflection.
  92465. */
  92466. private _bumpAffectsReflection;
  92467. bumpAffectsReflection: boolean;
  92468. /**
  92469. * Defines the water color blended with the refraction (near).
  92470. */
  92471. waterColor: BABYLON.Color3;
  92472. /**
  92473. * Defines the blend factor related to the water color.
  92474. */
  92475. colorBlendFactor: number;
  92476. /**
  92477. * Defines the water color blended with the reflection (far).
  92478. */
  92479. waterColor2: BABYLON.Color3;
  92480. /**
  92481. * Defines the blend factor related to the water color (reflection, far).
  92482. */
  92483. colorBlendFactor2: number;
  92484. /**
  92485. * Defines the maximum length of a wave.
  92486. */
  92487. waveLength: number;
  92488. /**
  92489. * Defines the waves speed.
  92490. */
  92491. waveSpeed: number;
  92492. /**
  92493. * 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.
  92494. */
  92495. waveCount: number;
  92496. /**
  92497. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92498. * will avoid calculating useless pixels in the pixel shader of the water material.
  92499. */
  92500. disableClipPlane: boolean;
  92501. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92502. private _mesh;
  92503. private _refractionRTT;
  92504. private _reflectionRTT;
  92505. private _reflectionTransform;
  92506. private _lastTime;
  92507. private _lastDeltaTime;
  92508. private _useLogarithmicDepth;
  92509. private _waitingRenderList;
  92510. private _imageProcessingConfiguration;
  92511. private _imageProcessingObserver;
  92512. /**
  92513. * Gets a boolean indicating that current material needs to register RTT
  92514. */
  92515. get hasRenderTargetTextures(): boolean;
  92516. /**
  92517. * Constructor
  92518. */
  92519. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92520. get useLogarithmicDepth(): boolean;
  92521. set useLogarithmicDepth(value: boolean);
  92522. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92523. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92524. addToRenderList(node: any): void;
  92525. enableRenderTargets(enable: boolean): void;
  92526. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92527. get renderTargetsEnabled(): boolean;
  92528. needAlphaBlending(): boolean;
  92529. needAlphaTesting(): boolean;
  92530. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92531. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92532. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92533. private _createRenderTargets;
  92534. getAnimatables(): BABYLON.IAnimatable[];
  92535. getActiveTextures(): BABYLON.BaseTexture[];
  92536. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92537. dispose(forceDisposeEffect?: boolean): void;
  92538. clone(name: string): WaterMaterial;
  92539. serialize(): any;
  92540. getClassName(): string;
  92541. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92542. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92543. }
  92544. }
  92545. declare module BABYLON {
  92546. /** @hidden */
  92547. export var asciiartPixelShader: {
  92548. name: string;
  92549. shader: string;
  92550. };
  92551. }
  92552. declare module BABYLON {
  92553. /**
  92554. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92555. *
  92556. * It basically takes care rendering the font front the given font size to a texture.
  92557. * This is used later on in the postprocess.
  92558. */
  92559. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92560. private _font;
  92561. private _text;
  92562. private _charSize;
  92563. /**
  92564. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92565. */
  92566. get charSize(): number;
  92567. /**
  92568. * Create a new instance of the Ascii Art FontTexture class
  92569. * @param name the name of the texture
  92570. * @param font the font to use, use the W3C CSS notation
  92571. * @param text the caracter set to use in the rendering.
  92572. * @param scene the scene that owns the texture
  92573. */
  92574. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92575. /**
  92576. * Gets the max char width of a font.
  92577. * @param font the font to use, use the W3C CSS notation
  92578. * @return the max char width
  92579. */
  92580. private getFontWidth;
  92581. /**
  92582. * Gets the max char height of a font.
  92583. * @param font the font to use, use the W3C CSS notation
  92584. * @return the max char height
  92585. */
  92586. private getFontHeight;
  92587. /**
  92588. * Clones the current AsciiArtTexture.
  92589. * @return the clone of the texture.
  92590. */
  92591. clone(): AsciiArtFontTexture;
  92592. /**
  92593. * Parses a json object representing the texture and returns an instance of it.
  92594. * @param source the source JSON representation
  92595. * @param scene the scene to create the texture for
  92596. * @return the parsed texture
  92597. */
  92598. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92599. }
  92600. /**
  92601. * Option available in the Ascii Art Post Process.
  92602. */
  92603. export interface IAsciiArtPostProcessOptions {
  92604. /**
  92605. * The font to use following the w3c font definition.
  92606. */
  92607. font?: string;
  92608. /**
  92609. * The character set to use in the postprocess.
  92610. */
  92611. characterSet?: string;
  92612. /**
  92613. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92614. * This number is defined between 0 and 1;
  92615. */
  92616. mixToTile?: number;
  92617. /**
  92618. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92619. * This number is defined between 0 and 1;
  92620. */
  92621. mixToNormal?: number;
  92622. }
  92623. /**
  92624. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92625. *
  92626. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92627. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92628. */
  92629. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92630. /**
  92631. * The font texture used to render the char in the post process.
  92632. */
  92633. private _asciiArtFontTexture;
  92634. /**
  92635. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92636. * This number is defined between 0 and 1;
  92637. */
  92638. mixToTile: number;
  92639. /**
  92640. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92641. * This number is defined between 0 and 1;
  92642. */
  92643. mixToNormal: number;
  92644. /**
  92645. * Instantiates a new Ascii Art Post Process.
  92646. * @param name the name to give to the postprocess
  92647. * @camera the camera to apply the post process to.
  92648. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92649. */
  92650. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92651. }
  92652. }
  92653. declare module BABYLON {
  92654. /** @hidden */
  92655. export var digitalrainPixelShader: {
  92656. name: string;
  92657. shader: string;
  92658. };
  92659. }
  92660. declare module BABYLON {
  92661. /**
  92662. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92663. *
  92664. * It basically takes care rendering the font front the given font size to a texture.
  92665. * This is used later on in the postprocess.
  92666. */
  92667. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92668. private _font;
  92669. private _text;
  92670. private _charSize;
  92671. /**
  92672. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92673. */
  92674. get charSize(): number;
  92675. /**
  92676. * Create a new instance of the Digital Rain FontTexture class
  92677. * @param name the name of the texture
  92678. * @param font the font to use, use the W3C CSS notation
  92679. * @param text the caracter set to use in the rendering.
  92680. * @param scene the scene that owns the texture
  92681. */
  92682. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92683. /**
  92684. * Gets the max char width of a font.
  92685. * @param font the font to use, use the W3C CSS notation
  92686. * @return the max char width
  92687. */
  92688. private getFontWidth;
  92689. /**
  92690. * Gets the max char height of a font.
  92691. * @param font the font to use, use the W3C CSS notation
  92692. * @return the max char height
  92693. */
  92694. private getFontHeight;
  92695. /**
  92696. * Clones the current DigitalRainFontTexture.
  92697. * @return the clone of the texture.
  92698. */
  92699. clone(): DigitalRainFontTexture;
  92700. /**
  92701. * Parses a json object representing the texture and returns an instance of it.
  92702. * @param source the source JSON representation
  92703. * @param scene the scene to create the texture for
  92704. * @return the parsed texture
  92705. */
  92706. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92707. }
  92708. /**
  92709. * Option available in the Digital Rain Post Process.
  92710. */
  92711. export interface IDigitalRainPostProcessOptions {
  92712. /**
  92713. * The font to use following the w3c font definition.
  92714. */
  92715. font?: string;
  92716. /**
  92717. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92718. * This number is defined between 0 and 1;
  92719. */
  92720. mixToTile?: number;
  92721. /**
  92722. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92723. * This number is defined between 0 and 1;
  92724. */
  92725. mixToNormal?: number;
  92726. }
  92727. /**
  92728. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92729. *
  92730. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92731. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92732. */
  92733. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92734. /**
  92735. * The font texture used to render the char in the post process.
  92736. */
  92737. private _digitalRainFontTexture;
  92738. /**
  92739. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92740. * This number is defined between 0 and 1;
  92741. */
  92742. mixToTile: number;
  92743. /**
  92744. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92745. * This number is defined between 0 and 1;
  92746. */
  92747. mixToNormal: number;
  92748. /**
  92749. * Instantiates a new Digital Rain Post Process.
  92750. * @param name the name to give to the postprocess
  92751. * @camera the camera to apply the post process to.
  92752. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92753. */
  92754. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92755. }
  92756. }
  92757. declare module BABYLON {
  92758. /** @hidden */
  92759. export var brickProceduralTexturePixelShader: {
  92760. name: string;
  92761. shader: string;
  92762. };
  92763. }
  92764. declare module BABYLON {
  92765. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92766. private _numberOfBricksHeight;
  92767. private _numberOfBricksWidth;
  92768. private _jointColor;
  92769. private _brickColor;
  92770. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92771. updateShaderUniforms(): void;
  92772. get numberOfBricksHeight(): number;
  92773. set numberOfBricksHeight(value: number);
  92774. get numberOfBricksWidth(): number;
  92775. set numberOfBricksWidth(value: number);
  92776. get jointColor(): BABYLON.Color3;
  92777. set jointColor(value: BABYLON.Color3);
  92778. get brickColor(): BABYLON.Color3;
  92779. set brickColor(value: BABYLON.Color3);
  92780. /**
  92781. * Serializes this brick procedural texture
  92782. * @returns a serialized brick procedural texture object
  92783. */
  92784. serialize(): any;
  92785. /**
  92786. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92787. * @param parsedTexture defines parsed texture data
  92788. * @param scene defines the current scene
  92789. * @param rootUrl defines the root URL containing brick procedural texture information
  92790. * @returns a parsed Brick Procedural BABYLON.Texture
  92791. */
  92792. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92793. }
  92794. }
  92795. declare module BABYLON {
  92796. /** @hidden */
  92797. export var cloudProceduralTexturePixelShader: {
  92798. name: string;
  92799. shader: string;
  92800. };
  92801. }
  92802. declare module BABYLON {
  92803. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92804. private _skyColor;
  92805. private _cloudColor;
  92806. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92807. updateShaderUniforms(): void;
  92808. get skyColor(): BABYLON.Color4;
  92809. set skyColor(value: BABYLON.Color4);
  92810. get cloudColor(): BABYLON.Color4;
  92811. set cloudColor(value: BABYLON.Color4);
  92812. /**
  92813. * Serializes this cloud procedural texture
  92814. * @returns a serialized cloud procedural texture object
  92815. */
  92816. serialize(): any;
  92817. /**
  92818. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92819. * @param parsedTexture defines parsed texture data
  92820. * @param scene defines the current scene
  92821. * @param rootUrl defines the root URL containing cloud procedural texture information
  92822. * @returns a parsed Cloud Procedural BABYLON.Texture
  92823. */
  92824. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92825. }
  92826. }
  92827. declare module BABYLON {
  92828. /** @hidden */
  92829. export var fireProceduralTexturePixelShader: {
  92830. name: string;
  92831. shader: string;
  92832. };
  92833. }
  92834. declare module BABYLON {
  92835. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92836. private _time;
  92837. private _speed;
  92838. private _autoGenerateTime;
  92839. private _fireColors;
  92840. private _alphaThreshold;
  92841. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92842. updateShaderUniforms(): void;
  92843. render(useCameraPostProcess?: boolean): void;
  92844. static get PurpleFireColors(): BABYLON.Color3[];
  92845. static get GreenFireColors(): BABYLON.Color3[];
  92846. static get RedFireColors(): BABYLON.Color3[];
  92847. static get BlueFireColors(): BABYLON.Color3[];
  92848. get autoGenerateTime(): boolean;
  92849. set autoGenerateTime(value: boolean);
  92850. get fireColors(): BABYLON.Color3[];
  92851. set fireColors(value: BABYLON.Color3[]);
  92852. get time(): number;
  92853. set time(value: number);
  92854. get speed(): BABYLON.Vector2;
  92855. set speed(value: BABYLON.Vector2);
  92856. get alphaThreshold(): number;
  92857. set alphaThreshold(value: number);
  92858. /**
  92859. * Serializes this fire procedural texture
  92860. * @returns a serialized fire procedural texture object
  92861. */
  92862. serialize(): any;
  92863. /**
  92864. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92865. * @param parsedTexture defines parsed texture data
  92866. * @param scene defines the current scene
  92867. * @param rootUrl defines the root URL containing fire procedural texture information
  92868. * @returns a parsed Fire Procedural BABYLON.Texture
  92869. */
  92870. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92871. }
  92872. }
  92873. declare module BABYLON {
  92874. /** @hidden */
  92875. export var grassProceduralTexturePixelShader: {
  92876. name: string;
  92877. shader: string;
  92878. };
  92879. }
  92880. declare module BABYLON {
  92881. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92882. private _grassColors;
  92883. private _groundColor;
  92884. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92885. updateShaderUniforms(): void;
  92886. get grassColors(): BABYLON.Color3[];
  92887. set grassColors(value: BABYLON.Color3[]);
  92888. get groundColor(): BABYLON.Color3;
  92889. set groundColor(value: BABYLON.Color3);
  92890. /**
  92891. * Serializes this grass procedural texture
  92892. * @returns a serialized grass procedural texture object
  92893. */
  92894. serialize(): any;
  92895. /**
  92896. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92897. * @param parsedTexture defines parsed texture data
  92898. * @param scene defines the current scene
  92899. * @param rootUrl defines the root URL containing grass procedural texture information
  92900. * @returns a parsed Grass Procedural BABYLON.Texture
  92901. */
  92902. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92903. }
  92904. }
  92905. declare module BABYLON {
  92906. /** @hidden */
  92907. export var marbleProceduralTexturePixelShader: {
  92908. name: string;
  92909. shader: string;
  92910. };
  92911. }
  92912. declare module BABYLON {
  92913. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92914. private _numberOfTilesHeight;
  92915. private _numberOfTilesWidth;
  92916. private _amplitude;
  92917. private _jointColor;
  92918. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92919. updateShaderUniforms(): void;
  92920. get numberOfTilesHeight(): number;
  92921. set numberOfTilesHeight(value: number);
  92922. get amplitude(): number;
  92923. set amplitude(value: number);
  92924. get numberOfTilesWidth(): number;
  92925. set numberOfTilesWidth(value: number);
  92926. get jointColor(): BABYLON.Color3;
  92927. set jointColor(value: BABYLON.Color3);
  92928. /**
  92929. * Serializes this marble procedural texture
  92930. * @returns a serialized marble procedural texture object
  92931. */
  92932. serialize(): any;
  92933. /**
  92934. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  92935. * @param parsedTexture defines parsed texture data
  92936. * @param scene defines the current scene
  92937. * @param rootUrl defines the root URL containing marble procedural texture information
  92938. * @returns a parsed Marble Procedural BABYLON.Texture
  92939. */
  92940. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92941. }
  92942. }
  92943. declare module BABYLON {
  92944. /** @hidden */
  92945. export var normalMapProceduralTexturePixelShader: {
  92946. name: string;
  92947. shader: string;
  92948. };
  92949. }
  92950. declare module BABYLON {
  92951. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92952. private _baseTexture;
  92953. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92954. updateShaderUniforms(): void;
  92955. render(useCameraPostProcess?: boolean): void;
  92956. resize(size: any, generateMipMaps: any): void;
  92957. isReady(): boolean;
  92958. get baseTexture(): BABYLON.Texture;
  92959. set baseTexture(texture: BABYLON.Texture);
  92960. /**
  92961. * Serializes this normal map procedural texture
  92962. * @returns a serialized normal map procedural texture object
  92963. */
  92964. serialize(): any;
  92965. /**
  92966. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92967. * @param parsedTexture defines parsed texture data
  92968. * @param scene defines the current scene
  92969. * @param rootUrl defines the root URL containing normal map procedural texture information
  92970. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92971. */
  92972. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92973. }
  92974. }
  92975. declare module BABYLON {
  92976. /** @hidden */
  92977. export var perlinNoiseProceduralTexturePixelShader: {
  92978. name: string;
  92979. shader: string;
  92980. };
  92981. }
  92982. declare module BABYLON {
  92983. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92984. time: number;
  92985. timeScale: number;
  92986. translationSpeed: number;
  92987. private _currentTranslation;
  92988. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92989. updateShaderUniforms(): void;
  92990. render(useCameraPostProcess?: boolean): void;
  92991. resize(size: any, generateMipMaps: any): void;
  92992. /**
  92993. * Serializes this perlin noise procedural texture
  92994. * @returns a serialized perlin noise procedural texture object
  92995. */
  92996. serialize(): any;
  92997. /**
  92998. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92999. * @param parsedTexture defines parsed texture data
  93000. * @param scene defines the current scene
  93001. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93002. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93003. */
  93004. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93005. }
  93006. }
  93007. declare module BABYLON {
  93008. /** @hidden */
  93009. export var roadProceduralTexturePixelShader: {
  93010. name: string;
  93011. shader: string;
  93012. };
  93013. }
  93014. declare module BABYLON {
  93015. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93016. private _roadColor;
  93017. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93018. updateShaderUniforms(): void;
  93019. get roadColor(): BABYLON.Color3;
  93020. set roadColor(value: BABYLON.Color3);
  93021. /**
  93022. * Serializes this road procedural texture
  93023. * @returns a serialized road procedural texture object
  93024. */
  93025. serialize(): any;
  93026. /**
  93027. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93028. * @param parsedTexture defines parsed texture data
  93029. * @param scene defines the current scene
  93030. * @param rootUrl defines the root URL containing road procedural texture information
  93031. * @returns a parsed Road Procedural BABYLON.Texture
  93032. */
  93033. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93034. }
  93035. }
  93036. declare module BABYLON {
  93037. /** @hidden */
  93038. export var starfieldProceduralTexturePixelShader: {
  93039. name: string;
  93040. shader: string;
  93041. };
  93042. }
  93043. declare module BABYLON {
  93044. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93045. private _time;
  93046. private _alpha;
  93047. private _beta;
  93048. private _zoom;
  93049. private _formuparam;
  93050. private _stepsize;
  93051. private _tile;
  93052. private _brightness;
  93053. private _darkmatter;
  93054. private _distfading;
  93055. private _saturation;
  93056. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93057. updateShaderUniforms(): void;
  93058. get time(): number;
  93059. set time(value: number);
  93060. get alpha(): number;
  93061. set alpha(value: number);
  93062. get beta(): number;
  93063. set beta(value: number);
  93064. get formuparam(): number;
  93065. set formuparam(value: number);
  93066. get stepsize(): number;
  93067. set stepsize(value: number);
  93068. get zoom(): number;
  93069. set zoom(value: number);
  93070. get tile(): number;
  93071. set tile(value: number);
  93072. get brightness(): number;
  93073. set brightness(value: number);
  93074. get darkmatter(): number;
  93075. set darkmatter(value: number);
  93076. get distfading(): number;
  93077. set distfading(value: number);
  93078. get saturation(): number;
  93079. set saturation(value: number);
  93080. /**
  93081. * Serializes this starfield procedural texture
  93082. * @returns a serialized starfield procedural texture object
  93083. */
  93084. serialize(): any;
  93085. /**
  93086. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93087. * @param parsedTexture defines parsed texture data
  93088. * @param scene defines the current scene
  93089. * @param rootUrl defines the root URL containing startfield procedural texture information
  93090. * @returns a parsed Starfield Procedural BABYLON.Texture
  93091. */
  93092. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93093. }
  93094. }
  93095. declare module BABYLON {
  93096. /** @hidden */
  93097. export var woodProceduralTexturePixelShader: {
  93098. name: string;
  93099. shader: string;
  93100. };
  93101. }
  93102. declare module BABYLON {
  93103. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93104. private _ampScale;
  93105. private _woodColor;
  93106. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93107. updateShaderUniforms(): void;
  93108. get ampScale(): number;
  93109. set ampScale(value: number);
  93110. get woodColor(): BABYLON.Color3;
  93111. set woodColor(value: BABYLON.Color3);
  93112. /**
  93113. * Serializes this wood procedural texture
  93114. * @returns a serialized wood procedural texture object
  93115. */
  93116. serialize(): any;
  93117. /**
  93118. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93119. * @param parsedTexture defines parsed texture data
  93120. * @param scene defines the current scene
  93121. * @param rootUrl defines the root URL containing wood procedural texture information
  93122. * @returns a parsed Wood Procedural BABYLON.Texture
  93123. */
  93124. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93125. }
  93126. }